Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Last active January 24, 2020 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhodgins/f05ce20122a2eaed380f785ba75173fd to your computer and use it in GitHub Desktop.
Save tomhodgins/f05ce20122a2eaed380f785ba75173fd to your computer and use it in GitHub Desktop.
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