Skip to content

Instantly share code, notes, and snippets.

@zz85
Forked from alisaifee/pootify.js
Last active August 29, 2015 14:06
Show Gist options
  • Save zz85/95823758ddffd7a40ade to your computer and use it in GitHub Desktop.
Save zz85/95823758ddffd7a40ade to your computer and use it in GitHub Desktop.
Pootify Bookmarklet
// 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