Image preview fixes
This commit is contained in:
		
							parent
							
								
									7b26c273bd
								
							
						
					
					
						commit
						4d1f2fd0d6
					
				@ -54,6 +54,10 @@ const previewInitiationTime = Date.now();
 | 
			
		||||
(() => {
 | 
			
		||||
    try {
 | 
			
		||||
        const clear = () => {
 | 
			
		||||
            if (window.location.href.match(/^https?:\/\/(www\.)?redgifs\.com/)) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            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=""])');
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,8 @@ class FListImagePreviewDomMutator {
 | 
			
		||||
            skipElementRemove: false,
 | 
			
		||||
            safeTags: [],
 | 
			
		||||
            injectStyle: false,
 | 
			
		||||
            delayPreprocess: false
 | 
			
		||||
            delayPreprocess: false,
 | 
			
		||||
            schedule: false
 | 
			
		||||
        };
 | 
			
		||||
        /* ## SETTINGS_END ## */
 | 
			
		||||
 | 
			
		||||
@ -113,6 +114,8 @@ class FListImagePreviewDomMutator {
 | 
			
		||||
        this.updateImgSizeTimer(this.img);
 | 
			
		||||
 | 
			
		||||
        this.cleanDom(this.body);
 | 
			
		||||
 | 
			
		||||
        this.finalize();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -396,9 +399,51 @@ class FListImagePreviewDomMutator {
 | 
			
		||||
    error(...args) {
 | 
			
		||||
        console.error('DOM Mutator:', ...args, `${(Date.now() - this.startTime)/1000}s`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    finalize(counter) {
 | 
			
		||||
        if (counter <= 0) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setTimeout(
 | 
			
		||||
            () => {
 | 
			
		||||
                if (this.img) {
 | 
			
		||||
                    this.attemptPlay(this.img);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                this.finalize(counter - 1);
 | 
			
		||||
            },
 | 
			
		||||
            100
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    scheduler() {
 | 
			
		||||
        setTimeout(
 | 
			
		||||
            () => {
 | 
			
		||||
                this.img = this.detectImage(this.selectors, this.body);
 | 
			
		||||
 | 
			
		||||
                if (!this.img) {
 | 
			
		||||
                    this.scheduler();
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                this.run();
 | 
			
		||||
            },
 | 
			
		||||
            200
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    execute() {
 | 
			
		||||
        if (this.settings.schedule) {
 | 
			
		||||
            this.scheduler();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.run();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ## EXECUTION_START ## */
 | 
			
		||||
const flistImagePreviewMutator = new FListImagePreviewDomMutator();
 | 
			
		||||
flistImagePreviewMutator.run();
 | 
			
		||||
flistImagePreviewMutator.execute();
 | 
			
		||||
/* ## EXECUTION_END ## */
 | 
			
		||||
 | 
			
		||||
@ -168,7 +168,7 @@ export class ImageDomMutator {
 | 
			
		||||
        this.add('sexbot.gallery', this.getBaseJsMutatorScript(['video.hero', 'video']));
 | 
			
		||||
        this.add('imagefap.com', this.getBaseJsMutatorScript(['.image-wrapper img', 'video', 'img']));
 | 
			
		||||
        this.add('myhentaicomics.com', this.getBaseJsMutatorScript(['#entire_image img', 'video', 'img']));
 | 
			
		||||
        this.add('redgifs.com', this.getBaseJsMutatorScript(['video']));
 | 
			
		||||
        this.add('redgifs.com', this.getBaseJsMutatorScript(['video'], true, [], false, true));
 | 
			
		||||
        this.add('furaffinity.net', this.getBaseJsMutatorScript(['#submissionImg', 'video', 'img']));
 | 
			
		||||
        this.add('rule34.paheal.net', this.getBaseJsMutatorScript(['#main_image', 'video', 'img']));
 | 
			
		||||
        this.add('xhamster.com', this.getBaseJsMutatorScript(['#photo_slider video', '#photo_slider img', 'video', 'img']));
 | 
			
		||||
@ -316,7 +316,7 @@ export class ImageDomMutator {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    protected getBaseJsMutatorScript(elSelector: string[], skipElementRemove: boolean = false, safeTags: string[] = [], delayPreprocess = false): string {
 | 
			
		||||
    protected getBaseJsMutatorScript(elSelector: string[], skipElementRemove: boolean = false, safeTags: string[] = [], delayPreprocess: boolean = false, scheduled: boolean = false): string {
 | 
			
		||||
        const js = this.scripts.processor; // ./assets/browser.processor.raw.js
 | 
			
		||||
 | 
			
		||||
        const settings = {
 | 
			
		||||
@ -324,6 +324,7 @@ export class ImageDomMutator {
 | 
			
		||||
            safeTags,
 | 
			
		||||
            delayPreprocess,
 | 
			
		||||
            selectors: elSelector,
 | 
			
		||||
            schedule: scheduled,
 | 
			
		||||
            debug: this.debug
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -68,6 +68,15 @@ export class ImageUrlMutator {
 | 
			
		||||
          }
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        this.add(
 | 
			
		||||
          /^https?:\/\/media[0-9]?.giphy.com\/media\/(.+)$/,
 | 
			
		||||
          async(_url: string, match: RegExpMatchArray): Promise<string> => {
 | 
			
		||||
            const giphyUri = match[1];
 | 
			
		||||
 | 
			
		||||
            return `https://i.giphy.com/media/${giphyUri}`;
 | 
			
		||||
          }
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        this.add(
 | 
			
		||||
          /^https?:\/\/(www.)?gfycat.com\/([a-z0-9A-Z\-]+)\/?$/,
 | 
			
		||||
          async(_url: string, match: RegExpMatchArray): Promise<string> => {
 | 
			
		||||
@ -77,6 +86,7 @@ export class ImageUrlMutator {
 | 
			
		||||
          }
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        this.add(
 | 
			
		||||
          /^https?:\/\/e621.net\/(posts|post\/show)\/([0-9]+)/,
 | 
			
		||||
          async(url: string, match: RegExpMatchArray): Promise<string> => {
 | 
			
		||||
 | 
			
		||||
@ -127,3 +127,6 @@
 | 
			
		||||
 | 
			
		||||
    [url=https://www.hentai-foundry.com/pictures/user/LeraPI/879374/PDQ-style-my-OC-Violette]Hentai-foundry.com[/url]
 | 
			
		||||
 | 
			
		||||
    [url=https://www.redgifs.com/watch/blissfulhandywhoopingcrane]Redgifs.com[/url]
 | 
			
		||||
 | 
			
		||||
    [url=https://media.giphy.com/media/P7hen0jkFBud3EZ6ez/giphy.gif]Giphy[/url]
 | 
			
		||||
 | 
			
		||||
@ -239,6 +239,10 @@ function createWindow(): Electron.BrowserWindow | undefined {
 | 
			
		||||
 | 
			
		||||
            blocker.enableBlockingInSession(electron.session.defaultSession);
 | 
			
		||||
 | 
			
		||||
            // blocker.blockStyles();
 | 
			
		||||
            blocker.blockFonts();
 | 
			
		||||
            // blocker.blockScripts();
 | 
			
		||||
 | 
			
		||||
            // Temp fix -- manually override adblocker's preload script
 | 
			
		||||
            // to point to CJS  that has been copied over with config in webpack.config.js
 | 
			
		||||
            // require.resolve('@cliqz/adblocker-electron-preload');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user