R34 AgeVerif Block

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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