Adblock Protector Revived

Advanced protection against adblock detectors and invasive scripts

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

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

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==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!');
})();