|
Translate |
Print |
A |
A |
A |
to
Convert
// ==UserScript==
// @name Harry Potter Spoiler Killer
// @namespace none
// @description No Deathly Hallows spoilers!
// @include *
/*
Based on Jmaxxz Vulgar Word Blocker, which in turn was
based on a script in Mark Pilgram's upcoming "Dive into Greasemonkey"
The Jmaxxz Vulgar Word Blocker can be found at: http://userscripts.org/scripts/show/2287
You need the Greasemonkey Firefox extension to use this script.
This script is not perfect!
I didn't include every single Harry Potter word, and it doesn't include misspellings.
If you think of a new one, add it to your script! Also, if your computer is slow or
bogged down, it might take a second for the script to replace the words, so you might
see the page before it has been censored. It also filters out parts of words... but
I think that's a small price to pay to avoid spoilers until Saturday.
Do whatever you want with this script.
*/
// ==/UserScript==
(function() {
var bad = [], good = [], modifiers = [];
populate({
"aberforth" : "???",
"alastor" : "???",
"albus" : "???",
"alley" : "???",
"andromeda" : "???",
"animagus" : "???",
"arabella" : "???",
"argus" : "???",
"arthur" : "???",
"aunt" : "???",
"avada" : "???",
"azkaban" : "???",
"bagman" : "???",
"barty" : "???",
"basilisk" : "???",
"battle" : "???",
"bellatrix" : "???",
"bill" : "???",
"black" : "???",
"boggart" : "???",
"buckbeak" : "???",
"cast" : "???",
"cedric" : "???",
"chang" : "???",
"charlie" : "???",
"charm" : "???",
"cho" : "???",
"colin" : "???",
"cornelius" : "???",
"cousin" : "???",
"crabbe" : "???",
"creevey" : "???",
"crookshanks" : "???",
"crouch" : "???",
"cruciatus" : "???",
"crucio" : "???",
"curse" : "???",
"dark" : "???",
"death" : "???",
"deathly" : "???",
"delacour" : "???",
"dementor" : "???",
"dennis" : "???",
"diagon" : "???",
"die" : "???",
"diggory" : "???",
"dobby" : "???",
"draco" : "???",
"dudley" : "???",
"duel" : "???",
"dumbledore" : "???",
"dursley" : "???",
"dying" : "???",
"eater" : "???",
"eileen" : "???",
"elf" : "???",
"evans" : "???",
"family" : "???",
"father" : "???",
"fawkes" : "???",
"felicis" : "???",
"felix" : "???",
"figg" : "???",
"fight" : "???",
"filtch" : "???",
"firenze" : "???",
"fleur" : "???",
"fred" : "???",
"fudge" : "???",
"gabrielle" : "???",
"george" : "???",
"ghost" : "???",
"gilderoy" : "???",
"ginny" : "???",
"goblin" : "???",
"godric" : "???",
"goyle" : "???",
"granger" : "???",
"grawp" : "???",
"gregory" : "???",
"grimmauld" : "???",
"gryffindor" : "???",
"haggrid" : "???",
"hagrid" : "???",
"hallows" : "???",
"harry" : "???",
"hedwig" : "???",
"helga" : "???",
"herminie" : "???",
"hermione" : "???",
"hermoine" : "???",
"hogsmeade" : "???",
"hogwarts" : "???",
"horace" : "???",
"horcrux" : "???",
"house elf" : "???",
"house elves" : "???",
"hufflepuff" : "???",
"imperius" : "???",
"james" : "???",
"kedavra" : "???",
"kill" : "???",
"kills" : "???",
"kingsley" : "???",
"kneazle" : "???",
"kreacher" : "???",
"legilimency" : "???",
"lestrange" : "???",
"leviosa" : "???",
"lily" : "???",
"live" : "???",
"lives" : "???",
"lockhart" : "???",
"longbottom" : "???",
"lord" : "???",
"lose" : "???",
"lost" : "???",
"lovegood" : "???",
"lucius" : "???",
"ludovic" : "???",
"luna" : "???",
"lupin" : "???",
"magic" : "???",
"malfoy" : "???",
"marjorie" : "???",
"mask" : "???",
"mcgonagall" : "???",
"merope" : "???",
"minerva" : "???",
"ministry" : "???",
"moaning" : "???",
"molly" : "???",
"moody" : "???",
"mother" : "???",
"mouth" : "???",
"muggle" : "???",
"myrtle" : "???",
"nagini" : "???",
"narcissa" : "???",
"neville" : "???",
"nigellus" : "???",
"nymphadora" : "???",
"occlumency" : "???",
"order" : "???",
"pansy" : "???",
"parent" : "???",
"parkinson" : "???",
"parsel" : "???",
"patronus" : "???",
"peeves" : "???",
"pensieve" : "???",
"percy" : "???",
"peter" : "???",
"pettigrew" : "???",
"petunia" : "???",
"phineas" : "???",
"phoenix" : "???",
"pigwidgeon" : "???",
"potter" : "???",
"prefect" : "???",
"prince" : "???",
"privet" : "???",
"professor" : "???",
"prophecy" : "???",
"quidditch" : "???",
"ravenclaw" : "???",
"regulus" : "???",
"remus" : "???",
"riddle" : "???",
"ron" : "???",
"rowena" : "???",
"rubeus" : "???",
"rufus" : "???",
"salazar" : "???",
"school" : "???",
"scrimgeour" : "???",
"seamus" : "???",
"seeker" : "???",
"severus" : "???",
"shacklebolt" : "???",
"shield" : "???",
"sirius" : "???",
"slughorn" : "???",
"slytherin" : "???",
"snake" : "???",
"snape" : "???",
"sorceror" : "???",
"spell" : "???",
"squib" : "???",
"thestral" : "???",
"tobias" : "???",
"tom" : "???",
"tongue" : "???",
"tonks" : "???",
"trelawney" : "???",
"troll" : "???",
"uncle" : "???",
"unforgiveable" : "???",
"unforgiveable" : "???",
"vernon" : "???",
"vincent" : "???",
"voldemort" : "???",
"voldermort" : "???",
"walburga" : "???",
"wand" : "???",
"weasley" : "???",
"werewolf" : "???",
"werewolves" : "???",
"win" : "???",
"witch" : "???",
"witchcraft" : "???",
"wizard" : "???",
}, "gi");
function populate(replacements, flags) {
var word, modPos, mod;
for(var key in replacements)
{
if((modPos = key.indexOf("/")) > -1)
{
mod = key.substring(modPos + 1);
word = key.substring(0, modPos);
}
else
{
mod = "";
word = key;
}
modifiers.push(mod);
bad.push(new RegExp(word, flags));
good.push(replacements[key]);
}
}
// this function does the replacements
function sanitize(s, noContext, notredirect) {
for (var j = 0; j < bad.length; j++) {
if(noContext && modifiers[j].indexOf("c") != -1 || notredirect && modifiers[j].indexOf("r") !=-1 ) {
continue;
}
s = s.replace(bad[j], good[j]);
}
return s;
}
// replace in title
if(document.title) document.title = sanitize(document.title, false , true);
// replace in body text
var textnodes = document.evaluate( "//body//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < textnodes.snapshotLength; i++) {
node = textnodes.snapshotItem(i);
node.data = sanitize(node.data, false, true);
}
})();
|