Clout to Butt

Replaces all the occurenes de of "The cloud" with "My Butt".

目前为 2015-09-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Clout to Butt
  3. // @namespace cloud-to-butt
  4. // @include *
  5. // @description Replaces all the occurenes de of "The cloud" with "My Butt".
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10.  
  11. walk(document.body);
  12.  
  13. function walk(node)
  14. {
  15. // I stole this function from here:
  16. // http://is.gd/mwZp7E
  17. var child, next;
  18.  
  19. switch ( node.nodeType )
  20. {
  21. case 1: // Element
  22. case 9: // Document
  23. case 11: // Document fragment
  24. child = node.firstChild;
  25. while ( child )
  26. {
  27. next = child.nextSibling;
  28. walk(child);
  29. child = next;
  30. }
  31. break;
  32.  
  33. case 3: // Text node
  34. handleText(node);
  35. break;
  36. }
  37. }
  38.  
  39. function handleText(textNode)
  40. {
  41. var v = textNode.nodeValue;
  42.  
  43. v = v.replace(/\bThe Cloud\b/g, "My Butt");
  44. v = v.replace(/\bThe cloud\b/g, "My butt");
  45. v = v.replace(/\bthe Cloud\b/g, "my Butt");
  46. v = v.replace(/\bthe cloud\b/g, "my butt");
  47. textNode.nodeValue = v;
  48. }