vulca / improveV6

// ==UserScript==
// @name         improveV6
// @namespace    http://topraider.eu
// @version      6.1.5.0
// @description  improveV6
// @author       Vulca
// @include       http://*.ogame.gameforge.com/game/index.php?page=messages*
// @include       http://*.ogame.gameforge.com/game/index.php?page=fleet1*
// @include       http://*.ogame.gameforge.com/game/index.php?page=research*
// @include       https://*.ogame.gameforge.com/game/index.php?page=messages*
// @include       https://*.ogame.gameforge.com/game/index.php?page=fleet1*
// @include       https://*.ogame.gameforge.com/game/index.php?page=research*
// @grant          GM_getValue
// @grant          GM_setValue
// ==/UserScript==
'use strict';

function Vu_getValue(key,defaultVal) 
{
    try 
    {  return GM_getValue(key,defaultVal);    } 
    catch( err )
    {  
        return defaultVal;
    }
}

function Vu_setValue(key,value) 
{
    try 
    {  GM_setValue(key,value); } 
    catch( err )
    {}
}

function trim(string)
{return string.replace(/(^\s*)|(\s*$)/g,'');} 


function extractRess(res)
{
    if(/:/.test(res.textContent))
        res =trim(res.textContent.split(':')[1]);
    else
        res=trim(res.textContent);


    if(/^[0-9]{1,3}\.[0-9]{3}$/.test(res))
        res=res.replace(/\./g,'');
    else if (/^([0-9]{1,3}(\.|,))?[0-9]{1,3}(Md|Bn|Mrd)/.test(res))
        res=res.replace(/,/g,'.').replace(/Md|Bn|Mrd/g,'')*1000000000;
    else if (/^([0-9]{1,3}(\.|,))?[0-9]{1,3}(M|m)/.test(res))
        res=res.replace(/,/g,'.').replace(/(M|m)/g,'')*1000000;


    return parseInt(res);       
}

function compactNumber(n) 
{
    n=addPoints(n);


    if( /(^-?[0-9]{1,3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3})$/.test(n))
    {   
        n=n.replace(/([0-9]{1,2}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3}$)/, "KT");
    }
    else if(/(^-?[0-9]{1,3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3})$/.test(n))
    {   
        n=n.replace(/([0-9]{1,2}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3}$)/, "T");
    }
    else if(/(^-?[0-9]{1,3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{3})$/.test(n))
    {   
        n=n.replace(/([0-9]{1,2}\.[0-9]{3}\.[0-9]{3}$)/, "G");
    }
    else if(/(^-?[0-9]{1,3}\.[0-9]{3}\.[0-9]{3}$)/.test(n))
    {
        n=n.replace(/([0-9]{1,2}\.[0-9]{3}$)/, "M");
    }   

    else if(/(^-?[0-9]{1,3}\.[0-9]{3}$)/.test(n))
    {
        n=n.replace(/([0-9]{2}$)/, "K");
    }       


    return n;
}

