阻止js脚本运行

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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