NGA Auto Redirect

Automatically skips NGA external link redirection pages.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

// ==UserScript==
// @name         NGA Auto Redirect
// @name:zh-CN   NGA 外链自动跳转
// @name:zh-TW   NGA 外鏈自動跳轉
// @namespace    https://greasyfork.org/en/users/1575945-star-tanuki07
// @homepageURL  https://github.com/Startanuki07
// @version      0.1.0.0
// @description         Automatically skips NGA external link redirection pages.
// @description:zh-CN   自动跳过 NGA 外链重定向页面。
// @description:zh-TW   自動跳過 NGA 外部連結重定向頁面。
// @author       Star_tanuki07
// @match        *://nga.cn/*
// @match        *://ngabbs.com/*
// @match        *://bbs.nga.cn/*
// @match        *://nga.178.com/*
// @grant        none
// @license      MIT
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nga.cn
// ==/UserScript==

(function() {
    'use strict';

    const SELECTOR = 'a[onclick="g()"]';
    let timeoutId;

    const observer = new MutationObserver(function(mutations) {
        for (const mutation of mutations) {
            for (const node of mutation.addedNodes) {
                if (node.nodeType !== 1) continue;
                const link = node.matches(SELECTOR)
                    ? node
                    : node.querySelector(SELECTOR);
                if (link) {
                    link.click();
                    observer.disconnect();
                    clearTimeout(timeoutId);
                    return;
                }
            }
        }
    });

    if (!document.body) return;

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    timeoutId = setTimeout(() => {
        observer.disconnect();
        console.warn('[NGA Auto] Observer timed out — redirect link not found');
    }, 15000);

    const existingLink = document.querySelector(SELECTOR);
    if (existingLink) {
        existingLink.click();
        observer.disconnect();
        clearTimeout(timeoutId);
    }

})();