Created
April 1, 2013 15:52
-
-
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.
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
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); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just wrote something very similar, and made a bookmarklet out of it:
http://bl.ocks.org/dergachev/5285534