您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Quietly block most redirects used by ad-heavy streaming sites (movieshd.watch, etc.) without breaking main page.
// ==UserScript== // @name Block Most Redirects (Simple) // @namespace https://github.com/osuobiem // @version 1.5 // @description Quietly block most redirects used by ad-heavy streaming sites (movieshd.watch, etc.) without breaking main page. // @author Gabriel Osuobiem // @match *://*/* // @run-at document-start // @grant none // ==/UserScript== (function () { 'use strict'; const log = (...args) => console.debug('[NoRedirect]', ...args); // Block window.open popups (ads) window.open = () => { log('Blocked window.open'); return null; }; // Block common location changes ['assign', 'replace', 'reload'].forEach(method => { try { const orig = window.location[method].bind(window.location); window.location[method] = (...args) => { log(`Blocked location.${method}`, args[0]); }; } catch (_) {} }); // Block direct location set try { Object.defineProperty(window, 'location', { set: (url) => log('Blocked direct location set to', url), get: () => document.location }); } catch (_) {} // Remove meta refresh tags (initial and added later) const removeMeta = () => { document.querySelectorAll('meta[http-equiv="refresh"]').forEach(m => { log('Removed meta refresh', m.content); m.remove(); }); }; new MutationObserver(removeMeta).observe(document.documentElement, { childList: true, subtree: true }); removeMeta(); // Block ad link clicks that cause immediate redirect document.addEventListener('click', (e) => { const a = e.target.closest('a[href]'); if (!a) return; if (!a.href.startsWith(window.location.origin)) { e.preventDefault(); log('Blocked external link click', a.href); } }, true); log('Simple redirect blocking active.'); })();