Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 16th, 2013  |  syntax: None  |  size: 0.57 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // ==UserScript==
  2. // @match http://*/*
  3. // @match https://*/*
  4. // ==/UserScript==
  5.  
  6. var startTime = new Date().getTime();
  7.  
  8. var walker = document.createTreeWalker(
  9.   document.body,
  10.   NodeFilter.SHOW_TEXT,
  11.   null,
  12.   false
  13. );
  14.  
  15. var node;
  16. var replaced = 0;
  17.  
  18. while(node = walker.nextNode()) {
  19.   if (node.nodeValue.toLowerCase().indexOf('whilst') > -1) {
  20.     node.nodeValue = node.nodeValue.replace(/(whil)st/gi, '$1e');
  21.     replaced++;
  22.   }
  23. }
  24.  
  25. var elapsed = new Date().getTime() - startTime;
  26. console.log('replaced ' + replaced + ' whilst(s) in ' + elapsed + 'ms');
clone this paste RAW Paste Data