Skip to content

Instantly share code, notes, and snippets.

@chendo
Last active December 12, 2015 03:29
Show Gist options
  • Save chendo/4707303 to your computer and use it in GitHub Desktop.
Save chendo/4707303 to your computer and use it in GitHub Desktop.
lolify.

Lolify!

Based on this image: Black Adder

Bookmarklet

Go to http://fiddle.jshell.net/Sb7rF/show/ and drag the Lolify! link from there because Github Markdown prevents bookmarklets.

Instructions:

// mostly via https://gist.github.com/2170045 but also support nodes
function htmlreplace(a, b, element) {
if (!element) element = document.body;
var nodes = element.childNodes;
for (var n=0; n<nodes.length; n++) {
if (nodes[n].nodeType == 3) {
var r = (a instanceof RegExp) ? a : new RegExp(a, 'gi');
if (nodes[n].textContent) {
nodes[n].nodeValue = nodes[n].textContent.replace(r, b);
} else {
nodes[n].nodeValue = nodes[n].nodeValue.replace(r,b);
}
} else {
htmlreplace(a, b, nodes[n]);
}
}
}
replacements = [
['candy bar', 'chocolate gobblernaught'],
['car', 'motorized rollingham'],
['firework', 'merry fizzbang'],
['pc', 'wunderbahboxes'],
['milk', 'cow juice',],
['gravy', 'meat water',],
['power cable', 'electrorope'],
['burger', 'beef wellington ensemble with lettuce'],
['pen', 'whimsy flimsy mark and scribbler'],
[/\bdoor ?knobs?\b/, 'twisting plankhandle'],
['sandwich', 'breaddystack'],
['keyboard', 'hoighty toighty tippy typers'],
['escalator', 'upsy stairsy'],
['sweater', 'knittedy wittedy sheepity sleepity'],
['cookie', 'choco chip bucky wicky'],
['sex', 'peepee friction pleasure'],
['screwdriver', 'pip pip gollywock'],
['gun', 'rooty tooty point-n-shooty'],
[/\blight ?bulbs?\b/, 'ceiling-bright'],
['ball', 'blimpy bounce'],
['snake', 'slippery dippy long mover'],
['road', 'cobble-stone-clippity-clop'],
];
for (var i=0; i<replacements.length; i++) {
console.log(replacements[i]);
htmlreplace(replacements[i][0], replacements[i][1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment