您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
MutationObserver wrapper to wait for the specified CSS selector
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyforks.org/scripts/12228/80003/setMutationHandler.js
/* EXAMPLE: setMutationHandler(document, '.container p.some-child', function(nodes) { // single node: nodes[0].remove(); // or multiple nodes: nodes.forEach(function(node) { node.style.display = 'none'; }); //this.disconnect(); // disconnect the observer, this is useful for one-time jobs return true; // continue enumerating current batch of mutations }); */ // ==UserScript== // @name setMutationHandler // @description MutationObserver wrapper to wait for the specified CSS selector // @namespace wOxxOm.scripts // @author wOxxOm // @grant none // @version 2.0.2 // ==/UserScript== function setMutationHandler(baseNode, selector, cb, options) { var ob = new MutationObserver(function(mutations) { for (var i=0, ml=mutations.length, m; (i<ml) && (m=mutations[i]); i++) switch (m.type) { case 'childList': for (var j=0, nodes=m.addedNodes, nl=nodes.length, n; (j<nl) && (n=nodes[j]); j++) if (n.nodeType == 1) if ((n = n.matches(selector) ? [n] : n.querySelectorAll(selector)) && n.length) if (!cb.call(ob, Array.prototype.slice.call(n))) return; case 'attributes': if (m.target.matches(selector) && !cb.call(ob, [m.target], m)) return; case 'characterData': if (m.target.parentNode && m.target.parentNode.matches(selector) && !cb.call(ob, [m.target.parentNode], m)) return; } }); ob.observe(baseNode, options || {subtree:true, childList:true}); return ob; }