Block gojo2.xyz Redirects

Blocks redirects on gojo2.xyz without property overrides

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();