// greasemonkey script for cleaning up GeoCache descriptions on geocaching.com
// (C) 2010 Philipp Hahn <pmhahn pmhahn de>
// Released under the GNU GENERAL PUBLIC LICENSE
// http://www.gnu.org/copyleft/gpl.html
//
// ==UserScript
// @name	geocaching
// @namespace	http://pmhahn.de/gc
// @description	Clean up GeoCaching.com descriptions
// @include	http://www.geocaching.com/seek/cdpf.aspx*
// @include	http://www.geocaching.com/seek/cache_details.aspx*
// ==//UserScript
//
// http://greasemonkey.mozdev.org/authoring.html
// http://jsfromhell.com/string/rot13

// hide elements to save space
GM_addStyle(
		'table.CacheDisclaimerTable {display:none;} ' +
		'#ctl00_ContentBody_DisclaimerText {display:none;} ' +
		'#ft {display:none;} ' +
		'#ctl00_ContentBody_EncryptionKey {display:none;} ' +
		'.TermsWidget {display:none;} '
	   );

// do rot13-decryption using JavaScript
function rot13(dummy) {
	var span = document.getElementById("ctl00_ContentBody_Hints");
	span.textContent = span.textContent.replace(/[a-zA-Z]/g, function(c){
		return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
	});
}
GM_registerMenuCommand( "Descrypt", rot13, "d", "shift", "d" );
unsafeWindow.decryptTheHint = rot13;
document.getElementById("ctl00_ContentBody_Encrypt").href = "#ctl00_ContentBody_Encrypt";