function addPoints(nombre)
{

    var signe = '';
    if (nombre<0)
    {
        nombre = Math.abs(nombre);
        signe = '-';
    }
    nombre=parseInt(nombre);
    var str = nombre.toString(), n = str.length;
    if (n <4) {return signe + nombre;} 
    else 
    {
        return  signe + (((n % 3) ? str.substr(0, n % 3) + '.' : '') + str.substr(n % 3).match(new RegExp('[0-9]{3}', 'g')).join('.'));
    }

}
function addGT()
{
    if(!document.getElementsByClassName('addGT')[0] && document.getElementsByClassName('resspan')[0])
    {
        var message = document.getElementsByClassName('msg');
        var listeRC=Vu_getValue('listeRc'+serveur+idPlayer, '1||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||');

        for(var i=0 ; i<message.length ; i++)
        {
            var ress = message[i].getElementsByClassName('resspan');


            if(ress[0])
            {

                message[i].getElementsByClassName('compacting')[0].style.display="none";
                message[i].getElementsByClassName('compacting')[2].style.display="none";
                if(message[i].getElementsByTagName('br')[2])
                    message[i].getElementsByTagName('br')[2].style.display="none";




                var m =extractRess(ress[0]);
                var c =extractRess(ress[1]);
                var d =extractRess(ress[2]);

                var coef=message[i].getElementsByClassName('ctn ctn4')[4].textContent.replace(/[^0-9]/g,'');


                var fret=coef/100*(m+c+d);
                
                if(fret>2500000)
                    fret+=250000;
                else fret*=1.1;
                    

                var link=message[i].getElementsByClassName('msg_actions clearfix')[0].getElementsByTagName('a')[3].href;
                
                if(message[i].getElementsByClassName('icon_espionage')[0])  //v6.1.5
                    var link=message[i].getElementsByClassName('msg_actions clearfix')[0].getElementsByTagName('a')[2].href;

                var APIkey = /(sr-[a-z]{2}-[0-9]+-[0-9a-z]+)/.exec(message[i].getElementsByClassName('icon_apikey')[0].title)[0].split('-')[3];


                var linkGT=link+'&am203='+Math.ceil(fret/25000)+'&addGT='+APIkey;
                var linkPT=link+'&am202='+Math.ceil(fret/5000)+'&addGT='+APIkey;




                var newElement = document.createElement("span"); // On crée un nouvelle élément div
                newElement.innerHTML ='(<a href="'+linkPT+'">'+compactNumber(Math.ceil(fret/5000))+' '+PT+'</a>'+
                    ' | <a href="'+linkGT+'">GT</a>)';


                newElement.className ='addGT';
                newElement.id ='addGT'+APIkey;


                message[i].getElementsByClassName('ctn ctn4')[2].appendChild(newElement);


                message[i].getElementsByClassName('icon_nf_link fleft')[2].href+='&addGT='+APIkey;

                document.getElementById('addGT'+APIkey).addEventListener("click", function(event) 
                                                                         {


                    this.getElementsByTagName('a')[0].style.color="rgba(250,0,0,0.6)";
                    this.getElementsByTagName('a')[0].style.fontWeight="bold";
                    this.getElementsByTagName('a')[1].style.color="rgba(250,0,0,0.6)";
                    this.getElementsByTagName('a')[1].style.fontWeight="bold";

                    this.style.color="rgba(250,0,0,0.6)";
                    this.style.fontWeight="bold";


                }, true);


                var crkeyReg = new RegExp(APIkey, "g"); 

                if(message[i].getElementsByClassName('tooltipRight')[1])
                    var def = extractRess(message[i].getElementsByClassName('tooltipRight')[1]);
                else var def=1;

                if(crkeyReg.test(listeRC))
                {
                    // document.getElementById('addGT'+APIkey).style.background="rgba(250,0,0,0.3)";
                    message[i].getElementsByClassName('addGT')[0].getElementsByTagName('a')[0].style.color="rgba(250,0,0,0.6)";
                    message[i].getElementsByClassName('addGT')[0].getElementsByTagName('a')[0].style.fontWeight="bold";
                    message[i].getElementsByClassName('addGT')[0].getElementsByTagName('a')[1].style.color="rgba(250,0,0,0.6)";
                    message[i].getElementsByClassName('addGT')[0].getElementsByTagName('a')[1].style.fontWeight="bold";

                    message[i].getElementsByClassName('addGT')[0].style.color="rgba(250,0,0,0.6)";
                    message[i].getElementsByClassName('addGT')[0].style.fontWeight="bold";


                }else if( Math.ceil(fret/5000) >300 && def ==0)
                {
                    message[i].getElementsByClassName('addGT')[0].getElementsByTagName('a')[0].style.color="rgba(0,250,0,0.6)";
                    message[i].getElementsByClassName('addGT')[0].getElementsByTagName('a')[0].style.fontWeight="bold";

                }
                else if(Math.ceil(fret/5000) >200 && def ==0)
                {
                    message[i].getElementsByClassName('addGT')[0].getElementsByTagName('a')[0].style.color="rgba(250,250,0,0.6)";

                }


                if(m>90000000)
                    ress[0].style.color="#00ff00";
                else if(m>20000000)
                    ress[0].style.color="#ccaa33";

                if(c>100000000)
                    ress[1].style.color="#00ff00";
                else if(c>20000000)
                    ress[1].style.color="#ccaa33";

                if(d>100000000)
                    ress[2].style.color="#00ff00";
                else if(d>20000000)
                    ress[2].style.color="#ccaa33";



                if(message[i].getElementsByClassName('tooltipLeft')[0])
                {
                    var flotte = extractRess(message[i].getElementsByClassName('tooltipLeft')[0])*30/100;                    


                    if(flotte > 100000000)
                        message[i].getElementsByClassName('tooltipLeft')[0].style.color="#00ff00";
                    else if(flotte > 50000000)
                        message[i].getElementsByClassName('tooltipLeft')[0].style.color="#ccaa33";

                    if(message[i].getElementsByClassName('tooltipRight')[1].innerHTML != '')
                    {    



                        if(def==0) 
                        {   
                            message[i].getElementsByClassName('tooltipRight')[1].style.color="#00bb00";
                            def=1;
                        }
                        else if (def<1000000)
                            message[i].getElementsByClassName('tooltipRight')[1].style.color="#bb8800";
                        else message[i].getElementsByClassName('tooltipRight')[1].style.color="#bb0000";

                        if(flotte+fret>5000000)
                        {
                            var ratio = Math.min(20, (fret+flotte) / def);
                            ratio = Math.round(ratio*100)/10;



                            var newElement = document.createElement("center"); // On crée un nouvelle élément div
                            newElement.innerHTML ='   ->R = '+ratio;
                            newElement.style.display= "inline-block";
                            newElement.style.margin= "auto";
                            newElement.style.width= "20%";
                            newElement.style.color= (ratio>1 ? '#00ff00' : '#ff0000');
                            message[i].getElementsByClassName('tooltipLeft')[0].appendChild(newElement);
                        }

                        /* if(fret+flotte<1000000)
                {
                    message[i].getElementsByClassName('msg_content')[0].style.display = 'none';
                }
                */

                    }
                    else 
                    {
                        var newElement = document.createElement("center"); // On crée un nouvelle élément div
                        newElement.innerHTML ='NO DATA FOR DEFENCE !!!!!';
                        newElement.style.color= '#ff0000';

                        message[i].getElementsByClassName('msg_content')[0].appendChild(newElement);


                    }   
                }
                else 
                {
                    var newElement = document.createElement("center"); // On crée un nouvelle élément div
                    newElement.innerHTML ='NO DATA FOR FLEET AND DEF !!!!!';
                    newElement.style.color= '#ff0000';

                    message[i].getElementsByClassName('msg_content')[0].appendChild(newElement);


                }


                var coord = message[i].getElementsByClassName('msg_title blue_txt')[0].getElementsByTagName('a')[0].textContent.split('[')[1].replace(/\[|\]/g,'').replace(/:/g,',');

                var newElement3 = document.createElement("span"); // On crée un nouvelle élément div
                newElement3.innerHTML ='<a title="Sonder" href="javascript:void(0);"><img onclick="sendShips(6,'+coord+',1,7);this.src=\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2Lj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x47SPxgLV7mm6w8ij+hlpLPjRjNdsXPv733Y+iXAANc0GruC56fxAAAAAElFTkSuQmCC" />';

                if(!message[i].getElementsByClassName('icon_espionage')[0])
                message[i].getElementsByClassName('msg_actions clearfix')[0].appendChild(newElement3);


                message[i].getElementsByClassName('msg_sender')[0].innerHTML=message[i].getElementsByClassName('compacting')[0].innerHTML.split(':</span>')[1];

                if(document.getElementsByName('ogame-version')[0].content == '6.0.7')
                    message[i].getElementsByClassName('msg_sender')[0].getElementsByTagName('a')[0].style.display='none';




                if(!message[i].getElementsByClassName('topraderespi')[0])
                {   
                    var tech = Vu_getValue('techno'+document.getElementsByName('ogame-universe')[0].content.split('.')[0]+document.getElementsByName('ogame-player-id')[0].content, "0|0|0").split('|');


                    var api = /(sr-[a-z]{2}-[0-9]+-[0-9a-z]+)/.exec(message[i].getElementsByClassName('icon_apikey ')[0].title)[0];

                    var newElement3 = document.createElement("span"); // On crée un nouvelle élément div
                    newElement3.innerHTML ='<a title="SpeedSim" target="_blank" href="http://topraider.eu/index.php?SR_KEY='+api+'&combu='+tech[0]+'&impu='+tech[1]+'&prop='+tech[2]+'&arme='+tech[3]+'&bouclier='+tech[4]+'&protect='+tech[5]+'&speed='+document.getElementsByName('ogame-universe-speed-fleet')[0].content+'"><img class="speedSimTR" src="http://topraider.eu/images/simu.png" />';
                    message[i].getElementsByClassName('msg_actions clearfix')[0].appendChild(newElement3);
                }



            }




        }





    }
    else if(document.getElementsByClassName('resource_list_el tooltipCustom')[0] && ! document.getElementById('speedsimOK'))
    { // RE DETAILLé
        document.getElementsByClassName('resource_list_el tooltipCustom')[0].getElementsByClassName('res_value')[0].innerHTML = '<span id="speedsimOK" style="font-size:0.5em;">Métal:</span>'+addPoints(extractRess(document.getElementsByClassName('resource_list_el tooltipCustom')[0].getElementsByClassName('res_value')[0]));
        document.getElementsByClassName('resource_list_el tooltipCustom')[1].getElementsByClassName('res_value')[0].innerHTML = '<span style="font-size:0.5em;">Cristal:</span>'+addPoints(extractRess(document.getElementsByClassName('resource_list_el tooltipCustom')[1].getElementsByClassName('res_value')[0]));
        document.getElementsByClassName('resource_list_el tooltipCustom')[2].getElementsByClassName('res_value')[0].innerHTML = '<span style="font-size:0.5em;">Deutérium:</span>'+addPoints(extractRess(document.getElementsByClassName('resource_list_el tooltipCustom')[2].getElementsByClassName('res_value')[0]));

        var img=document.getElementsByTagName('img');
        for(var j=0 ; j<img.length ; j++)
            img[j].alt="\n";


        var tech = Vu_getValue('techno'+document.getElementsByName('ogame-universe')[0].content.split('.')[0]+document.getElementsByName('ogame-player-id')[0].content, "0|0|0").split('|');
        var api = /(sr-[a-z]{2}-[0-9]+-[0-9a-z]+)/.exec(document.getElementsByClassName('detail_msg')[0].getElementsByClassName('icon_apikey')[0].title)[1]

        var newElement3 = document.createElement("span"); // On crée un nouvelle élément div
        newElement3.innerHTML ='<a title="SpeedSim" target="_blank" href="http://topraider.eu/index.php?SR_KEY='+api+'&combu='+tech[0]+'&impu='+tech[1]+'&prop='+tech[2]+'&arme='+tech[3]+'&bouclier='+tech[4]+'&protect='+tech[5]+'&speed='+document.getElementsByName('ogame-universe-speed-fleet')[0].content+'"><img src="http://topraider.eu/images/simu.png" />';
        document.getElementsByClassName('detail_msg')[0].getElementsByClassName('msg_actions clearfix')[0].appendChild(newElement3);





    }
    if (false &  !document.getElementsByClassName('improveRC')[0] && document.getElementsByClassName("msg_ctn msg_ctn3 tooltipLeft")[0])
    { // PAGE RC



        var message = document.getElementsByClassName('msg');
        for(var i=0 ; i<message.length ; i++)
        {
            var loots = message[i].getElementsByClassName('combatLeftSide')[0].getElementsByClassName("msg_ctn msg_ctn3 tooltipLeft")[0];
            loots.innerHTML += loots.title;
            loots.className += ' improveRC';

        }
    }
}


