From a09f2b126a1e8011f3149f20150cfb8ab798ef15 Mon Sep 17 00:00:00 2001 From: "Mr. Stallion" Date: Sat, 24 Oct 2020 14:42:04 -0500 Subject: [PATCH] Tumblr/Twitter fixes --- chat/preview/assets/browser.pre.js | 7 +++++++ chat/preview/image-dom-mutator.ts | 4 ++-- chat/preview/image-url-mutator.ts | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/chat/preview/assets/browser.pre.js b/chat/preview/assets/browser.pre.js index 20ae614..59c3d3d 100644 --- a/chat/preview/assets/browser.pre.js +++ b/chat/preview/assets/browser.pre.js @@ -56,6 +56,13 @@ const previewInitiationTime = Date.now(); const clear = () => { if (window.location.href.match(/^https?:\/\/[a-zA-Z0-9-]+\.tumblr\.com/)) { // Because Tumblr sucks with their iframes + const og = document.querySelectorAll('meta[property="og:image"]:not([content=""])'); + + if (og.length > 0) { + window.location.href = og[0].content; + } + + // Must return anyway because... Tumblr sucks with their iframes return; } diff --git a/chat/preview/image-dom-mutator.ts b/chat/preview/image-dom-mutator.ts index 78a857d..3627d03 100644 --- a/chat/preview/image-dom-mutator.ts +++ b/chat/preview/image-dom-mutator.ts @@ -153,8 +153,8 @@ export class ImageDomMutator { this.add('vimeo.com', this.getBaseJsMutatorScript(['#video, video', '#image, img'])); this.add('sex.com', this.getBaseJsMutatorScript(['.image_frame video', '.image_frame img'])); // this.add('redirect.media.tumblr.com', this.getBaseJsMutatorScript(['picture video', 'picture img'])); - this.add(/^[a-zA-Z0-9-]+\.media\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset video', '.photoset img', '#base-container video', '#base-container img', 'picture video', 'picture img', 'video', 'img']), undefined, 'dom-ready'); - this.add(/^[a-zA-Z0-9-]+\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset iframe', '.photoset video', '.photoset img', 'picture video', 'picture img', 'video', 'img']), undefined, 'dom-ready'); + this.add(/^[a-zA-Z0-9-]+\.media\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset video', '.photoset img', 'img:not([role="img"]):not([alt="Avatar"])', '#base-container video', '#base-container img', 'picture video', 'picture img', 'video', 'img']), undefined, 'dom-ready'); + this.add(/^[a-zA-Z0-9-]+\.tumblr\.com$/, this.getBaseJsMutatorScript(['.photoset iframe', '.photoset video', '.photoset img', 'img:not([role="img"]):not([alt="Avatar"])', 'picture video', 'picture img', 'video', 'img']), undefined, 'dom-ready'); this.add('postimg.cc', this.getBaseJsMutatorScript(['video', '#main-image'])); this.add('gifsauce.com', this.getBaseJsMutatorScript(['video'])); // this.add('motherless.com', this.getBaseJsMutatorScript(['.content video', '.content img'])); diff --git a/chat/preview/image-url-mutator.ts b/chat/preview/image-url-mutator.ts index 55345a0..ce612c6 100644 --- a/chat/preview/image-url-mutator.ts +++ b/chat/preview/image-url-mutator.ts @@ -25,6 +25,11 @@ export class ImageUrlMutator { } protected init(): void { + this.add( + /^https?:\/\/.*twitter.com/, + async(): Promise => 'https://i.imgur.com/ScNLbsp.png' + ); + this.add( /^https?:\/\/(www.)?pornhub.com\/view_video.php\?viewkey=([a-z0-9A-Z]+)/, async(_url: string, match: RegExpMatchArray): Promise => {