Skip to content

Instantly share code, notes, and snippets.

@Ariarule

Ariarule/goggles.js

Created Nov 10, 2011
Embed
What would you like to do?
Safety Goggles
/////////////////////
// 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