Difference between revisions of "User:Nic Smith/Safety Goggles"

From Lesswrongwiki
Jump to: navigation, search
(Start page for further reference)
 
(Moving to Gist)
 
Line 1: Line 1:
<pre>
+
Moved to https://gist.github.com/1356249
/////////////////////
 
// 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);
 
</pre>
 

Latest revision as of 07:14, 11 November 2011