You're looking at Less Wrong's discussion board. This includes all posts, including those that haven't been promoted to the front page yet. For more information, see About Less Wrong.

dbaupp comments on Reforming rot13 - Less Wrong Discussion

2 Post author: DanielVarga 04 November 2011 11:41PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (35)

You are viewing a single comment's thread. Show more comments above.

Comment author: dbaupp 05 November 2011 02:20:51AM *  2 points [-]

I agree that a bookmarklet is preferable to external applications. And in that vein, I've adapted this one so that it does in-place encoding/decoding both of normal text and text inside textboxes (like this: na rknzcyr).

javascript:function%20convert(inText){var%20outText='',t;for(i=0;i<inText.length;i++){t=inText.charCodeAt(i);if((t>64&&t<78)||(t>96&&t<110))t%20+=%2013;else%20if((t>77&&t<91)||(t>109&&t<123))t%20-=%2013;outText%20+=%20String.fromCharCode(t);}return%20outText;}var%20sel=window.getSelection().getRangeAt(0);if(sel==''){var%20act=document.activeElement;if(act.type=="textarea"){var%20start=act.selectionStart,end=act.selectionEnd;if(start!=end){var%20prefix=act.value.substring(0,start);var%20middle=convert(act.value.substring(start,end));var%20suffix=act.value.substring(end);act.value=prefix;act.value%20+=%20middle;void(act.value%20+=%20suffix);}}else{void(inText=prompt('Phrase...',''));if(inText)alert(convert(inText));}}else{out=convert(sel.toString());sel.deleteContents();var%20span=document.createElement("span");span.innerHTML=out;sel.insertNode(span);}

(I've only tested it on newer versions of Firefox and Chrome)

Comment author: see 08 November 2011 09:53:16PM 0 points [-]

Irel hfrshy!

Comment author: dbaupp 09 November 2011 05:41:54AM 1 point [-]

Thanks!

(When I saw this in my inbox, I was very very confused, until I realised its context.)