-
Notifications
You must be signed in to change notification settings - Fork 1
/
content.js
29 lines (26 loc) · 929 Bytes
/
content.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
chrome.storage.local.get(null, function(data) {
if(!(data["compassionomaticDisabled"] == true)) {
if(data["compassionomaticShowMarker"] == true) {
var marker = '*';
}
else {
var marker = '';
}
var elements = document.getElementsByTagName('*');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
for (var j = 0; j < element.childNodes.length; j++) {
var node = element.childNodes[j];
if (node.nodeType === 3) {
var text = node.nodeValue;
var replacedText = text.replace(/\bmigrant/g, marker + 'refugee').
replace(/\bMigrant/g, marker + 'Refugee').
replace(/\bMIGRANT/g, marker + 'REFUGEE');
if (replacedText !== text) {
element.replaceChild(document.createTextNode(replacedText), node);
}
}
}
}
}
});