Skip to content

Instantly share code, notes, and snippets.

@martinvirtel
Created May 17, 2016 06:53
Show Gist options
  • Save martinvirtel/54746a9b1cfd0e98bb33c8789e6245c1 to your computer and use it in GitHub Desktop.
Save martinvirtel/54746a9b1cfd0e98bb33c8789e6245c1 to your computer and use it in GitHub Desktop.
Wikimedia against capital D
/* http://stackoverflow.com/questions/10730309/find-all-text-nodes-in-html-page */
function textNodesUnder(el){
var n, a=[], walk=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false);
while(n=walk.nextNode()) a.push(n);
return a;
}
f=textNodesUnder(document);
f.forEach(function(e,i) { a=e.textContent; b=a.replace(/\bDpa/g,"dpa"); e.textContent=b; })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment