你正在訪問的內容是外部程式的映像位址,僅用於使用者加速訪問,本站無法保證其可靠性。當前的連結位址(單點即可複製)為 https://greasyfork.org.cn/zh-CN/scripts/12228-setmutationhandler/discussions/14713,源站連結 點此以跳轉。
MutationObserver wrapper to wait for the specified CSS selector
Nvm. Finally figured out what I was doing wrong. If you follow the documentation instead of making it up as you go along, it disconnects as expected.
This script is magic
Hey @wOxxOm I've been using the 'for' loop version of this forever in lots of scripts, but I never really learned how to get the most out of it. I've left the observer connected unnecessarily in some cases, so I'm trying to figure out how to use it properly. I can get the 'forEach' loops working, but IDEK how to confirm that the observer has disconnected properly though.
What I'm trying:
// ==UserScript==// // @name Ololo // @include /https?://ololo\.to.*/ // @run-at document-start // @require https://greasyfork.org.cn/scripts/12228/code/setMutationHandler.js // ==/UserScript== const searchPage = location.href.match('^https?:\/\/ololo\.to\/s\/.*$'); const videoPage = location.href.match('^https?:\/\/ololo\.to\/video\/.*$'); setMutationHandler({ processExisting: true, // Process existing elements and watch for mutations from now on selector: '.results .item, .item-host[title="Vidcloud" i], .item-host[title="Vidlox" i], .item-host[title="Go Unlimited" i]', handler: nodes => nodes.forEach(node => { if (searchPage) { if (node.classList.contains('low-relevant')) { node.remove(); return false; } if (node.classList.contains('item-host')) { const badHostItem = node.closest('.item'); badHostItem.remove(); return false; } } }) });Not sure if
return false;should go after both 'ifs', or inside, or something else entirely. Works either way, but I have no clue if it's actually disconnecting, or if it is, if they're both completing by sheer luck. I've tried adding console logs to the disconnect conditions in the library itself, and get nothing. I can't find anything in event listeners. How can I tell if it disconnected successfully?Also, are all the options enabled by default? They all seem to work without adding any customizations, so do I even need to add
processExisting: true?