Greasy Fork

Shined up real nice.

Coincidence Detector

Detects coincidences.

After trying this script, you can ask a question about it, review it, or report it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// ==UserScript==
// @name          Coincidence Detector
// @description   Detects coincidences.
// @include       *
// @grant         GM_getResourceText
// @resource      theList https://coincidencedetector.com/theList.json
// @homepageURL   https://coincidencedetector.com/
// @version       14.88.1
// @namespace     https://coincidencedetector.com/
// ==/UserScript==


(function(){
var theList = JSON.parse(GM_getResourceText("theList"));
var regexp = new RegExp('\\b(' + theList.join('|') + ')\\b(?!\\)\\))', "gi");

function walk(node) {
	// I stole this function from here:
	// http://is.gd/mwZp7E

	var child, next;

	switch ( node.nodeType )
	{
		case 1:
		case 9:
		case 11:
			child = node.firstChild;
			while ( child )
			{
				next = child.nextSibling;
				walk(child);
				child = next;
			}
			break;

		case 3:
			handleText(node);
			break;
	}
}

function handleText(textNode) {
	textNode.nodeValue = textNode.nodeValue.replace(regexp, '((($1)))');
	textNode.nodeValue = textNode.nodeValue.replace(/\bIsrael\b/, '(((Our Greatest Ally)))');
}

walk(document.body);
})();