Skip to content

Instantly share code, notes, and snippets.

@Darker
Created October 25, 2019 12:59
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 Darker/73817f6e5865afc0f661b85a7ed95b21 to your computer and use it in GitHub Desktop.
Save Darker/73817f6e5865afc0f661b85a7ed95b21 to your computer and use it in GitHub Desktop.
function changeText(originalText) {
return "💩";
}
// Najde všechny texty v dokumentu
var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, null);
// Sem budeme dávat nalezený texty
var node = null;
// dokud walker.nextNode() vrací text a ne null
while(node = walker.nextNode()) {
// "text node" má "data", to je text co je pak vidět v browseru
node.data = changeText(node.data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment