Skip to content

Instantly share code, notes, and snippets.

@canalun
Last active April 30, 2024 13:19
Show Gist options
  • Save canalun/64ba801617a17700ee18667c7a967c15 to your computer and use it in GitHub Desktop.
Save canalun/64ba801617a17700ee18667c7a967c15 to your computer and use it in GitHub Desktop.
replace texts on web page
;(function overwriteTextNodes(root, yourText) {
const extendedChildNode = (node) =>
node.firstChild || node.shadowRoot || node.contentDocument
for (let node = extendedChildNode(root); node; node = node.nextSibling) {
node.nodeType === 3 && (node.nodeValue = yourText)
overwriteTextNodes(node, yourText)
}
})(document.body, "👶")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment