Skip to content

Instantly share code, notes, and snippets.

@alisaifee
Created September 19, 2014 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alisaifee/046242b2d1c8648156a9 to your computer and use it in GitHub Desktop.
Save alisaifee/046242b2d1c8648156a9 to your computer and use it in GitHub Desktop.
pootify
(function switchText(node) {
var nodes = node.childNodes;
var poots = ["poot", "pooties", "pootify", "pootpoot"];
for (n in nodes) {
if (nodes[n].nodeType == 3) {
if (nodes[n].parentNode.nodeName.toLowerCase() != 'script') {
if (!/^\s+$/.test(nodes[n].value)) {
nodes[n].data = nodes[n].data.replace(/[a-zA-Z]+/g, function(w) {
if (w.match(/^(the|on|are|if|is|and|or|you|your|a|an)$/i)) return w;
return poots[Math.floor(Math.random() * poots.length)];
});
}
}
}
else {
switchText(nodes[n])
}
}
})(document.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment