Skip to content

Instantly share code, notes, and snippets.

@iboss-ptk
Last active August 18, 2019 01:08
Show Gist options
  • Select an option

  • Save iboss-ptk/c84227b2dc3d4f2ec67f5d5242c57a1c to your computer and use it in GitHub Desktop.

Select an option

Save iboss-ptk/c84227b2dc3d4f2ec67f5d5242c57a1c to your computer and use it in GitHub Desktop.
const censor = text => {
const iter = document
.evaluate(`//*[contains(text(),'${text}')]`, document, null, XPathResult.ANY_TYPE, null)
let el = iter.iterateNext()
while(el) {
el.style = "color: transparent; text-shadow: 0 0 5px rgba(0,0,0,0.5);"
try { el = iter.iterateNext() } catch (_) { break }
}
}
const observer = new MutationObserver(() => censor('text_to_censor'))
observer.observe(document.body, { childList: true })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment