Coincidence Detector

Detects coincidences.

  1. // ==UserScript==
  2. // @name Coincidence Detector
  3. // @description Detects coincidences.
  4. // @include *
  5. // @grant GM_getResourceText
  6. // @resource theList https://coincidencedetector.com/theList.json
  7. // @homepageURL https://coincidencedetector.com/
  8. // @version 14.88.1
  9. // @namespace https://coincidencedetector.com/
  10. // ==/UserScript==
  11.  
  12.  
  13. (function(){
  14. var theList = JSON.parse(GM_getResourceText("theList"));
  15. var regexp = new RegExp('\\b(' + theList.join('|') + ')\\b(?!\\)\\))', "gi");
  16.  
  17. function walk(node) {
  18. // I stole this function from here:
  19. // http://is.gd/mwZp7E
  20.  
  21. var child, next;
  22.  
  23. switch ( node.nodeType )
  24. {
  25. case 1:
  26. case 9:
  27. case 11:
  28. child = node.firstChild;
  29. while ( child )
  30. {
  31. next = child.nextSibling;
  32. walk(child);
  33. child = next;
  34. }
  35. break;
  36.  
  37. case 3:
  38. handleText(node);
  39. break;
  40. }
  41. }
  42.  
  43. function handleText(textNode) {
  44. textNode.nodeValue = textNode.nodeValue.replace(regexp, '((($1)))');
  45. textNode.nodeValue = textNode.nodeValue.replace(/\bIsrael\b/, '(((Our Greatest Ally)))');
  46. }
  47.  
  48. walk(document.body);
  49. })();