Skip to content
Create a gist now

Instantly share code, notes, and snippets.

anonymous /manifest.json

"name": "XKCD Text",
"version": "0.1",
"permissions": [
"content_scripts": [
"matches": ["http://*/*"],
"js": ["xkcdfy.js"],
"run_at": "document_end"
"manifest_version": 2
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
Something went wrong with that request. Please try again.