// ==UserScript==
// @name          Descramble experts-exchange.com
// @namespace     http://enlavin.com/jquery/greasemonkey
// @description	  bla bla
// @author        Enlavin
// @homepage      http://enlavin.com/jquery/greasemonkey
// @include       http://www.experts-exchange.com/*
// ==/UserScript==


// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://code.jquery.com/jquery-latest.pack.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);

// Check if jQuery's loaded
function GM_wait() {
	if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
	else { $ = unsafeWindow.jQuery; letsJQuery(); }
}
GM_wait();

var rot13map;

function rot13init() {
    var map = new Array();
    var s   = "abcdefghijklmnopqrstuvwxyz";
    for (i=0; i<s.length; i++)
        map[s.charAt(i)] = s.charAt((i+13)%26);
    for (i=0; i<s.length; i++)
        map[s.charAt(i).toUpperCase()]	= s.charAt((i+13)%26).toUpperCase();
    return map;
}

function rot13(a) {
    if (!rot13map)
        rot13map=rot13init();
    s = "";
    var in_tag = false;
    var in_ent = false;
    for (i=0; i<a.length; i++) {
        var b = a.charAt(i);
        if ( !in_tag && b == '<' ) {
            in_tag = true;
        } 
        else if ( in_tag && b == '>' ) {
            in_tag = false;
        }
        else if ( !in_ent && b == '&' ) {
            in_ent = true;
        } 
        else if ( in_ent && b == ';' ) {
            in_ent = false;
        }

        if ( !in_tag && !in_ent )
            s += (b>='A' && b<='Z' || b>='a' && b<='z' ? rot13map[b] : b);
        else
            s += b;
    }
    return s;
}

// All your GM code must be inside this function
function letsJQuery() {
    $("div.infoBody").each(function(i){
        var children = $(this).children(".signUpSpace");
        if ( children.length > 0 ) {
            $(this).children(".answerBody").each(function(o) {
                var s = $(this).html();
                s = rot13(s);
                $(this).html(s);
            });
            $(this).children(".blur").remove();
            children.remove();            
        }
    });
}



