Last active
January 24, 2020 22:32
-
-
Save tomhodgins/f05ce20122a2eaed380f785ba75173fd to your computer and use it in GitHub Desktop.
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
const MO = new MutationObserver(processNodes) | |
function processNodes(entries) { | |
entries.forEach(({addedNodes}) => | |
Array.from(addedNodes) | |
.filter(node => node.matches && node.matches('div.zp-Zotpress')) | |
.forEach(node => node.textContent = node.textContent.replace('Available at:', '')) | |
) | |
} | |
// Process all nodes in document right away | |
processNodes([{addedNodes: document.querySelectorAll('*')}]) | |
// And begin watching <html> for any future nodes added | |
MO.observe(document.documentElement, {childList: true, subtree: true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment