消除js Remove JS Button

在当前页添加一个删除指定的html标签的按钮,点击后会自动删除JS。

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         消除js Remove JS Button
// @namespace    消除js Remove JS Button
// @license      yagizaMJ
// @version      1.1.1
// @description  在当前页添加一个删除指定的html标签的按钮,点击后会自动删除JS。
// @AuThor       yagizaMJ
// @match        *://*/*
// @grant        none
// ==/UserScript==
 
(function() {
    'use strict';
 
    function removeTags(tagNames) {
        tagNames.forEach(function(tagName) {
            // 获取所有指定标签
            var elements = document.querySelectorAll(tagName);
 
            // 遍历所有的指定标签并移除它们
            elements.forEach(function(element) {
                element.parentNode.removeChild(element);
            });
        });
    }
 
    // 创建按钮元素
    var removeButton = document.createElement('button');
    removeButton.textContent = 'Remove JS';
    removeButton.style.position = 'fixed';
    removeButton.style.top = '250px';
    removeButton.style.right = '20px';
    removeButton.style.zIndex = '9999';
 
    // 将按钮添加到页面上
    document.body.appendChild(removeButton);
 
    // 添加按钮点击事件
    removeButton.addEventListener('click', function() {
        // 调用函数删除 <a> 和 <h1> 标签
        removeTags(['link', 'script']);
 
        // 移除按钮自身
        removeButton.parentNode.removeChild(removeButton);
    });
 
    // 隐藏按钮的右键菜单
    removeButton.addEventListener('contextmenu', function(event) {
        event.preventDefault();
        removeButton.style.display = 'none';
    });
 
    // 当文档双击时,恢复按钮
    document.addEventListener('dblclick', function() {
        removeButton.style.display = 'block';
    });
})();