ushro0m / KYS_Galaxy_Ranks

// ==UserScript==
// @name         KYS_Galaxy_Ranks
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://ogame1304.de/game/index.php?page=galaxy*
// @grant        none
// ==/UserScript==

function iterate(item, index){
    
    alert(item, index);
}

function gogo()
 {
     
     var origHTML = document.getElementById('content').innerHTML;
     var whattolookfor = '<span class="normal">';
     var whattolookfor2 = '<td class=c >';
     var whattolookfor3 = ' ranked ';
     var endlooking = '</span>';
     var endlooking2 = '</td>'; 
     var lastindex = 0;    
     var array = [];    
     
     for (i = 0; i < (origHTML.match(/<span class="normal">/g) || []).length; i++) {  
         lastindex = origHTML.indexOf(whattolookfor, lastindex+whattolookfor.length);        
         array.push([origHTML.indexOf(whattolookfor, lastindex)+whattolookfor.length, origHTML.substring(origHTML.indexOf(whattolookfor, lastindex)+whattolookfor.length, origHTML.indexOf(endlooking, origHTML.indexOf(whattolookfor, lastindex)+whattolookfor.length))]);
}
   
     
     var array1 = [];     
     var lastindex2 = 0;    
     var newHTML = origHTML;    
     for (i=0; i < array.length; i++){
        
         var whattolookforc = whattolookfor2+array[i][1]+whattolookfor3;
         var whattoreplace = whattolookfor+array[i][1]+endlooking;
        var rank = origHTML.substring(origHTML.indexOf(whattolookforc, lastindex2)+whattolookforc.length, origHTML.indexOf(endlooking2, origHTML.indexOf(whattolookforc, lastindex2)+whattolookforc.length));
     
         var re = new RegExp(whattoreplace,"g");
    
         newHTML = newHTML.replace(re, array[i][1]+"<font color='orange'> "+rank+"</font>");
         document.getElementById('content').innerHTML = newHTML;
        
     }
     
  
 }

gogo();