TouchGal 自动跳转

跳过5s等待

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         TouchGal 自动跳转
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  跳过5s等待
// @match        https://www.touchgal.us/*
// @grant        none
// @license      MIT
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    let lastUrl = location.href;

    
    function autoRedirect() {
        const currentUrl = location.href;

        
        if (currentUrl === lastUrl) return;
        lastUrl = currentUrl;

        
        if (currentUrl.includes('/redirect?url=')) {
            
            const targetUrl = getUrlParameter('url');

            if (targetUrl) {
                window.location.href = decodeURIComponent(targetUrl);
            }
        }
    }

  
    function getUrlParameter(name) {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get(name);
    }

    autoRedirect();
    const originalPushState = history.pushState;
    const originalReplaceState = history.replaceState;

    history.pushState = function() {
        originalPushState.apply(history, arguments);
        setTimeout(autoRedirect, 100);
    };

    history.replaceState = function() {
        originalReplaceState.apply(history, arguments);
        setTimeout(autoRedirect, 100);
    };

    window.addEventListener('popstate', function() {
        setTimeout(autoRedirect, 100);
    });

    window.addEventListener('hashchange', function() {
        setTimeout(autoRedirect, 100);
    });
})();