// DEBUT SCRIPT

var version = document.getElementsByName('ogame-version')[0].content;

if(/page=message/.test(location.href))
{
    var idPlayer =document.getElementsByName('ogame-player-id')[0].content;
    var serveur  = document.getElementsByName('ogame-universe')[0].content;

    var PT = 'SC';
    var GT = 'LC';

    if(document.getElementsByName('ogame-language')[0].content == 'fr')
    {
        PT = 'PT';
        GT = 'GT';       
    }

    setInterval(addGT,500);
}
else if(/page=fleet1/.test(location.href) && /addGT=/.test(location.href) )
{

    var idPlayer =document.getElementsByName('ogame-player-id')[0].content;
    var serveur  = document.getElementsByName('ogame-universe')[0].content;


    var listeRC=Vu_getValue('listeRc'+serveur+idPlayer, '1||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||').split('|');
    listeRC[parseInt(listeRC[0])+1]=location.href.split(/addGT=/g)[1];
    listeRC[0]=(parseInt(listeRC[0])+1)%250;

    Vu_setValue('listeRc'+serveur+idPlayer, listeRC.join('|'));  

}
else if(/page=research/.test(location.href))
{

    var niveaux = document.getElementsByClassName('level') ;
    var niveau ='';
    var listNiveau='';

    for (var f=5; f<16 ; f++)
    {
        if(typeof(niveaux[f].getElementsByClassName('textlabel')[0])=="undefined") 
        {   

            niveau = niveaux[f].innerHTML.split('span')[0].replace( /[^0-9-]/g, ""); 

        }
        else 
        {

            niveau = niveaux[f].textContent;

            var span = niveaux[f].getElementsByTagName('span');

            for(var k=0; k< span.length ; k++)
            {   niveau = trim(niveau.replace( span[k].textContent, ""));}
        }

        //alert( parseInt(niveau) +'  '+f);
        listNiveau+=niveau+'|';

        if(f==7)
            f=12;

    }


    Vu_setValue('techno'+document.getElementsByName('ogame-universe')[0].content.split('.')[0]+document.getElementsByName('ogame-player-id')[0].content, listNiveau);


}