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와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 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!');
})();