// ==UserScript==
// @name Censor Web Pages
// @namespace http://davidjcobb.deviantart.com/
// @description Replaces profanities on web pages. NOTE: Runs after the page loads, and if profanities are added to the page after it loads (which is somewhat rare), this script won't spot them.
// @include *
// ==/UserScript==
window.profanities=[];
// Profanity syntax:
// window.profanities.push([/SWEAR WORD/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>REPLACEMENT</span>"]);
// You'd copy the above line, remove the "// " at the beginning, and replace "SWEAR WORD" with the profanity and "REPLACEMENT" with the replacement.
// Please note that if the swear phrase contains any of the following characters, you must place a backslash before them: \.$^*()+[]{}:.?/
// Similarly, if the replacement phrase contains double-quotes (") you must put a backslash before them as well (\")
// Also, replacements that you want performed first must go first. For example, if I want to replace "fuck" with "123" and "fucker" with "456",
// I'd have to replace "fucker" first, otherwise "fucker" becomes "123er"
window.profanities.push([/fucking/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>freaking</span>"]);
window.profanities.push([/fucker/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>freaker</span>"]);
window.profanities.push([/fuck/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>freak</span>"]);
window.profanities.push([/bullshit/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>bullcrap</span>"]);
window.profanities.push([/shit/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>crap</span>"]);
window.profanities.push([/cunt/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>female reproductive organ</span>"]);
window.profanities.push([/cock[\s\-]sucker/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>homosexual</span>"]);
window.profanities.push([/cock[\s\-]teaser/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>non-modest person</span>"]);
window.profanities.push([/cock[\s\-]tease/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>non-modest person</span>"]);
window.profanities.push([/cock/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>male reproductive organ</span>"]);
window.profanities.push([/dick[\s\-]sucker/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>homosexual</span>"]);
window.profanities.push([/dick[\s\-]teaser/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>non-modest person</span>"]);
window.profanities.push([/dick[\s\-]tease/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>non-modest person</span>"]);
window.profanities.push([/slut/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity\]'>non-modest person</span>"]);
window.profanities.push([/slutty/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity\]'>non-modest</span>"]);
window.profanities.push([/whore/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>prostitute</span>"]);
window.profanities.push([/dick/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>male reproductive organ</span>"]);
window.profanities.push([/knob/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>male reproductive organ</span>"]);
window.profanities.push([/prick/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>male reproductive organ</span>"]);
window.profanities.push([/twat/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>female reproductive organ</span>"]);
window.profanities.push([/pussy/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>female reproductive organ</span>"]);
window.profanities.push([/damn/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>dang</span>"]);
window.profanities.push([/bastard/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>illegitimate child</span>"]);
window.profanities.push([/bitch/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>pregnant dog</span>"]);
window.profanities.push([/tits/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>female chest area</span>"]);
window.profanities.push([/faggot/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>homosexual</span>"]);
window.profanities.push([/fag/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>homosexual</span>"]);
window.profanities.push([/queer/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>homosexual</span>"]);
window.profanities.push([/hell/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>heck</span>"]);
window.profanities.push([/ass/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>butt</span>"]);
window.profanities.push([/arsed/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>bothered</span>"]);
window.profanities.push([/arse/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>butt</span>"]);
window.profanities.push([/jizz/gi,"<span class='DJCReplacedProfanity' title='[replaced profanity]'>male reproductive fluid</span>"]);
// Don't edit anything below this line
S=document.createElement("style");
S.innerHTML=".DJCReplacedProfanity{border-bottom-style:double}";
document.body.appendChild(S);
// we have to find all text nodes
A=document.documentElement;
window.TextNodes=[];
B=function(node){
for(var i=0;i<node.childNodes.length;i++) {
if(node.childNodes[i].nodeType==3){
window.TextNodes.push(node.childNodes[i])
}else if (node.childNodes[i].childNodes&&("scriptstyleiframeframeframeset").indexOf(node.childNodes[i].tagName)==-1){
arguments.callee(node.childNodes[i]);
}
}
};
B(A);
var C;
for(i=0;i<window.TextNodes.length;i++) {
for(var P=0;P<window.profanities.length;P++) {
while(window.TextNodes[i].nodeValue&&window.TextNodes[i].nodeValue.match(window.profanities[P][0])){
window.TextNodes[i].splitText(window.TextNodes[i].nodeValue.indexOf(window.TextNodes[i].nodeValue.match(window.profanities[P][0])[0]));
window.TextNodes[i].nextSibling.nodeValue=window.TextNodes[i].nextSibling.nodeValue.substring(window.TextNodes[i].nextSibling.nodeValue.match(window.profanities[P][0])[0].length);
C=document.createElement("span");
C.innerHTML=window.profanities[P][1];
C=C.childNodes[0];
window.TextNodes[i].parentNode.insertBefore(C,window.TextNodes[i].nextSibling);
window.TextNodes.push(window.TextNodes[i].nextSibling);
}
}
}