R34 AgeVerif Block

Блокировка загрузки скриптов ageverif.com

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         R34 AgeVerif Block
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Блокировка загрузки скриптов ageverif.com
// @match        https://rule34video.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rule34video.com
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const TARGET_DOMAIN = 'ageverif.com';

    // Перехват динамического создания тегов script
    const originalCreateElement = document.createElement;
    document.createElement = function (tagName, options) {
        const element = originalCreateElement.call(document, tagName, options);
        if (tagName && tagName.toLowerCase() === 'script') {
            const originalSetAttribute = element.setAttribute;
            element.setAttribute = function (name, value) {
                if (name && name.toLowerCase() === 'src' && typeof value === 'string' && value.includes(TARGET_DOMAIN)) {
                    return;
                }
                return originalSetAttribute.call(this, name, value);
            };

            Object.defineProperty(element, 'src', {
                set(url) {
                    if (typeof url === 'string' && url.includes(TARGET_DOMAIN)) {
                        return;
                    }
                    element.setAttribute('src', url);
                },
                get() {
                    return element.getAttribute('src') || '';
                },
                configurable: true
            });
        }
        return element;
    };

    // Блокировка тегов script в HTML-дереве
    const observer = new MutationObserver((mutations) => {
        for (const mutation of mutations) {
            for (const node of mutation.addedNodes) {
                if (node.nodeType === 1 && node.tagName === 'SCRIPT') {
                    if (node.src && node.src.includes(TARGET_DOMAIN)) {
                        node.type = 'javascript/blocked';
                        node.remove();
                    }
                }
            }
        }
    });

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