Greasy Fork

Remover

Removes Nodes

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.icu/scripts/21713/138250/Remover.js

// ==UserScript==
// @name        Remover
// @namespace   MegaByteRem
// @description Removes Nodes
// @run-at      document-end
// @include     *
// @version     1
// @grant       none
// ==/UserScript==


    Element.prototype.remove = function() {
        this.parentElement.removeChild(this);
    }
    NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
        for(var i = this.length - 1; i >= 0; i--) {
            if(this[i] && this[i].parentElement) {
                this[i].parentElement.removeChild(this[i]);
            }
        }
    }
    
    function remove(selector) {
        document.querySelectorAll(selector).remove();
    }