Skip to content

Instantly share code, notes, and snippets.

@headquarters
Created April 1, 2013 15:52
Show Gist options
  • Save headquarters/5285731 to your computer and use it in GitHub Desktop.
Save headquarters/5285731 to your computer and use it in GitHub Desktop.
Happy April Fool's Day! If you'd like to translate all the ROT13 encrypted articles on Slashdot's homepage today, just run this gist through your browser's console.
var alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var rot13 = function(letter){
var l = letter.toLowerCase();
var index = alphabet.indexOf(l);
var newIndex = (index + 13) % alphabet.length;
return alphabet[newIndex];
};
$('.body .p i').each(function(){
var letters = $(this).text().split("");
var translation = "";
for(var i=0; i < letters.length; i++){
if(/[a-zA-Z]/.test(letters[i])){
translation += rot13(letters[i]);
} else {
translation += letters[i];
}
}
$(this).replaceWith(translation);
});
@dergachev
Copy link

I just wrote something very similar, and made a bookmarklet out of it:

http://bl.ocks.org/dergachev/5285534

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment