Advertisement
teknoraver

Clown Computing

Sep 23rd, 2014
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function handleText(textNode)
  2. {
  3.     textNode.nodeValue = textNode.nodeValue
  4.  
  5.     .replace(/Cloud/g, "Clown")
  6.     .replace(/cloud/g, "clown")
  7.     .replace(/CLOUD/g, "CLOWN")
  8.  
  9.     ;
  10. }
  11.  
  12. function walk(node)
  13. {
  14.     // thanks to: http://is.gd/mwZp7E
  15.     switch (node.nodeType) {
  16.         case  1: // Node.ELEMENT_NODE
  17.         case  9: // Node.DOCUMENT_NODE
  18.         case 11: // Node.DOCUMENT_FRAGMENT_NODE
  19.             var child = node.firstChild;
  20.             while (child) {
  21.                 var next = child.nextSibling;
  22.                 walk(child);
  23.                 child = next;
  24.             }
  25.             break;
  26.  
  27.         case  3: // Node.TEXT_NODE
  28.             handleText(node);
  29.             break;
  30.     }
  31. }
  32.  
  33. walk(document.body);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement