// ==UserScript== // @name Universal Image Host Interceptor // @namespace https://greasyfork.org/users/108513 // @version 1.0 // @description Clean and fast image viewing for Fastpic, Imgbox, ImgDrive, Pixhost, ImageBam, and many more. Features: Stealth Mode (no ads/flash), Auto-Redirect (gateway bypass), and Anti-Loop. // @description:fr Visionneuse d'image rapide et propre pour Fastpic, Imgbox, ImgDrive, Pixhost, ImageBam et bien d'autres. Fonctionnalités : Mode Furtif (pas de pubs/flash), Redirection Auto (contournement des pages d'attente) et Anti-Boucle. // @author seb-du17 // @match *://imgbox.com/* // @match *://*.imgbox.com/* // @match *://fastpic.org/view/* // @match *://imgxxt.in/* // @match *://imgdrive.net/* // @match *://imagebam.com/view/* // @match *://www.imagebam.com/image/* // @match *://turboimagehost.com/* // @match *://imagetwist.com/* // @match *://vipr.im/* // @match *://pixhost.to/* // @match *://*.pixhost.to/* // @match *://pimpandhost.com/* // @match *://*.imagevenue.com/* // @match *://imx.to/* // @match *://*.imx.to/* // @icon https://www.google.com/s2/favicons?sz=64&domain=fastpic.org // @grant none // @run-at document-start // @compatible firefox // @compatible chrome // @license MIT // @downloadURL none // ==/UserScript== /* jshint esversion:11 */ (function() { 'use strict'; // --- UTILS --- const noop = () => {}; window.console.log = noop; window.console.warn = noop; const HOST = window.location.hostname; const HREF = window.location.href; // --- CORE ENGINE --- const render = (url) => { if (!document.documentElement) { requestAnimationFrame(() => render(url)); return; } const stealthIds = ['fp-stealth', 'imx-stealth', 'drive-stealth', 'box-stealth', 'bam-stealth']; stealthIds.forEach(id => { const el = document.getElementById(id); if (el) { el.remove(); } }); document.documentElement.style.visibility = 'visible'; document.documentElement.style.background = 'none'; if (document.head) { while (document.head.firstChild) { document.head.removeChild(document.head.firstChild); } } if (document.body) { while (document.body.firstChild) { document.body.removeChild(document.body.firstChild); } } requestAnimationFrame(() => { if (!document.head) { document.documentElement.appendChild(document.createElement('head')); } if (!document.body) { document.documentElement.appendChild(document.createElement('body')); } document.head.innerHTML = ` Image View `; document.body.innerHTML = `Full Size`; new MutationObserver((mutations) => { mutations.forEach((m) => { m.addedNodes.forEach((n) => { if (n.tagName === 'SCRIPT' || n.tagName === 'IFRAME') { n.remove(); } }); }); }).observe(document.documentElement, { childList: true, subtree: true }); }); }; const cleanAndShow = (src, refererHost) => { try { window.stop(); } catch (e) {} src = src.replace(/\\\//g, '/'); if (src.startsWith('//')) { src = window.location.protocol + src; } if (refererHost === 'fastpic') { render(src); return; } if (refererHost === 'pixhost') { if (src.includes('/thumbs/')) { const newSrc = src.replace('//t', '//img').replace('/thumbs/', '/images/'); const imgCheck = new Image(); imgCheck.onload = () => { render(newSrc); }; imgCheck.onerror = () => { render(src); }; imgCheck.src = newSrc; return; } } else { src = src.replace(/(\.|_)(md|th|tn|thumbnail|preview)(\.|_)/i, '$1$3'); } render(src); }; // --- MODULES --- const Modules = { fastpic: { check: () => HOST.includes('fastpic'), init: () => { if (document.documentElement) { const s = document.createElement('style'); s.id = 'fp-stealth'; s.textContent = 'html, body { visibility: hidden !important; background: #0e0e0e !important; }'; document.documentElement.appendChild(s); } }, extract: () => { const imgs = document.getElementsByTagName('img'); for (let i = 0; i < imgs.length; i++) { if (imgs[i].src && imgs[i].src.includes('/big/')) { return imgs[i].src; } } const imgOld = document.querySelector('#image'); if (imgOld && imgOld.src) { return imgOld.src; } return null; }, onFail: () => { const s = document.getElementById('fp-stealth'); if (s) { s.remove(); } if (document.documentElement) { document.documentElement.style.visibility = 'visible'; } } }, pixhost: { check: () => HOST.includes('pixhost'), extract: () => { const scripts = document.getElementsByTagName('script'); for (let i = 0; i < scripts.length; i++) { const html = scripts[i].innerHTML; if (html.includes('pswp_items')) { const urls = html.match(/https?:\\?\/\\?\/[^"']+\.(jpg|jpeg|png|webp)/gi); if (urls && urls.length > 0) { const best = urls.find(u => !u.includes('/thumbs/') && !u.includes('/show/')) || urls[0]; if (!best.includes('/show/')) { return best; } } } } const img = document.querySelector('#image, #show_image, img.image-center'); if (img && img.src && !img.src.includes('/show/')) { return img.src; } return null; } }, imx: { check: () => HOST.includes('imx.to'), init: () => { if (document.documentElement) { const s = document.createElement('style'); s.id = 'imx-stealth'; s.textContent = 'html, body { visibility: hidden !important; background: #0e0e0e !important; }'; document.documentElement.appendChild(s); } }, extract: () => { const img = document.querySelector('#iimg') || document.querySelector('img.centred'); if (img) { return img.src; } const urlParts = HREF.split('/'); const id = urlParts[urlParts.length - 1]; if (id.length > 3) { const candidate = document.querySelector(`img[src*="${id}"]`); if (candidate && !candidate.src.includes('logo')) { return candidate.src; } } const continueBtn = document.querySelector('input[name="imgContinue"]'); if (continueBtn) { const key = 'imx_click_' + HREF; if (!sessionStorage.getItem(key)) { sessionStorage.setItem(key, '1'); setTimeout(() => { continueBtn.click(); }, 500); } return null; } return null; }, onFail: () => { const s = document.getElementById('imx-stealth'); if (s) { s.remove(); } if (document.documentElement) { document.documentElement.style.visibility = 'visible'; } } }, imagevenue: { check: () => HOST.includes('imagevenue.com'), extract: () => { const continueLink = document.querySelector('a[title="Continue to ImageVenue"]'); if (continueLink && continueLink.href) { window.location.href = continueLink.href; return null; } const img = document.querySelector('img.card-img-top') || document.querySelector('#main-image'); if (img) { return img.src; } const imgs = document.querySelectorAll('img[src*=".jpg"], img[src*=".jpeg"], img[src*=".png"]'); for (let i = 0; i < imgs.length; i++) { if (imgs[i].naturalWidth > 300 || (imgs[i].style.width && parseInt(imgs[i].style.width) > 300)) { return imgs[i].src; } } return null; } }, imagetwist: { check: () => HOST.includes('imagetwist') || HOST.includes('vipr.im'), extract: () => { let img = document.querySelector('img.pic'); if (img && img.src) { return img.src; } const urlParts = HREF.split('/'); const filename = urlParts[urlParts.length - 1]; if (filename.length > 5) { const selector = `img[src*="${filename}"]`; const candidate = document.querySelector(selector); if (candidate && candidate.src !== HREF) { return candidate.src; } } return null; } }, imgxxt: { check: () => HOST.includes('imgxxt'), extract: () => { const link = document.querySelector('link[rel="image_src"]'); if (link) { return link.href; } const meta = document.querySelector('meta[property="og:image"]'); if (meta) { return meta.content; } const v = document.querySelector('.image-viewer-container img'); if (v) { return v.src; } return null; } }, imgdrive: { check: () => HOST.includes('imgdrive'), init: () => { if (document.documentElement) { const s = document.createElement('style'); s.id = 'drive-stealth'; s.textContent = 'html, body { visibility: hidden !important; background: #0e0e0e !important; }'; document.documentElement.appendChild(s); } }, extract: () => { const og = document.querySelector('meta[property="og:image"]'); if (og && og.content) { const thumb = og.content; if (thumb.includes('/small/')) { const hd = thumb.replace('/small/', '/big/'); const imgTest = new Image(); imgTest.onload = () => { render(hd); }; imgTest.src = hd; } } const continueLink = document.querySelector('a[onclick*="closeOverlay"]'); if (continueLink) { if (typeof unsafeWindow !== 'undefined' && unsafeWindow.closeOverlay) { unsafeWindow.closeOverlay(); } else { continueLink.click(); } return null; } const img = document.querySelector('img.centred_resized, img.main-image, img.pic'); if (img) { return img.src; } const imgId = document.querySelector('#myImage, #main_image'); if (imgId) { return imgId.src; } return null; }, onFail: () => { const s = document.getElementById('drive-stealth'); if (s) { s.remove(); } if (document.documentElement) { document.documentElement.style.visibility = 'visible'; } } }, imgbox: { check: () => HOST.includes('imgbox'), init: () => { if (document.documentElement) { const s = document.createElement('style'); s.id = 'box-stealth'; s.textContent = 'html, body { visibility: hidden !important; background: #0e0e0e !important; }'; document.documentElement.appendChild(s); } }, extract: () => { if (HREF.match(/\.(jpg|jpeg|png|gif)$/i)) { return HREF; } const img = document.querySelector('#img'); if (img) { return img.src; } return null; }, onFail: () => { const s = document.getElementById('box-stealth'); if (s) { s.remove(); } if (document.documentElement) { document.documentElement.style.visibility = 'visible'; } } }, imagebam: { check: () => HOST.includes('imagebam'), init: () => { if (document.documentElement) { const s = document.createElement('style'); s.id = 'bam-stealth'; s.textContent = 'html, body { visibility: hidden !important; background: #0e0e0e !important; }'; document.documentElement.appendChild(s); } document.cookie = "nsfw_inter=1; path=/"; }, extract: () => { const img = document.querySelector('img.main-image'); if (img) { return img.src; } const continueLink = document.querySelector('a[data-shown="inter"]'); if (continueLink) { continueLink.click(); return null; } const allLinks = document.getElementsByTagName('a'); for(let i=0; i 300 || (imgs[i].style.width && parseInt(imgs[i].style.width) > 300)) { return imgs[i].src; } } return null; }, onFail: () => { const s = document.getElementById('bam-stealth'); if (s) { s.remove(); } if (document.documentElement) { document.documentElement.style.visibility = 'visible'; } } }, generic: { check: () => true, extract: () => { if (HOST.includes('pimpandhost')) { return document.querySelector('.main-image-wrapper')?.dataset.src; } return null; } } }; // --- MAIN LOOP --- let activeModule = Modules.generic; if (Modules.fastpic.check()) { activeModule = Modules.fastpic; } else if (Modules.imgdrive.check()) { activeModule = Modules.imgdrive; } else if (Modules.imgbox.check()) { activeModule = Modules.imgbox; } else if (Modules.imagebam.check()) { activeModule = Modules.imagebam; } else if (Modules.pixhost.check()) { activeModule = Modules.pixhost; } else if (Modules.imagetwist.check()) { activeModule = Modules.imagetwist; } else if (Modules.imgxxt.check()) { activeModule = Modules.imgxxt; } else if (Modules.imagevenue.check()) { activeModule = Modules.imagevenue; } else if (Modules.imx.check()) { activeModule = Modules.imx; } if (activeModule.init) { activeModule.init(); } let src = activeModule.extract(); if (src) { cleanAndShow(src, activeModule === Modules.fastpic ? 'fastpic' : (activeModule === Modules.pixhost ? 'pixhost' : null)); return; } let attempts = 0; const poller = setInterval(() => { src = activeModule.extract(); attempts++; if (src) { clearInterval(poller); cleanAndShow(src, activeModule === Modules.fastpic ? 'fastpic' : (activeModule === Modules.pixhost ? 'pixhost' : null)); } else if (attempts > 40) { clearInterval(poller); if (activeModule.onFail) { activeModule.onFail(); } } }, 250); })();