Block gojo2.xyz Redirects

Blocks redirects on gojo2.xyz without property overrides

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Block gojo2.xyz Redirects
// @namespace    http://tampermonkey.net/
// @version      1.8
// @description  Blocks redirects on gojo2.xyz without property overrides
// @author       You
// @match        https://gojo2.xyz/*
// @run-at       document-start
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    console.log("Script injected at document-start on", window.location.href);

    // Block navigation early
    window.addEventListener('beforeunload', function(e) {
        console.log("Navigation attempt detected to:", window.location.href);
        e.preventDefault();
        e.returnValue = '';
    }, { capture: true });

    // Block setTimeout/setInterval without redefining
    const originalSetTimeout = window.setTimeout;
    window.setTimeout = function(fn, delay) {
        if (typeof fn === 'function') {
            const fnStr = fn.toString();
            if (fnStr.includes('location') || fnStr.includes('redirect') || fnStr.includes('href')) {
                console.log("Blocked setTimeout redirect attempt:", fnStr);
                return null;
            }
        }
        return originalSetTimeout(fn, delay);
    };

    const originalSetInterval = window.setInterval;
    window.setInterval = function(fn, delay) {
        if (typeof fn === 'function') {
            const fnStr = fn.toString();
            if (fnStr.includes('location') || fnStr.includes('redirect') || fnStr.includes('href')) {
                console.log("Blocked setInterval redirect attempt:", fnStr);
                return null;
            }
        }
        return originalSetInterval(fn, delay);
    };

    // Block meta refresh and scripts
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            // Meta tags
            const metaTags = document.querySelectorAll('meta[http-equiv="refresh"]');
            metaTags.forEach(tag => {
                console.log("Found meta refresh tag:", tag.content);
                tag.remove();
                console.log("Removed meta refresh tag");
            });
            // Scripts
            const scripts = document.querySelectorAll('script');
            scripts.forEach(script => {
                if (script.textContent.includes('location') || script.textContent.includes('redirect') || script.textContent.includes('href')) {
                    console.log("Blocked script with redirect potential:", script.textContent.slice(0, 50) + "...");
                    script.remove();
                }
            });
        });
    });
    observer.observe(document.documentElement, { childList: true, subtree: true });
    console.log("Mutation observer started at document-start");

    console.log("Redirect blocker fully active on", window.location.href);
})();