nicolaitan / MostrarNGCYNPC

// ==UserScript==
// @name         MostrarNGCYNPC
// @version      6.0.7.2
// @description  MostrarNGC
// @author       Robert// @include       http*.ogame.gameforge.com/game/index.php?page=messages*
// @grant          GM_getValue
// @grant          GM_setValue
// @grant          GM_xmlhttpRequest
// ==/UserScript==

var injectShowRe = (function() {


		// Global Scope
		var showReControl, showReCmd, maxWait = 25;
		
		// Helper function for select the report
		function SelectRe(element) {
		  var text = document.getElementById(element);    
		  if (document.body.createTextRange) {
		    range = document.body.createTextRange();
		    range.moveToElementText(text);
		    range.select();
		  } else if (window.getSelection) {
		    selection = window.getSelection();        
		    range = document.createRange();
		    range.selectNodeContents(text);
		    selection.removeAllRanges();
		    selection.addRange(range);
		  }
		}
		
		// Global call to start the survey, bound on tabs and load
		function launchMonitor() {
			showReControl = 0;
			showReCmd = setInterval(showRe,200);
		}
		
		// Fire the display if monitor loop comes after load or reload
		function showRe()
		{
			if(showReControl<=maxWait)
		  {
		  	
		  	if($('.msg').length>0 && $('.msg').length>$('.showRePlaceHolder').length) {
		  		
		  		$('ul.subtabs a, ul.tabs_btn a, .paginator').bind('click', function() { launchMonitor(); });
			
			  	showReControl = maxWait;
			  		
			  	$.each($('.msg'), function(index ,value ) {
			  	    if($(value).find('.resspan').length>0) {
			  	    if($(value).find('.msg_content font').html()) {
			    			$(value).find('.msg_title').html($(value).find('.msg_title').html()+' <font color="#ff0000">'+$(value).find('.msg_content font').html()+'</font>');
			    		}
			    		$(value).find('.msg_content br').remove(); // Condensed
			    		$(value).find('.msg_content .ctn4:eq(1)').remove(); // Activity
							$(value).find('.msg_content .compacting:eq(0) a').remove(); // Second Coords
			    		$(value).find('.msg_content .compacting:eq(1)').html('<br>'+$(value).find('.msg_content .compacting:eq(1) span').attr('title').replace(/<br\/>/g,' | ')); // Transpo
			    		$(value).find('.msg_sender').append(' ('+$(value).find('.msg_content .compacting:eq(2) span.fright').html()+')'); 
			    		$(value).find('.msg_content .compacting:eq(2)').remove(); // Probability Spy Detection
			    		$(value).find('.msg_content .compacting:eq(1)').append('<br>'+$(value).find('.msg_content .compacting:eq(2) span:eq(0)').html()+' [<span class="showReFleetSum">'+$(value).find('.msg_content .compacting:eq(2) span:eq(0)').attr('title')+'</span>]');
			    		$(value).find('.msg_content .compacting:eq(1)').append('<br>'+$(value).find('.msg_content .compacting:eq(2) span:eq(1)').html()+' [<span class="showReDefSum">'+$(value).find('.msg_content .compacting:eq(2) span:eq(1)').attr('title')+'</span>]');
			    		$(value).find('.msg_content .compacting:eq(2)').remove(); // Def & Fleet
			    		$(value).find('.msg_actions').prepend('<a id="showRe_copy_'+index+'" class="icon_nf_link fleft" href="javascript:void(0);"><span class="icon_nf"></span></a>'); // Select button for Speedsim
			    		$('#showRe_copy_'+index).bind('click',function() { SelectRe('showRe_'+index); });


			    	}
			  	});
		   
			  }
		 
		  }
			
			showReControl++;
			if(showReControl>maxWait) clearInterval(showReCmd); 
			
		}
		
		if(/page=message/.test(location.href)) {
			launchMonitor();
		}

// Host the function on body scope
}).toString();

var script = document.createElement("script");
script.text = "(" + injectShowRe + ")();";
document.body.appendChild(script);