Last active
June 2, 2022 18:19
-
-
Save retrohacker/1ea32a6f405c2368992574ee69ffc202 to your computer and use it in GitHub Desktop.
Handling dynamic content with greasemonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Apply rules to dynamically loaded content | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
// Create a new mutation observer | |
const observer = new window.MutationObserver(() => { | |
// Apply your rules here | |
// Example: hide tweet stats on twitter | |
document.querySelectorAll('div[data-testid="reply"]') | |
.forEach(v => v.parentElement.parentElement.style["display"] = "none"); | |
}); | |
observer.observe(document, { subtree: true, childList: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment