-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxkcd-substitutions.user.js
More file actions
108 lines (103 loc) · 3.76 KB
/
xkcd-substitutions.user.js
File metadata and controls
108 lines (103 loc) · 3.76 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// ==UserScript==
// @name xkcd-substitutions
// @namespace istepaniuk.com
// @description SUBSTITUTIONS That make reading the news more fun. (http://xkcd.com/1288/ & https://xkcd.com/1625/ & http://xkcd.com/1679/)
// @include http://www.bbc.co.uk/*
// @include http://www.bbc.com/*
// @include http://www.cbc.ca/*
// @include http://www.theguardian.com/*
// @include http://www.telegraph.co.uk/*
// @include http://www.theonion.com/*
// @include http://www.foxnews.com/*
// @include https://www.reddit.com/*
// @include https://www.washingtonpost.com/*
// @version 2
// @grant none
// ==/UserScript==
(function() {
var substitutions,
textNodes,
regexps = {};
substitutions = {
"allegedly": "kinda probably",
"ancient": "haunted",
"anti-terror": "freedom",
"an unknown number": "like hundreds",
"at large": "very large",
"behind the headlines": "beyond the grave",
"candidate": "airbender",
"car": "cat",
"cautiously optimistic": "delusional",
"congressional leaders": "river spirits",
"could not be reached for comment": "is guilty and everyone knows it",
"debate": "dance-off",
"disrupt": "destroy",
"doctor who": "the big bang theory",
"drone": "dog",
"election": "eating contest",
"electric": "atomic",
"email": "poem",
"expands": "physically expands",
"facebook ceo": "this guy",
"facebook post": "poem",
"first-degree": "friggin' awful",
"front runner": "blade runner",
"gaffe": "magic spell",
"global": "spherical",
"google glass": "Virtual Boy",
"guerrilla": "gorilla",
"homeland security": "homestar runner",
"horsepower": "tons of horsemeat",
"killed": "smashed to bits",
"latest": "final",
"meeting": "channing tatum and his friends",
"meeting": "ménage à trois",
"migrant": "slave",
"minutes": "years",
"new study": "Tumblr post",
"no indication": "lots of signs",
"poll": "psychic reading",
"rebuild": "avenge",
"refugee": "rapist pig",
"remains to be seen": "will never be known",
"scientists": "channing tatum and his friends",
"second-degree": "friggin' awful",
"self driving": "uncontrollably swerving",
"senator": "elf-lord",
"silver bullet": "way to kill werewolves",
"smartphone": "Pokédex",
"space": "spaaace",
"star-studded": "blood-soaked",
"subway system": "tunnels I found",
"successfully": "suddenly",
"surprising": "surprising (but not to me)",
"tension": "sexual tension",
"terror": "freedom",
"terrorism": "freedom",
"terrorist": "clown",
"third-degree": "friggin' awful",
"tweet": "poem",
"urged restraint by": "drunkenly egged on",
"verify": "lie about",
"vows to": "probably won't",
"war of words": "interplanetary war",
"win votes": "find pokemon",
"witnesses": "these dudes I know",
"years": "minutes",
"you won't believe": "I'm really sad about"
}
for (var key in substitutions) {
regexps[key] = new RegExp(key, 'gi');
}
textNodes = document.evaluate("//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < textNodes.snapshotLength; i++) {
var node = textNodes.snapshotItem(i);
node.data = substituteTextIn(node.data);
}
function substituteTextIn(text) {
for (var key in substitutions) {
text = text.replace(regexps[key], substitutions[key]);
}
return text;
}
})();