Bypass

Skips timers, removes ads, resolves safelinks, and auto-redirects on kimochi.info and ryuugames.com

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bypass
// @namespace    Bypass
// @version      3.0
// @description  Skips timers, removes ads, resolves safelinks, and auto-redirects on kimochi.info and ryuugames.com
// @author       gdlbo
// @match        *://kimochi.info/download/*
// @match        *://*.ryuugames.com/processing/download*
// @match        *://*.ryuugames.com/*download*
// @match        *://www.ryuugames.com/wp-json/ryuu-safelink/v1/redirect/*
// @grant        GM_addStyle
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const origSetTimeout = window.setTimeout;
    const origSetInterval = window.setInterval;

    window.setTimeout = (fn, delay, ...args) => origSetTimeout(fn, delay && delay < 120000 ? 50 : delay, ...args);
    window.setInterval = (fn, delay, ...args) => origSetInterval(fn, delay && delay < 120000 ? 50 : delay, ...args);

    window.alert = () => {};
    window.confirm = () => true;
    window.prompt = () => null;
    if (window.Notification) {
        Notification.requestPermission = () => Promise.resolve('denied');
    }

    const adStyles = `
        #ryuu-sl-ad-banner, #ryuu-sl-ad-banner-2, #ryuu-sl-ad-button-1, #ryuu-sl-ad-button-2,
        #ryuu-sl-skyscraper-left, #ryuu-sl-skyscraper-right,
        [class*="ad-"], [id*="ad-"], [class*="_ad"], [id*="_ad"],
        .popup, .modal, .overlay, .ad-container, .ad-banner,
        iframe[src*="ads"], iframe[id*="google_ads"] {
            display: none !important;
            visibility: hidden !important;
            pointer-events: none !important;
            width: 0 !important;
            height: 0 !important;
        }
    `;
    if (typeof GM_addStyle !== 'undefined') {
        GM_addStyle(adStyles);
    } else {
        const style = document.createElement('style');
        style.textContent = adStyles;
        document.head.appendChild(style);
    }

    const blockPattern = /(adblock|adb|detectad|fuckadblock|disabledevtools)/i;
    const adObserver = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (node.nodeType === 1 && (node.tagName === 'SCRIPT' || node.tagName === 'IFRAME')) {
                    const source = node.src || node.textContent || '';
                    if (blockPattern.test(source)) node.remove();
                }
            });
        });
    });
    adObserver.observe(document, { childList: true, subtree: true });

    function waitForElement(selector, timeout = 3000) {
        return new Promise(resolve => {
            const el = document.querySelector(selector);
            if (el) return resolve(el);
            const observer = new MutationObserver(() => {
                const target = document.querySelector(selector);
                if (target) {
                    observer.disconnect();
                    resolve(target);
                }
            });
            observer.observe(document.documentElement, { childList: true, subtree: true });
            if (timeout > 0) setTimeout(() => { observer.disconnect(); resolve(null); }, timeout);
        });
    }

    if (window.location.pathname.startsWith('/wp-json/ryuu-safelink/v1/redirect/')) {
        try {
            const text = document.body.textContent || document.querySelector('pre')?.textContent || '';
            const data = JSON.parse(text);
            const url = data?.url || data?.data?.url || data?.redirect || (data?.success && typeof data?.data === 'string' && data.data.startsWith('http') ? data.data : null);
            if (url) window.location.replace(url);
        } catch (e) {
            const match = (document.body.textContent || '').match(/https?:\/\/[^\s"']+/);
            if (match) window.location.replace(match[0]);
        }
        return;
    }

    async function handleRyuugames() {
        const btn = await waitForElement('#ryuu-sl-download-btn');
        if (!btn) return;

        btn.disabled = false;
        btn.classList.remove('ryuu-sl-disabled');
        btn.classList.add('ryuu-sl-ready');
        btn.style.display = 'block';
        btn.style.pointerEvents = 'auto';

        const btnText = document.getElementById('ryuu-sl-btn-text');
        const countdownEl = document.getElementById('ryuu-sl-countdown-number');
        const progressEl = document.getElementById('ryuu-sl-progress');

        if (btnText) btnText.textContent = 'Download';
        if (countdownEl) countdownEl.textContent = '0';
        if (progressEl) progressEl.style.strokeDashoffset = '0';

        setTimeout(() => {
            ['mouseover', 'mousedown', 'mouseup', 'click'].forEach(evt => {
                btn.dispatchEvent(new MouseEvent(evt, { bubbles: true, cancelable: true }));
            });
        }, 600);
    }

    async function handleKimochi() {
        const btn = await waitForElement('#downloadBtn');
        if (!btn) return;

        btn.style.display = 'block';
        btn.style.visibility = 'visible';
        btn.style.opacity = '1';
        btn.removeAttribute('disabled');
        btn.style.pointerEvents = 'auto';

        const hrefObserver = new MutationObserver(() => {
            if (btn.href && btn.href.startsWith('http')) {
                hrefObserver.disconnect();
                window.location.replace(btn.href);
            }
        });
        hrefObserver.observe(btn, { attributes: true, attributeFilter: ['href'] });

        if (btn.href && btn.href.startsWith('http')) {
            window.location.replace(btn.href);
        }
    }

    if (window.location.hostname.includes('ryuugames.com')) {
        handleRyuugames();
    } else if (window.location.hostname.includes('kimochi.info')) {
        handleKimochi();
    }
})();