// ==UserScript==
// @name           Experts-Exchange decode
// @namespace      http://www.wodzu.net
// @description    Decodes answers on Experts-Exchange.
// @include        http://www.experts-exchange.com/*
// ==/UserScript==
(function() { 
var prefix = "";
prefix = "Href: "; // this will be displayed in the tooltip before the alternate text
var myElements = getNodesFromXpath("//div[contains(@class,'answerBody')]");
myElements.forEach( function(element) {
  	var s = element.innerHTML;
	var res = "";
	for( var i = 0; i < s.length; i++ ){
		var c = s.charCodeAt(i);
		if( c >= 97 && c <= 122 )
			c = (c - 97 + 13)%(122 - 97 + 1 ) + 97;
		else if( c >= 65 && c <= 90 )
			c = (c - 65 + 13)%(90 - 65 + 1 ) + 65;
		res += String.fromCharCode(c);
	}
	element.innerHTML = res;
}
);

addGlobalStyle('.blur { display: none !important; }');

function getNodesFromXpath(xpath) {
	var rs = document.evaluate(xpath,document,null,5,null);
	var nodes = [];
	var currentNode = rs.iterateNext();
	while(currentNode) {
		nodes.push(currentNode);
		currentNode = rs.iterateNext();
	}
	return nodes;
}

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}




})();
