Created
November 9, 2013 18:02
-
-
Save anonymous/7388059 to your computer and use it in GitHub Desktop.
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
{ | |
"name": "XKCD Text", | |
"version": "0.1", | |
"permissions": [ | |
"http://*/*" | |
], | |
"content_scripts": [ | |
{ | |
"matches": ["http://*/*"], | |
"js": ["xkcdfy.js"], | |
"run_at": "document_end" | |
} | |
], | |
"manifest_version": 2 | |
} |
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
String.prototype.replaceWithCase=function(subStr, newStr) { | |
return this.replace( new RegExp(subStr, 'ig'), function(found) { | |
return /[A-Z]/.test(found.charAt(0))?( newStr.charAt(0).toUpperCase() + newStr.substring(1) ) : newStr.toLowerCase(); | |
}); | |
} | |
var replacements = [["witnesses", "these dudes I know"], | |
["allegedly", "kinda probably"], | |
["new study", "tumbler post"], | |
["rebuild", "avenge"], | |
["space", "spaaace"], | |
["google glass", "virtual boy"], | |
["smartphone", "pokedex"], | |
["electric", "atomic"], | |
["senator", "elf-lord"], | |
["car", "cat"], | |
["election", "eating contest"], | |
["congressional leaders", "river spirits"], | |
["homeland security", "homestar runner"], | |
["could not be reached for comment", "is guilty and everyone knows it"]]; | |
function replaceAll (text) { | |
var result = text; | |
for (r in replacements) { | |
var pair = replacements[r]; | |
result = result.replaceWithCase(pair[0], pair[1]); | |
} | |
return result; | |
} | |
document.body.innerHTML = replaceAll(document.body.innerHTML); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment