-
-
Save zz85/95823758ddffd7a40ade to your computer and use it in GitHub Desktop.
Pootify Bookmarklet
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
// TODO Use the DOM Mutation API! | |
(function switchText(node) { | |
var nodes = node.childNodes; | |
for (var n = 0; n < nodes.length; n++) { | |
if (nodes[n].nodeName.match(/(script|style)/i)); else | |
if (nodes[n].nodeType == 3) { | |
if (!/^\s+$/.test(nodes[n].value)) { | |
nodes[n].data = nodes[n].data.replace(/[a-zA-Z]+/g, function(w) { | |
return (w.match(/^(the|on|are|if|is|and|or|you|your|a|an)$/i)) | |
? w | |
: w.length > 4 ? new Array(~~(w.length / 4)).join('poot') : 'poot'; | |
}); | |
} | |
} | |
else { | |
switchText(nodes[n]) | |
} | |
} | |
})(document.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment