forked from ebarry/cloud-to-butt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
content_script.js
50 lines (41 loc) · 1.17 KB
/
content_script.js
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
walk(document.body);
function walk(node)
{
// I stole this function from here:
// http://is.gd/mwZp7E
var child, next;
switch ( node.nodeType )
{
case 1: // Element
case 9: // Document
case 11: // Document fragment
child = node.firstChild;
while ( child )
{
next = child.nextSibling;
if (node.nodeName != "TEXTAREA" && node.nodeName != "INPUT") walk(child);
child = next;
}
break;
case 3: // Text node
handleText(node);
break;
}
}
function handleText(textNode)
{
var v = textNode.nodeValue;
v = v.replace(/\bscientist\b/g, '"scientist"');
v = v.replace(/\bScientist\b/g, '"Scientist"');
v = v.replace(/\bscientists\b/g, '"scientists"');
v = v.replace(/\bScientists\b/g, '"Scientists"');
v = v.replace(/\bexpert\b/g, '"expert"');
v = v.replace(/\bExpert\b/g, '"Expert"');
v = v.replace(/\bexperts\b/g, '"experts"');
v = v.replace(/\bExperts\b/g, '"Experts"');
v = v.replace(/\bprofessional\b/g, '"professional"');
v = v.replace(/\bProfessional\b/g, '"Professional"');
v = v.replace(/\bprofessionals\b/g, '"professionals"');
v = v.replace(/\bProfessionals\b/g, '"Professionals"');
textNode.nodeValue = v;
}