Adblock Protector Revived

Advanced protection against adblock detectors and invasive scripts

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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