Last active
December 27, 2015 20:49
-
-
Save smcl/7387473 to your computer and use it in GitHub Desktop.
xkcd 1287 page substitution bookmarklet
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
javascript:(function(){function replaceTextInPage(oldText,newText,node){replaceTextInPage2(combo1(oldText),combo1(newText));replaceTextInPage2(combo2(oldText),combo2(newText));replaceTextInPage2(combo3(oldText),combo3(newText));}function replaceTextInPage2(oldText,newText,node){node=node||document.body;var childs=node.childNodes,i=0;while(node=childs[i]){if(node.nodeType==3){if(node.textContent){node.textContent=node.textContent.replace(oldText,newText);}else{node.nodeValue=node.nodeValue.replace(oldText,newText);}}else{replaceTextInPage2(oldText,newText,node);}i++;}}function combo1(str){return str.toLowerCase();}function combo2(str){words=str.split(" ");for(var i=words.length-1;i>=0;i--){words[i][0]=words[i][0].toUpperCase();};return words.join(" ");}function combo3(str){return str.toUpperCase();}replaceTextInPage("witnesses","these dudes I know");replaceTextInPage("allegedly","kinda probably");replaceTextInPage("new study","tumblr post");replaceTextInPage("rebuild","avenge");replaceTextInPage("space","spaaace");replaceTextInPage("google glass","virtual boy");replaceTextInPage("smartphone","pokedex");replaceTextInPage("electric","atomic");replaceTextInPage("senator","elf-lord");replaceTextInPage("Senator","Elf-lord");replaceTextInPage("car","cat");replaceTextInPage("election","eating contest");replaceTextInPage("congressional leaders","river spirits");replaceTextInPage("homeland security","homestar runner");replaceTextInPage("could not be reached for comment","is guilty and everyone knows it");})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment