public
anonymous / manifest.json
Created

  • Download Gist
manifest.json
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{
"name": "XKCD Text",
"version": "0.1",
"permissions": [
"http://*/*"
],
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["xkcdfy.js"],
"run_at": "document_end"
}
],
"manifest_version": 2
}
xkcdfy.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.