Adblock Protector Revived

Advanced protection against adblock detectors and invasive scripts

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Adblock Protector Revived
// @name:it      Adblock Protector Revived
// @version      1.5.1
// @description  Advanced protection against adblock detectors and invasive scripts
// @description:it Protezione avanzata contro rilevatori di adblock e script invasivi
// @author       itzkuiicha
// @license      MIT
// @match        *://*/*
// @grant        none
// @run-at       document-start
// @noframes
// @namespace    https://greasyfork.org/users/1451793
// ==/UserScript==

(function() {
    'use strict';

    const CONFIG = {
        blockLevel: 2, // 1=Yandex, 2=+RU, 3=Nuclear
        aggressiveness: 3,
        cleanInterval: 1500,
        telemetry: ['stats.ipaper.io', 'mc.yandex.ru', 'sentry.io', 'amplitude.com'] // Aggiunta altra telemetria comune
    };

    const BLOCKED_DOMAINS = [
        'ya.*', 'yandex.*', 'yastatic.*', 'yandex.ru', 'yandex.net',
        'mail.ru', 'zen.ru', 'vk.ru', 'vk.com', 'ok.ru', 'imgsmail.ru', 'my.games',
        ...CONFIG.blockLevel >= 3 ? ['*.ru', '*.by', '*.рф', '*.su', '*.kz'] : []
    ];

    const DOMAIN_REGEX = BLOCKED_DOMAINS.map(pat =>
        new RegExp(`^(https?|wss?)://([a-z0-9-]+\\.)*${pat.replace(/\./g, '\\.').replace(/\*/g, '.*')}|//([a-z0-9-]+\\.)*${pat.replace(/\./g, '\\.').replace(/\*/g, '.*')}|([a-z0-9-]+\\.)*${pat.replace(/\./g, '\\.').replace(/\*/g, '.*')}/`, 'i')
    );

    const isBlocked = (url) => {
        if (!url || typeof url !== 'string') return false;
        try {
            const decUrl = decodeURIComponent(url).toLowerCase();
            return DOMAIN_REGEX.some(r => r.test(decUrl)) || CONFIG.telemetry.some(t => decUrl.includes(t));
        } catch (e) {
            return DOMAIN_REGEX.some(r => r.test(url.toLowerCase()));
        }
    };

    // Intercettori di Rete
    const nativeFetch = window.fetch;
    window.fetch = (input, init) => {
        const url = (typeof input === 'string') ? input : (input?.url || '');
        if (isBlocked(url)) {
            return Promise.resolve(new Response(null, { status: 403, statusText: 'Blocked by Adblock Protector Revived' }));
        }
        return nativeFetch.call(window, input, init);
    };

    const nativeOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        if (isBlocked(url)) {
            this.abort();
            return;
        }
        nativeOpen.apply(this, arguments);
    };

    if (navigator.sendBeacon) {
        const nativeBeacon = navigator.sendBeacon;
        navigator.sendBeacon = (url, data) => {
            if (isBlocked(url)) return true;
            return nativeBeacon.call(navigator, url, data);
        };
    }

    // Pulizia DOM Aggressiva
    const elementsToClean = ['script', 'iframe', 'img', 'link', 'embed', 'object', 'source', 'style', 'div[id*="ad-"]'];

    const cleanDOM = () => {
        document.querySelectorAll(elementsToClean.join(',')).forEach(el => {
            const src = el.src || el.href || el.dataset?.src || el.srcset;
            if (src && isBlocked(src)) {
                el.remove();
            }
        });
    };

    // Monitoraggio Cambiamenti
    const observer = new MutationObserver((mutations) => {
        mutations.forEach(m => {
            m.addedNodes.forEach(nodo => {
                if (nodo.nodeType === 1) {
                    const url = nodo.src || nodo.href || nodo.dataset?.src;
                    if (url && isBlocked(url)) nodo.remove();
                }
            });
        });
        if (CONFIG.aggressiveness >= 2) cleanDOM();
    });

    if (document.documentElement) {
        observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['src', 'href', 'data-src', 'srcset'] });
    }

    // Difesa Attiva Periodica
    setInterval(cleanDOM, CONFIG.cleanInterval);

    console.info('Adblock Protector Revived by itzkuiicha active!');
})();