Skip to content

Instantly share code, notes, and snippets.

@kalisjoshua
Created October 9, 2013 21:03
Show Gist options
  • Save kalisjoshua/6908341 to your computer and use it in GitHub Desktop.
Save kalisjoshua/6908341 to your computer and use it in GitHub Desktop.
Piratize Plugin - make the headers of a website more Pirate-like.
(function piratize () {
$('h1, h2, h3, h4, h5, h6')
.each(function (_, el) {
el.innerHTML = el.innerHTML
.split(' ')
.reduceRight(function (acc, word) {
if (!acc[1] && /r/.test(word)) {
word = word.replace(/(.*)(r+)/i, '$1$2rrrr');;
acc[1] = true;
}
acc[0] = word + ' ' + acc[0];
return acc;
}, ['', false])
.shift();
});
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment