Created
November 10, 2011 21:13
-
-
Save Ariarule/1356249 to your computer and use it in GitHub Desktop.
Safety Goggles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////// | |
// SafetyGoggles | |
// @name SafetyGoggles | |
// @version 0.1.10082010 | |
// @description Highlighlights Weasel Words in Text. Just a proof of concept version. | |
// @include http://* | |
// THIS VERSION IS SLOW AND SOMETIMES BREAKS LINKS -- Still needs work | |
var docbod; | |
docbod = document.body; | |
function recursively_change_text_of_children(node) { | |
terminalnode = node.childNodes.length; | |
if (terminalnode === 1) { | |
if (typeof(node.innerHTML) != 'string') { | |
return false; | |
} | |
wordlist = ["legendary", | |
"great", | |
"leading", | |
"famous", | |
"cult", | |
"extremist", | |
"denialist", | |
"pseudo", | |
"some", | |
"many", | |
"most", | |
"experts", | |
"often", | |
"widely", | |
"science", | |
"supposed", | |
"purported", | |
"alleged", | |
"accused", | |
"so-called", | |
"clearly", | |
"fnord"]; | |
var number_of_words = wordlist.length; | |
for (i = 0;i < number_of_words;i++) { | |
node.innerHTML = node.innerHTML.replace(new RegExp("(" + wordlist[i] + ")","gi"),"<span class='e11a6f39580ed84623de5da732bc9a02_goggles' style='background: yellow; font-weight: bolder; border-bottom: double red 3px;'>$1</span>"); | |
} | |
} | |
else { | |
for (i in node.children) { | |
recursively_change_text_of_children(node.children[i]); | |
} | |
} | |
} | |
recursively_change_text_of_children(docbod); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment