Created
September 19, 2014 07:52
-
-
Save alisaifee/046242b2d1c8648156a9 to your computer and use it in GitHub Desktop.
pootify
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
(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