阻止js脚本运行

这个脚本用于阻止指定的 JavaScript 文件在特定网站上运行。

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         阻止js脚本运行
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  这个脚本用于阻止指定的 JavaScript 文件在特定网站上运行。
// @author       veip007
// @match        *://*.sexinsex.net/*
// @match        *://*.91porn.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // 要阻止的JS文件列表
    const blockedScripts = ['indexonly.js', 'myjavascriptajax.js', 'adblock.js'];

    // 拦截并阻止特定的JS文件
    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        for (let script of blockedScripts) {
            if (url.includes(script)) {
                console.log('Blocked:', url);
                return;
            }
        }
        originalOpen.apply(this, arguments);
    };

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            mutation.addedNodes.forEach((node) => {
                if (node.tagName === 'SCRIPT') {
                    blockedScripts.forEach((script) => {
                        if (node.src.includes(script)) {
                            node.parentNode.removeChild(node);
                            console.log('Blocked:', node.src);
                        }
                    });
                }
            });
        });
    });

    observer.observe(document.head, { childList: true, subtree: true });
    observer.observe(document.body, { childList: true, subtree: true });
})();