d4n13lus / DEAD MANDA

// ==UserScript==
// @name         DEAD MANDA
// @namespace    www.dead.com
// @version      0
// @description  DEAD MANDA
// @author       DEAD MANDA
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @include     	*.ogame*gameforge.com/game/index.php?page=messages*
// @include     	*.ogame*gameforge.com/game/index.php?page=research*
// @license MIT
// ==/UserScript==
/* jshint -W097 */
'use strict';
//Beta testers : DEAD MANDA
//DEAD MANDA

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ZONE CSS ////////////////////////////////////////////////////////////////////////////////////////////////CSS AREA/////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var MetaGlobal = MetaDatas();

var Picture = {};
    Picture.Attack = '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAAK/INwWK6QAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAA9QTFRF////ERohKT9OGCQt////xekcDAAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAUUlEQVQI1z3O0QnAQAiD4XguoO0CV7qAbfbf7S5Cm6ePHwSBb5a9gG0HICgIphINBcGOK4TMOXTl5Bxkwd3fu0oACcHghdjAST4QVDaMvfi/WNC7CBtD82AsAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE2LTA1LTE4VDIxOjQ5OjM1KzAyOjAwxD15VgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0wNS0xOFQyMTo0OTozNSswMjowMLVgweoAAABKdEVYdHNpZ25hdHVyZQA0MDdjN2E2YTVlZjRkNWEwZmQ3YmYzYTZkMjEzZTQxNTc1ZjVmZmVkMWVhZGEwYjVjY2UyZmM0ZWQ2ZjJjMzY4RTAYDAAAAABJRU5ErkJggg=="';
    Picture.Delete = '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAQAgMAAAC0OM2XAAAABGdBTUEAAK/INwWK6QAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAxQTFRF////ERohGCQt////TqQTdwAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAO0lEQVQI12NgAAHR0NAABlEH1gAGAQYgYgwNZWAQcXUJYBBxgREaHR0LMIhVK4AEA8MCBqlVqxaATQIAQGARmtdXRBkAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTYtMDUtMTlUMjE6MjY6MDUrMDI6MDD9ZH7qAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTA1LTE5VDIxOjI2OjA1KzAyOjAwjDnGVgAAAEp0RVh0c2lnbmF0dXJlAGYyMjAyNjVlMzFjYjRjODY3NWI5ZWYxNTU2YTVlNGM5OGMwZTg0OTMwZTc0ZWIxMmQxMDk5NjJkNWJmZWJlZDdTCRapAAAAAElFTkSuQmCC"';
    Picture.Message = '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAAK/INwWK6QAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAA9QTFRF////ERoh7RwkGCQt////eP04VgAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAUElEQVQI11XOUQrAIAwD0NRcwHmC6QkKuf/dlgpuLB/yiIUWOIkxL6d/aGvNP2LcNWm0KmBE+KMbTInZQQpQprGbAuXCgBwYWRv9Ujv5XvEAY0YJ1r8Dex4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTYtMDUtMTlUMjE6NDE6MjUrMDI6MDC1KKitAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTA1LTE5VDIxOjQxOjI1KzAyOjAwxHUQEQAAAEp0RVh0c2lnbmF0dXJlADAzOGUzY2E5Nzk3N2Y1NzM0MTM2ZTlkMWVlMTBhYmNmMDBlNjhlMmY3ZjdhNjY2N2M1ZDRlM2Q2Y2M4M2YzMTYencQXAAAAAElFTkSuQmCC"';
    Picture.RC = '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAABGdBTUEAAK/INwWK6QAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAxQTFRF////ERohGCQt////TqQTdwAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAATklEQVQI12NgAAHR0NAQBpEQgRAGUQYBEQZRxkAgyyHUhUHU0YWFQdSVlYVBYdWqFQwKizpWMGgwMXAwaDE1ALlaTUBiVdcKBi2QLAgAAAiRD+3F7dwlAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE2LTA2LTEyVDE5OjEwOjA1KzAyOjAwtnczDgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0wNi0xMlQxOToxMDowNSswMjowMMcqi7IAAABKdEVYdHNpZ25hdHVyZQA2NWUxNjAxZWY4MzgwMGVjMmZhOTc0NDIxZTIxZjI2MDU2MWM2MTYwZWY2Nzk5MDA2NGZmZTE4MjU0N2U1NDExqdtWPAAAAABJRU5ErkJggg=="';
    Picture.Undelete = '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAABGdBTUEAAK/INwWK6QAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAxQTFRF////ERohGCQt////TqQTdwAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAS0lEQVQI12NgAAHR0NAQBrEJrC4MUoyOLgwSoiEsDCKhQEIg1IGFQRAkq7Rq1QoGBRChsWqVBoOGFpDQYmpYwaC1gAtIrFq1BGwSAFXPEZWmN3m+AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE2LTA5LTA2VDE5OjE5OjE0KzAyOjAwMLcC5AAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0wOS0wNlQxOToxOToxNCswMjowMEHqulgAAABKdEVYdHNpZ25hdHVyZQA5MzAxMTMwYzI5YWQyNTgzNTZhMTYwOTU5MTQ3Mzc5YTFlNzYyYTNhOThkNDZhY2UyOGI5MGM3MmIxMzA4ZjkyhgdCmAAAAABJRU5ErkJggg=="';

GM_addStyle(".InfosVague { border: 1px solid #555; border-radius: 0px 0px 25px 25px; margin-top: 10px  } "); //bord du tableau
GM_addStyle(".TableauRaid { text-align: center; width: 100%;} "); //bord du tableau

//Ligne d'entête
GM_addStyle(".FirstLine { text-align: center; height: 30px; font-weight: bold; border-left: 1px solid #333; cursor:default; background-color: #000000;} "); //lignes de tête
GM_addStyle(".FirstLine:hover { text-align: center; height: 30px; font-weight: bold; border-left: 1px solid #333; cursor:default; background-color: #111117;} "); //lignes de tête

//Toutes les lignes à l'intérieur du tableau
GM_addStyle(".InsideBoard { text-align: center; border-left: 1px solid #333; height: 21px} "); //lignes contenant les RE


//Lignes spécifiques
GM_addStyle(".Line {width: 30px; border-left: 1px solid #222;}");
GM_addStyle(".PTGT {width: 18px ;}");


//Lignes paires et impaires
//lignes paires
if ((GM_getValue('color0' +  MetaGlobal.Universe) && GM_getValue('color16' + MetaGlobal.Universe))) { //only applies custom configs when COLOR0 and COLOR16 have value stored
    GM_addStyle(".Pair {background-color: #" + GM_getValue('color16' +  MetaGlobal.Universe) + ";}");
    GM_addStyle(".Pair:hover { background-image: linear-gradient(to bottom, #" + GM_getValue('color0' +  MetaGlobal.Universe) + " 0%, #" + GM_getValue('color16' +  MetaGlobal.Universe) + " 30%, #" + GM_getValue('color16' +  MetaGlobal.Universe) + " 70%, #" + GM_getValue('color0' + MetaGlobal.Universe) + " 100%); "); //lignes paires, le get value récupère la couleur enregistrée par l'utilisateur
} else {
    GM_addStyle(".Pair {background-color: #111A21;}"); //lignes paires
    GM_addStyle(".Pair:hover { background-image: linear-gradient(to bottom, #0C8528 0%, #111A21 30%, #111A21 70%, #0C8528 100%); "); //attribution du style par défaut lorsqu'aucune préférence n'est enregistrée
}
//lignes impaires
if ((GM_getValue('color0' +  MetaGlobal.Universe) && GM_getValue('color17' + MetaGlobal.Universe))) { //only applies custom configs when COLOR0 and COLOR17 have value stored
    GM_addStyle(".Impair {background-color: #" + GM_getValue('color17' +  MetaGlobal.Universe) + ";}");
    GM_addStyle(".Impair:hover {background-image: linear-gradient(to bottom, #" + GM_getValue('color0' + MetaGlobal.Universe) + " 0%, #" + GM_getValue('color17' +  MetaGlobal.Universe) + " 30%, #" + GM_getValue('color17' +  MetaGlobal.Universe) + " 70%, #" + GM_getValue('color0' + MetaGlobal.Universe) + " 100%); "); //lignes impaires, le get value récupère la couleur enregistrée par l'utilisateur
} else {
    GM_addStyle(".Impair {background-color: #18242d;"); //lignes impaires
    GM_addStyle(".Impair:hover { background-image: linear-gradient(to bottom, #0C8528 0%, #18242D 30%, #18242D 70%, #0C8528 100%);}"); //lignes impaires
}


//Boutons attaque
if ((GM_getValue('color1' + MetaGlobal.Universe))) { //Vérifie la présence de contenu sauvegardé, le if fait exactement la même chose que pour les lignes paires et impaires juste au dessus (explications dispo à cet endroit-là)
    GM_addStyle(".AttackPTButton:link, .AttackGTButton:link {display: block; width: 16px; height:16px; background-image: url(" + Picture.Attack + "); background-color: #" + GM_getValue('color1' + MetaGlobal.Universe) + ";}");
    GM_addStyle(".RCButton:link {display: block; width: 16px; height:16px; background-image: url(" + Picture.RC + "); background-color: #" + GM_getValue('color1' + MetaGlobal.Universe) + ";}");
} else {
    GM_addStyle(".AttackPTButton:link, .AttackGTButton:link {display: block; width: 16px; height:16px; background-image: url(" + Picture.Attack + "); background-color: #ffffff;}");
    GM_addStyle(".RCButton {display: block; width: 16px; height:16px; background-image: url(" + Picture.RC + "); background-color: #FFFFFF;}");
}
if ((GM_getValue('color2' + MetaGlobal.Universe))) {
    GM_addStyle(".AttackPTButton:hover, .AttackGTButton:hover {background-color: #" + GM_getValue('color2' + MetaGlobal.Universe) +" !important ;}");
    GM_addStyle(".RCButton:hover {background-color: #" + GM_getValue('color2' + MetaGlobal.Universe) +" !important;}");
} else {
    GM_addStyle(".AttackPTButton:hover, .AttackGTButton:hover {background-color: #00ff00 !important;}");
    GM_addStyle(".RCButton:hover {background-color: #00ff00;}!important;");
}

///////////////////////////////////////////////////////////////////////////////////////////
//CSS for specific items in HTML Board
//CSS to colorize Def and fleet in white and underline it when hover
GM_addStyle(".FltDefCtn {text-decoration: none; }");
GM_addStyle(".FltDefCtn:hover { color:#FFFFFF; text-decoration: underline;} "); //color fleet value in white on hover

//CSS to colorize fleet when it reaches the good amount
if (GM_getValue('color6' + MetaGlobal.Universe)) {
    GM_addStyle(".FltColorized { color:#" + GM_getValue('color6' + MetaGlobal.Universe) + ";} "); //Style used to colorize fleet value in table
} else {
    GM_addStyle(".FltColorized { color:#FF0000;} "); //Style used to colorize fleet value in table, default value
}
//CSS to colorize def when it reaches the good amount
if (GM_getValue('color7' + MetaGlobal.Universe)) {
    GM_addStyle(".DefColorized { color:#" + GM_getValue('color7' + MetaGlobal.Universe) + ";} "); //Style used to colorize fleet value in table
} else {
    GM_addStyle(".DefColorized { color:#FF0000;} "); //Style used to colorize fleet value in table, default value
}
//CSS to colorize def when it's profitable to send missiles
if (GM_getValue('color12' + MetaGlobal.Universe)) {
    GM_addStyle(".DefMissilesColorized { color:#" + GM_getValue('color12' + MetaGlobal.Universe) + ";} "); //Style used to colorize fleet value in table
} else {
    GM_addStyle(".DefMissilesColorized { color:#00FF00;} "); //Style used to colorize fleet value in table, default value
}

//Lien Galaxie
GM_addStyle(".CoordLink:link, .CoordLink:visited, CoordLink:active  {text-decoration: none; color: white;}");
GM_addStyle(".PlayerCell:hover {text-decoration: underline; color: white !important; }");


//Colorize line coords if the galaxy distance is bigger than user specified in color22/text34 options
if (GM_getValue('color22' + MetaGlobal.Universe)) {
    GM_addStyle(".Table_GCoords_Colored:link, .Table_GCoords_Colored:visited, .Table_GCoords_Colored:active {text-decoration: none; color:#" + GM_getValue('color22' + MetaGlobal.Universe) + ";}");
} else {
    GM_addStyle(".Table_GCoords_Colored:link, .Table_GCoords_Colored:visited, .Table_GCoords_Colored:active {text-decoration: none; color:#FFFFFF;}");
}

//Colorize line coords if the ss distance is bigger than user specified in color23/text35 options
if (GM_getValue('color23' + MetaGlobal.Universe)) {
    GM_addStyle(".Table_SSCoords_Colored:link, .Table_SSCoords_Colored:visited, .Table_SSCoords_Colored:active {text-decoration: none; color:#" + GM_getValue('color23' + MetaGlobal.Universe) + ";}");
} else {
    GM_addStyle(".Table_SSCoords_Colored:link, .Table_SSCoords_Colored:visited, .Table_SSCoords_Colored:active {text-decoration: none; color:#FFFFFF;}");
}

//Bouton supprimer message et bouton plus de détails
GM_addStyle("#DeleteA {display: block; width: 15px; height:16px; background-image: url(" + Picture.Delete + "); background-color: #FFFFFF;}");
GM_addStyle("#UnDelete {display: block; width: 16px; height:16px; background-image: url(" + Picture.Undelete + "); background-color: #FFFFFF;}");
GM_addStyle("#MoreDetails:link {display: block; width: 16px; height:16px; background-image: url(" + Picture.Message + "); background-color: #FFFFFF;}");

//Tableau d'entête avec tous les boutons
GM_addStyle(".TableButton {text-align: center; width: 100%; cursor:default; margin: 30px 0px 30px 0px;}");
GM_addStyle(".CaseTableButton {display:inline; border: 1px dashed #444; margin-left: 3px; padding: 5px 3px 5px 2px ");
GM_addStyle(".CaseTableButton:hover {display:inline; border: 1px solid #666; margin-left: 3px");

//Tableau des options
GM_addStyle("#OptionsDiv { border: 1px solid #555; text-align: center; width: 100%; border-radius: 0px 0px 25px 25px; margin-top: 20px;  } "); //bord du tableau
GM_addStyle("#OptionsMainTable {background-color : #000000; border: 1px solid #222; width: 100%} "); //bord du tableau
GM_addStyle(".OptionsMainLine { text-align: center; border-bottom: 1px solid #222; width: 100%; height: 30px;} "); //Lignes principales à dérouler
GM_addStyle(".LastMainLine {text-align: center; width: 100%; height: 30px;} "); //Lignes principales à dérouler
GM_addStyle("#SauvegarderOptions {text-align: center; width: 100%; height: 30px; border-bottom: 1px solid #222} "); //Bouton sauvegarder en bas des options
GM_addStyle("#SauvegarderOptions:hover {text-align: center; width: 100%; height: 30px; background-image: radial-gradient(ellipse closest-corner at center, #242424 0%, #000000 80%, #000000 80%, #FFFFFF 84%, #000000 100%); color: white;} "); //Bouton sauvegarder en bas des options


GM_addStyle(".OptionsColonnes {width: 100%;} "); //Lignes principales à dérouler
GM_addStyle(".TableauZoneColonnes {width: 100%; display:inline;}"); //Lignes principales à dérouler
GM_addStyle(".OptionsColonnesContent {text-align: left; width: 100%; height: 20px; width: 100%; } "); //Lignes principales à dérouler

GM_addStyle(".OptionsCouleurs {width: 100%;} "); //Lignes principales à dérouler
GM_addStyle(".TableauZoneCouleurs {width: 100%; display:inline;}"); //Lignes principales à dérouler
GM_addStyle(".OptionsCouleursContent, .OptionsGlobalesContent, .OptionsTechsContent, .OptionsTableauRecapContent {text-align: left; width: 100%; height: 20px; width: 100%; } "); //Lignes principales à dérouler



GM_addStyle(".DropDownShipsMore {text-align:center ;width:100px;}");

//Text fields input
GM_addStyle("input[type='text'].BigText { width:90px; background-color : #FFFFFF; padding: 0px 0px 0px 0px; box-shadow:none; border: 1px solid #aaa; height: 15px; padding:0px; border-radius: 0px 0px 0px 0px; text-align: center; !important}");
GM_addStyle("input[type='text'].SmallText { width:30px; background-color : #FFFFFF; padding: 0px 0px 0px 0px; box-shadow:none; border: 1px solid #aaa; height: 15px; padding:0px; border-radius: 0px 0px 0px 0px; text-align: center; !important }");


function PlayerColor(Message) {
    switch(Message.PlayerColor) {
        case "0":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#505050;}");
            break;
        case "1":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#808080;}");
            break;
        case "2":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#ffffff;}");
            break;
        case "3":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#ffff00;}");
            break;
        case "4":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#ff00ff;}");
            break;
        case "5":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#00ffff;}");
            break;
        case "6":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#00ff00;}");
            break;
        case "7":
            GM_addStyle("#PL" + Message.Id + ", #PL" + Message.Id + ":hover  {color:#ff0000;}");
            break;
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FONCTION D-AFFICHAGE DU SCRIPT////////////////////////////////////////////////////////DISPLAY BOARD FUNCTIONS/////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function Display() //Cette fonction génère les boutons du haut
{
    var MetaLocal = MetaDatas();
    var DisplayButton = document.createElement("div"); //Création d'un élément div
    DisplayButton.innerHTML = BoardButton(); //Appel de la fonction affichant les boutons du dessus

    document.querySelector("#ui-id-14 .tab_inner:first-child").insertBefore(DisplayButton, document.querySelector("#ui-id-14 .tab_inner:first-child").firstChild); //Affichage des boutons
    try { //désactive l'affichage de la ligne indiquant qu'il n'y a aucun message (lorsqu'il y a aucun message)
        document.querySelector(".no_msg").style.display='none';
    } catch(err) {
    }


    //Assignation des fonctions des boutons

    //DISPLAY BUTTON
    document.getElementById('AfficherTableau').addEventListener("click", function(event) //Création du bouton permettant l'affichage du tableau
                                                                {
        InitialisationTableau('',1); //1 = show not deleted spy reports
    }, true);

    //COLLECT BUTTON
    document.getElementById('CollecterMessages').addEventListener("click", CollectAndStoreRE, true);

    //HIDE BUTTON
    document.getElementById('MasquerTableau').addEventListener("click", HideTable, true);

    //OPTIONS BUTTON
    document.getElementById('OptionsButton').addEventListener("click", function(event) //Création du bouton permettant la collecte et la sauvegarde des messages
                                                              {
        OptionsButton();
    }, true);

    //EMPTY BUTTON
    document.getElementById('Empty').addEventListener("click", StartEmptyProcess, true);


    // + BUTTON
    //BEGIN OF EVENTLISTENERS FOR + TOOLTIP BUTTON
    //If you don't understand something explained on this part, try to change values to see the problems from yourself. I try my best to explain, but this part is kind of... hard for me.
    //This part took me 2 days to make it work correctly (a lot of problems occured :( )
    //This is really important for eventlistener to wait until the tooltip is correctly shown inside the source code. If the script don't wait, eventlistener generates an error, as no id is found (no tooltip at this time). That's why this part is only executed when user put the mouse on "+" button, and waits some milliseconds until the tooltip is shown.
    document.querySelector('#Plus').addEventListener("mouseover", function(event) //Waits the user to put the mouse on "+" Button
                                                     {
        console.log("[O-Table] : + Button has been asked");
        GM_addStyle("#Plus {color: orange;}"); //Puts the "+" in orange, to help user to know when he has to wait
        setTimeout(function(){ //Set timeout is used to let the time to the source code to create the tooltip (without, the script will generate a VM8610:235 Uncaught TypeError: Cannot read property 'addEventListener' of null ERROR) as eventlistener will not find the id it needs, as this id is not yet on the source code
            var TrashBinButtons = document.querySelectorAll("#TRASHBIN");
            var UndeleteButton = document.querySelectorAll("#UNDELETETOOLTIP");
            var DeleteAttackedButton = document.querySelectorAll("#DELETEATTACKED");
            try {
                for (var i = 0; i < TrashBinButtons.length; i++) { //When user change of message page, the old TRASHBIN element is still in the source code. So instead of put the addeventlistenener to one element, we need to put the addeventlistener to 2 elements. Without the for, when the user change of message page, functions inside the "+" Tooltip aren't working anymore.
                    //Remove older eventlisteners created by the line just under. without this line, the script will be executed x times (x = amount of time the tooltip has been executed);
                    TrashBinButtons[i].removeEventListener("click", TrashbinInit); //The function must have no arguments, so InitialisationTableau cannot be launched directly (it has argumets). Instead, initialisationtableau is launched on TrashbinInit Function)
                    TrashBinButtons[i].addEventListener("click", TrashbinInit); //Trashbin Button
                }
                for (var i = 0; i < UndeleteButton.length; i++) { //Undeletebutton
                    //Remove older eventlisteners created by the line just under. without this line, the script will be executed x times (x = amount of time the tooltip has been executed);
                    UndeleteButton[i].removeEventListener("click", CancelDeletion);
                    UndeleteButton[i].addEventListener("click", CancelDeletion);
                }
                for (var i = 0; i < DeleteAttackedButton.length; i++) { //Delete all attacked targets button
                    //Remove older eventlisteners created by the line just under. without this line, the script will be executed x times (x = amount of time the tooltip has been executed);
                    DeleteAttackedButton[i].removeEventListener("click", DeleteAttacked);
                    DeleteAttackedButton[i].addEventListener("click", DeleteAttacked);
                }
                console.log("[O-Table] : Trashbin addeventlistener has been added to " + TrashBinButtons.length + " items in the source code");
            } catch(err) {
                console.log("[O-Table] : + Tooltip hasn't been created fast enough, slow PC ? ");
                GM_addStyle("#Plus {color: red !important;}");
            }

            GM_addStyle("#Plus {color: inherit;}");
        }, 400); // end of settimeout
    }, true);

    document.querySelector('#Plus').addEventListener("click", function(event) //Waits the user to put the mouse on "+" Button
                                                     {
        QuickFilter();
    }, true);

    //Function to launch trashbin when user click on trashbin button
    function TrashbinInit(){ //
        InitialisationTableau('',0)
    }

    //Function to cancel the last line deletion
    function CancelDeletion() { //This function is used inside the tooltip to cancel deletion of the last
        try {
            document.getElementById(IdLineGLB).style = '';
            var TextStoredLine = GetStoredRE(IdLineGLB);
            var ObjLine = ConvertStringToObj(TextStoredLine);
            ObjLine.Display = 1;
            SetStoredRE(IdLineGLB, ObjLine);
            console.log("[O-Table] : Line with id " + IdLineGLB + " successfully displayed and undeleted.");
        } catch(err) {
            console.log("[O-Table] : No line have been deleted since last refresh");
        }
    }

    //Function to delete all attacked targets
    function DeleteAttacked(){ //
        var CurrentTable =  document.querySelectorAll(".TableLine");
        console.log("[O-Table] : Begining to delete all attacked lines");
        for (var i = 0; i < CurrentTable.length; i++) {
            var BtnAttack = CurrentTable[i].querySelector(".AttackPTButton.BtnClicked") + CurrentTable[i].querySelector(".AttackGTButton.BtnClicked"); //this variable gets buttons data from attacked buttons, returns 0 if no attacked button has been found on the line
            if (BtnAttack === 0) {
                console.log("[O-Table] : No attack buttons has been clicked on line " + i + ", line not deleted");
            } else {
                //This part is like a delete button from each line
                var IdLineDeleted = CurrentTable[i].id;
                CurrentTable[i].style.display='none';
                var TextStoredLine = GetStoredRE(IdLineDeleted);
                var ObjLine = ConvertStringToObj(TextStoredLine);
                ObjLine.Display = 0;
                SetStoredRE(IdLineDeleted, ObjLine);
                console.log("[O-Table] : Line " + i + " sucessfully deleted");
            }
        }
    }

    //END OF + TOOLTIP


    //Si l'utilisateur a choisi de collecter automatiquement les REs, alors on les collecte
    if (GM_getValue('column22' + MetaLocal.Universe) === true) {
        CollectAndStoreRE();
        console.log("[O-Table] : Messages are automalically collected");
    }

    //Si l'utilisateur a choisi d'afficher automatiquement le tableau, alors on l'affiche
    if (GM_getValue('column21' + MetaLocal.Universe) === true) {
        InitialisationTableau('',1); //1 = show not deleted spy reports
        console.log("O-Table] : Table is automatically displayed");
    }
}





//////////////
//Fonction de création des boutons du tableau
/////////////
function BoardButton()
{
    var LangueIndex = GetLangue();
    var TableauBoutons = '<div class ="TableButton">' +
                              '<ul class ="LigneTableButton">' +
                                   '<li class ="CaseTableButton" id="AfficherTableau" title="' + Langue.BoutonAfficherTableauTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonAfficherTableau.split("|||")[LangueIndex] + '&#8239}</td>' + //
                                   '<li class ="CaseTableButton" id="CollecterMessages" title="' + Langue.BoutonCollecterMessagesTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonCollecterMessages.split("|||")[LangueIndex] + '&#8239}</td>' +
                                   '<li class ="CaseTableButton" id="MasquerTableau" title="' + Langue.BoutonMasquerTableauTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonMasquerTableau.split("|||")[LangueIndex] + '&#8239}</td>' +
                                   '<li class ="CaseTableButton" id="OptionsButton" title="' + Langue.BoutonOptionsTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonOptions.split("|||")[LangueIndex] + '&#8239}</td>' +
                                   '<li class ="CaseTableButton" id="Empty" title="' + Langue.BoutonViderScriptTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonViderScript.split("|||")[LangueIndex] + '&#8239}</td>' +
                                   '<li class ="CaseTableButton tooltipUp tooltipClose" id="Plus" title="<a id=TRASHBIN >' + Langue.AfficherCorbeille.split("|||")[LangueIndex] + '</a><br /><a id=UNDELETETOOLTIP >' + Langue.AfficherUndelete.split("|||")[LangueIndex]  + '</a><br /><a id=DELETEATTACKED >' + Langue.SupprimerAtq.split("|||")[LangueIndex]  + '</a>">&#8239{&#8239+&#8239}</td>' +
                                   //'<li class ="CaseTableButton"></td>' +
                              '</ul></div>';
    return TableauBoutons;
}


///////////////////////////
function InitialisationTableau(TableauRE,DisplayWhat) {
    var MetaLocal = MetaDatas();
    if (GM_getValue('REIdList' + MetaLocal.Universe)) { //Check if there is an SR id list is already stored on the script. An id list exists only if there is a spy report stored on the script. if yes, the function initializes, if no, nothing happens
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        var StartExec = new Date().getTime();
        try {//Permet d'effacer le tableau s'il est déjà présent
            var Empty = '';
            var Table = document.querySelector(".InfosVague");
            if(Table.outerHTML) {
                Table.outerHTML = Empty;
            }

        } catch(err) {
        }
        try {//Permet d'effacer le tableau d'informations s'il est déjà présent
            var Empty = '';
            var Table = document.querySelector("#DIVINFO");
            if(Table.outerHTML) {
                Table.outerHTML = Empty;
            }
        } catch(err) {}
        try {//Permet d'effacer le tableau d'options s'il est déjà présent
            var Empty = '';
            var Table = document.querySelector("#OptionsDiv");
            if(Table.outerHTML) {
                Table.outerHTML = Empty;
            }
        } catch(err) {}
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        GM_addStyle("#AfficherTableau {color : #FFAA00;}"); //Colorie le bouton en orange pour indiquer que l'affichage est en cours d'execution
        //Tri du tableau, vérifie si celui-ci a déja été trié ou non (TriDone passe à 1 lorsqu'un tri par l'utilisateur a été effectué)
        if (TriDone === 0) {
            TableauRE = MsgBoard();
            TableauRE.sort(Tri);
            if ((GM_getValue('color14' + MetaLocal.Universe))) {//Colorize selected line to sort the board
                GM_addStyle("#" + currentSort + " { color: #" + GM_getValue('color14' + MetaLocal.Universe) + "!important; background-color: #151515 !important;} ");
            } else {
                GM_addStyle("#" + currentSort + " {color: #00FF00 !important; background-color: #151515 !important;} ");
            }
        }
        TriDone = 0;
        var NbItemsTableau = TableauRE.length;
        //alert(NbItemsTableau);

        var DisplayInfos = 0;
        if (GM_getValue('column17' + MetaLocal.Universe) === false || GM_getValue('column17' + MetaLocal.Universe) === true) { //Vérifie si l'utilisateur a choisi d'afficher le tableau d'infos (je sais, l'id dans get value n'est pas explicite) -- Par défaut, le tableau s'affiche
            if (GM_getValue('column17' + MetaLocal.Universe) === true) {
                DisplayInfos = 1;
            }
        } else {
            DisplayInfos = 1
        }
        if (DisplayInfos == 1) {
            var TableauHTMLInfo = InfoDatasBoard(TableauRE,DisplayWhat); //Tableau d'infos
            var newElementA = document.createElement("div");
            newElementA.innerHTML = TableauHTMLInfo;
            document.querySelector("#ui-id-14 .TableButton:first-child").insertBefore(newElementA, document.querySelector("#ui-id-14 .TableButton:first-child").nextSibling);
        }


        var TableauHTML = CreateBoardHTML(TableauRE,DisplayWhat); //Tableau de pillage
        var Design = TableauHTML;
        var newElement = document.createElement("div"); // On crée un nouvelle élément div
        newElement.innerHTML = Design; // On écrit le code source qu'il contient
        document.querySelector("#ui-id-14 .TableButton:first-child").insertBefore(newElement, document.querySelector("#ui-id-14 .TableButton:first-child").nextSibling);


        //Indique à l'utilisateur que le tableau s'est bien executé en passant la couleur du texte du bouton "afficher tableau" en vert (avec personnalisation de couleur)
        if ((GM_getValue('color13' + MetaLocal.Universe))) {
            GM_addStyle("#AfficherTableau { color: #" + GM_getValue('color13' + MetaLocal.Universe) + ";}");
        } else {
            GM_addStyle("#AfficherTableau { color: #00FF00;}");
        }
        //Boutons présents à l'intérieur du tableau//////////////////////////////////////////////////////////////////////////////////////////////////
        ////Bouton suppression de chaque ligne
        for (var i=0; i < NbItemsDisplayed; i++){
            try {
                document.querySelectorAll('#DeleteA')[i].addEventListener("click", function(event)                                                  {
                    var IdLine = this.parentNode.parentNode.id;
                    IdLineGLB = IdLine;
                    this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                    var TextStoredLine = GetStoredRE(IdLine);
                    var ObjLine = ConvertStringToObj(TextStoredLine);
                    ObjLine.Display = 0;
                    SetStoredRE(IdLine, ObjLine);
                    console.log("[O-Table] : SR deleted successfully");
                }, true);
            } catch(err) {
            }
            try {
                document.querySelectorAll('#UnDelete')[i].addEventListener("click", function(event)                                                  {
                    var IdLine = this.parentNode.parentNode.id;
                    this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                    var TextStoredLine = GetStoredRE(IdLine);
                    var ObjLine = ConvertStringToObj(TextStoredLine);
                    ObjLine.Display = 1;
                    SetStoredRE(IdLine, ObjLine);
                    console.log("[O-Table] : SR undeleted successfully");
                }, true);
            } catch(err) {
            }
            try {
                document.querySelectorAll('.AttackPTButton')[i].addEventListener("click", function(event)                                                  { //AttackButton small cargo
                    var PtAttacked = 1;
                    this.className += " BtnClicked";
                    var IdLine = this.parentNode.parentNode.id;
                    var TextStoredLine = GetStoredRE(IdLine);
                    var ObjLine = ConvertStringToObj(TextStoredLine);
                    ObjLine.PTAttacked = 1; //Mise en mémoire permettant de d'enregistrer en dur que le bouton a été cliqué
                    SetStoredRE(IdLine, ObjLine);
                    if ((GM_getValue('color3' + MetaLocal.Universe))) {
                        GM_addStyle("#PT" + IdLine + ".AttackPTButton:visited, #PT" + IdLine + ".AttackPTButton:active { background-color: #" + GM_getValue('color3' + MetaLocal.Universe) + "!important;}"); //Cette ligne CSS s'applique uniquement lorsque l'utilisateur clique sur le bouton et permet d'afficher sur le tableau que le bouton a été cliqué. Elle ne permet pas de mise ne mémoire et vu qu'à chaque rafraichissement, il faut recliquer sur le bouton pour l'activer, il n'y a pas de mise en mémoire des liens cliqués à proprement parler.
                    } else {
                        GM_addStyle("#PT" + IdLine + ".AttackPTButton:visited, #PT" + IdLine + ".AttackPTButton:active { background-color: #00ff00 !important;}");
                    }
                    if (GM_getValue('column33' + MetaLocal.Universe) === true) { //same thing than classic deletebutton
                        IdLineGLB = IdLine;
                        this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                        var TextStoredLine = GetStoredRE(IdLine);
                        var ObjLine = ConvertStringToObj(TextStoredLine);
                        ObjLine.Display = 0;
                        SetStoredRE(IdLine, ObjLine);
                        console.log("[O-Table] : SR deleted successfully");
                    }
                }, true);
            } catch(err){
            }
            try {
                document.querySelectorAll('.AttackGTButton')[i].addEventListener("click", function(event)                                                  { //AttackButton heavy cargo
                    var GtAttacked = 1;
                    this.className += " BtnClicked";
                    var IdLine = this.parentNode.parentNode.id;
                    var TextStoredLine = GetStoredRE(IdLine);
                    var ObjLine = ConvertStringToObj(TextStoredLine);
                    ObjLine.GTAttacked = 1; //Mise en mémoire permettant de d'enregistrer en dur que le bouton a été cliqué
                    SetStoredRE(IdLine, ObjLine);
                    if ((GM_getValue('color3' + MetaLocal.Universe))) { //If de vérification de présence d'une donnée dans color3 (fonctionne comme les lignes paires et impaires dans la zone css
                        GM_addStyle("#GT" + IdLine + ".AttackGTButton:visited, #GT" + IdLine + ".AttackGTButton:active { background-color: #" + GM_getValue('color3' + MetaLocal.Universe) + ";}"); //Cette ligne CSS s'applique uniquement lorsque l'utilisateur clique sur le bouton et permet d'afficher sur le tableau que le bouton a été cliqué. Elle ne permet pas de mise ne mémoire et vu qu'à chaque rafraichissement, il faut recliquer sur le bouton pour l'activer, il n'y a pas de mise en mémoire des liens cliqués à proprement parler.
                    } else {
                        GM_addStyle("#GT" + IdLine + ".AttackGTButton:visited, #GT" + IdLine + ".AttackGTButton:active { background-color: #00ff00;}");
                    }
                    if (GM_getValue('column33' + MetaLocal.Universe) === true) { //same thing than classic deletebutton
                        IdLineGLB = IdLine;
                        this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                        var TextStoredLine = GetStoredRE(IdLine);
                        var ObjLine = ConvertStringToObj(TextStoredLine);
                        ObjLine.Display = 0;
                        SetStoredRE(IdLine, ObjLine);
                        console.log("[O-Table] : SR deleted successfully");
                    }
                }, true);
            } catch(err){
            }
            try {
                document.querySelectorAll('.RCButton')[i].addEventListener("click", function(event)                                                  { //attackbutton recycleurs
                    var RCRecycled = 1;
                    this.className += " BtnClicked";
                    var IdLine = this.parentNode.parentNode.id;
                    var TextStoredLine = GetStoredRE(IdLine);
                    var ObjLine = ConvertStringToObj(TextStoredLine);
                    ObjLine.RCRecycled = 1; //Mise en mémoire permettant de d'enregistrer en dur que le bouton a été cliqué
                    SetStoredRE(IdLine, ObjLine);
                    if ((GM_getValue('color3' + MetaLocal.Universe))) { //If de vérification de présence d'une donnée dans color3 (fonctionne comme les lignes paires et impaires dans la zone css
                        GM_addStyle("#RC" + IdLine + ".RCButton:visited, #RC" + IdLine + ".RCButton:active { background-color: #" + GM_getValue('color3' + MetaLocal.Universe) + ";}"); //Cette ligne CSS s'applique uniquement lorsque l'utilisateur clique sur le bouton et permet d'afficher sur le tableau que le bouton a été cliqué. Elle ne permet pas de mise ne mémoire et vu qu'à chaque rafraichissement, il faut recliquer sur le bouton pour l'activer, il n'y a pas de mise en mémoire des liens cliqués à proprement parler.
                    } else {
                        GM_addStyle("#RC" + IdLine + ".RCButton:visited, #RC" + IdLine + ".RCButton:active { background-color: #00ff00;}");
                    }
                }, true);
            } catch(err){
            }
            try {
                document.querySelectorAll('.PlayerCell')[i].addEventListener("click", function(event)                                                  { //send probes when you click on spy report player name
                    var IdLine = this.parentNode.id;
                    var TextStoredLine = GetStoredRE(IdLine);
                    var ObjLine = ConvertStringToObj(TextStoredLine);
                    ObjLine.Galaxie = ObjLine.CoordPlanete.split(":")[0];
                    ObjLine.System = ObjLine.CoordPlanete.split(":")[1];
                    ObjLine.Position = ObjLine.CoordPlanete.split(":")[2];
                    sendShipsWithPopup(6,ObjLine.Galaxie,ObjLine.System,ObjLine.Position,ObjLine.Moon,0);
                    GM_addStyle("#PL" + IdLine + ", #PL" + IdLine + ":hover  {text-decoration:underline; color:#FFBF00}");
                    setTimeout(function() { GM_addStyle("#PL" + IdLine + " { text-decoration:initial;}"); GM_addStyle("#PL" + IdLine + ":hover { text-decoration:underline;}"); PlayerColor(ObjLine);}, 1000); //Recolorie l'âge dans ses paramètres d'origine, d'origine //put back age to its original settings, helps the user to know when it's the best time to launch probes again (avoid spy errors)
                }, true);
            } catch(err){
            }
        }
        NbItemsDisplayed = 0; //Réinitialisation de cette variable, sinon le montant s'additionne à l'ancien et ça génère des erreurs sur les boutons attaque GT, PT et sur le bouton supprimer de chaque RE. Ces erreurs empêchent de pouvoir trier le tableau une seconde fois ou de trier lorsque l'on affiche le tableau sur une autre page de message.
        //Boutons d'entête du tableau (boutons permettant de trier le tableau par renta, par pseudo, ou autre)
        for (var j=0; j < NbColumnsDisplayed; j++){
                try {
                    document.querySelectorAll('.FirstLine')[j].addEventListener("click", function(event)                                                  {
                        var PairImpair = 1; //Variable permettant de faire un tri dans un ordre ou dans l'autre
                        if (GM_getValue('PairImpair' + MetaLocal.Universe)) {
                            PairImpair = GM_getValue('PairImpair' + MetaLocal.Universe);
                        }
                        TriDone = 1;
                        GM_addStyle("#" + currentSort + ", #" + currentID + " {color: #848484 !important; background-color: #000000 !important;} "); //Reset old selected line to default color
                        currentID = this.id;
                        //alert(currentID);
                        var TableauRESec = MsgBoard();
                        //tri d'un sens ou d'un autre (en fonction de PairImpair)
                        if (PairImpair % 2 === 0) {
                                if ((GM_getValue('color14' + MetaLocal.Universe))) {//Colorize selected line to sort the board
                                    GM_addStyle("#" + currentID + " { color: #" + GM_getValue('color14' + MetaLocal.Universe) + "!important; background-color: #151515 !important;} ");
                                } else {
                                    GM_addStyle("#" + currentID + " {color: #00FF00 !important; background-color: #151515 !important;} ");
                                }
                            TableauRESec.sort(function (a,b) {
                                if (a[currentID] < b[currentID])
                                    return 1;
                                if (a[currentID] > b[currentID])
                                    return -1;
                                return 0;
                            });
                        } else {
                            if ((GM_getValue('color15' + MetaLocal.Universe))) {//Colorize selected line to sort the board
                                GM_addStyle("#" + currentID + " { color: #" + GM_getValue('color15' + MetaLocal.Universe) + "!important; background-color: #151515 !important;} ");
                            } else {
                                GM_addStyle("#" + currentID + " {color: #FF3010 !important; background-color: #151515 !important;} ");
                            }
                            TableauRESec.sort(function (a,b) {
                                if (a[currentID] > b[currentID])
                                    return 1;
                                if (a[currentID] < b[currentID])
                                    return -1;
                                return 0;
                            });
                        }
                        PairImpair = PairImpair + 1;
                        GM_setValue('PairImpair' + MetaLocal.Universe, PairImpair);
                        InitialisationTableau(TableauRESec,DisplayWhat);
                    }, true);
                } catch(err) {
                }
        }
    } //Fin du if qui vérifie la présence d'un message
    var EndExec = new Date().getTime();
    var TimeExec = EndExec - StartExec;
    console.log('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXECUTION DISPLAY TIME : ' + TimeExec + 'ms    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
}//Fin de la fonction


//Fonction de création du tableau HTML
function CreateBoardHTML(DatasMsg,DisplayWhat) //mettre un second attribut qui définira si la création concerne la corbeille ou le vrai tableau *-*
{
    console.log("[O-Table] : Begin of CreateBoardHTML function");
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers
    //Toutes les variables ci dessous récupèrent les options dans la partie "affichage des colonnes" des options (fonction OptionsButton)


    var TextTravelTime = Langue.RETimeTravel.split("|||")[LangueIndex];
    var TextColProfitsHr = Langue.RELootHour.split("|||")[LangueIndex];
    var USMHr = ''; //Helps to define profits per hour USM id line in the board
    var DisplayCoorsdToTravel = false; //Debug column, not activable with script options. Put this variable to true to activate the column.
    var MetaLocal = MetaDatas();
    //
    /////////////////////////////START/////////////GETTING USER SELECTED COLUMN DISPLAYED//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    if (GM_getValue('column0' + MetaLocal.Universe) === false || GM_getValue('column0' + MetaLocal.Universe) === true) { //DisplayLeftLine
        var DisplayLeftLine = GM_getValue('column0' + MetaLocal.Universe);
    } else {
        var DisplayLeftLine = true; //Default value if no data has been found
    }
    if (GM_getValue('column1' + MetaLocal.Universe) === false || GM_getValue('column1' + MetaLocal.Universe) === true) { //DisplayRightLine
        var DisplayRightLine = GM_getValue('column1' + MetaLocal.Universe);
    } else {
        var DisplayRightLine = false;//Default value if no data has been found
    }
    if (GM_getValue('column2' + MetaLocal.Universe) === false || GM_getValue('column2' + MetaLocal.Universe) === true) { //DisplayCoord
        var DisplayCoord = GM_getValue('column2' + MetaLocal.Universe);
    } else {
        var DisplayCoord = true;   //Default value if no data has been found
    }
    if (GM_getValue('column3' + MetaLocal.Universe) === false || GM_getValue('column3' + MetaLocal.Universe) === true) { //DisplayMetal
        var DisplayMetal = GM_getValue('column3' + MetaLocal.Universe);
    } else {
        var DisplayMetal = false;//Default value if no data has been found
    }
    if (GM_getValue('column4' + MetaLocal.Universe) === false || GM_getValue('column4' + MetaLocal.Universe) === true) { //DisplayCristal
        var DisplayCristal = GM_getValue('column4' + MetaLocal.Universe);
    } else {
        var DisplayCristal = false;//Default value if no data has been found
    }
    if (GM_getValue('column5' + MetaLocal.Universe) === false || GM_getValue('column5' + MetaLocal.Universe) === true) { //DisplayDeut
        var DisplayDeut = GM_getValue('column5' + MetaLocal.Universe);
    } else {
        var DisplayDeut = false;//Default value if no data has been found
    }
    if (GM_getValue('column6' + MetaLocal.Universe) === false || GM_getValue('column6' + MetaLocal.Universe) === true) { //DisplayTotal
        var DisplayTotal = GM_getValue('column6' + MetaLocal.Universe);
    } else {
        var DisplayTotal = false;//Default value if no data has been found
    }
    if (GM_getValue('column7' + MetaLocal.Universe) === false || GM_getValue('column7' + MetaLocal.Universe) === true) { //DisplayButinRatio
        var DisplayButinRatio = GM_getValue('column7' + MetaLocal.Universe);
    } else {
        var DisplayButinRatio = false;//Default value if no data has been found
    }
    if (GM_getValue('column8' + MetaLocal.Universe) === false || GM_getValue('column8' + MetaLocal.Universe) === true) { //DisplayFlotte
        var DisplayFlotte = GM_getValue('column8' + MetaLocal.Universe);
    } else {
        var DisplayFlotte = true;//Default value if no data has been found
    }
    if (GM_getValue('column9' + MetaLocal.Universe) === false || GM_getValue('column9' + MetaLocal.Universe) === true) { //DisplayDefense
        var DisplayDefense = GM_getValue('column9' + MetaLocal.Universe);
    } else {
        var DisplayDefense = true;//Default value if no data has been found
    }
    if (GM_getValue('column10' + MetaLocal.Universe) === false || GM_getValue('column10' + MetaLocal.Universe) === true) { //DisplayLoot
        var DisplayLoot = GM_getValue('column10' + MetaLocal.Universe);
    } else {
        var DisplayLoot = true;//Default value if no data has been found
    }
    if (GM_getValue('column23' + MetaLocal.Universe) === false || GM_getValue('column23' + MetaLocal.Universe) === true) { //DisplayLootUSM
        var DisplayLootUSM = GM_getValue('column23' + MetaLocal.Universe);
    } else {
        var DisplayLootUSM = false;//Default value if no data has been found
    }
    if (GM_getValue('column11' + MetaLocal.Universe) === false || GM_getValue('column11' + MetaLocal.Universe) === true) { //DisplayPlayer
        var DisplayPlayer = GM_getValue('column11' + MetaLocal.Universe);
    } else {
        var DisplayPlayer = true;//Default value if no data has been found
    }
    if (GM_getValue('column12' + MetaLocal.Universe) === false || GM_getValue('column12' + MetaLocal.Universe) === true) { //DisplayLinkPT
        var DisplayLinkPT = GM_getValue('column12' + MetaLocal.Universe);
    } else {
        var DisplayLinkPT = true;//Default value if no data has been found
    }
    if (GM_getValue('column13' + MetaLocal.Universe) === false || GM_getValue('column13' + MetaLocal.Universe) === true) { //DisplayLinkGT
        var DisplayLinkGT = GM_getValue('column13' + MetaLocal.Universe);
    } else {
        var DisplayLinkGT = true;//Default value if no data has been found
    }
    if (GM_getValue('column25' + MetaLocal.Universe) === false || GM_getValue('column25' + MetaLocal.Universe) === true) { //DisplayLinkRC
        var DisplayLinkRC = GM_getValue('column25' + MetaLocal.Universe);
    } else {
        var DisplayLinkRC = true;//Default value if no data has been found
    }
    if (GM_getValue('column14' + MetaLocal.Universe) === false || GM_getValue('column14' + MetaLocal.Universe) === true) { //DisplayHour
        var DisplayHour = GM_getValue('column14' + MetaLocal.Universe);
    } else {
        var DisplayHour = true;//Default value if no data has been found
    }
    if (GM_getValue('column15' + MetaLocal.Universe) === false || GM_getValue('column15' + MetaLocal.Universe) === true) { //DisplayDelete
        var DisplayDelete = GM_getValue('column15' + MetaLocal.Universe);
    } else {
        var DisplayDelete = true;//Default value if no data has been found
    }
    if (GM_getValue('column16' + MetaLocal.Universe) === false || GM_getValue('column16' + MetaLocal.Universe) === true) { //DisplayMoreDetails
        var DisplayMoreDetails = GM_getValue('column16' + MetaLocal.Universe);
    } else {
        var DisplayMoreDetails = true;//Default value if no data has been found
    }
    if (GM_getValue('column26' + MetaLocal.Universe) === false || GM_getValue('column26' + MetaLocal.Universe) === true) { //DisplayTravelTime
        var DisplayTravelTime = GM_getValue('column26' + MetaLocal.Universe);
    } else {
        var DisplayTravelTime = false;//Default value if no data has been found
    }
    if (GM_getValue('column27' + MetaLocal.Universe) === false || GM_getValue('column27' + MetaLocal.Universe) === true) { //DisplayArrivalTime
        var DisplayArrivalTime = GM_getValue('column27' + MetaLocal.Universe);
    } else {
        var DisplayArrivalTime = false;//Default value if no data has been found
    }
    if (GM_getValue('column28' + MetaLocal.Universe) === false || GM_getValue('column28' + MetaLocal.Universe) === true) { //DisplayBackTime
        var DisplayBackTime = GM_getValue('column28' + MetaLocal.Universe);
    } else {
        var DisplayBackTime = false;//Default value if no data has been found
    }
    if (GM_getValue('column29' + MetaLocal.Universe) === false || GM_getValue('column29' + MetaLocal.Universe) === true) { //DisplayProfitsHour
        var DisplayProfitsHour = GM_getValue('column29' + MetaLocal.Universe);
    } else {
        var DisplayProfitsHour = false;//Default value if no data has been found
    }
    if (GM_getValue('column31' + MetaLocal.Universe) === false || GM_getValue('column31' + MetaLocal.Universe) === true) { //DisplayMissiles
        var DisplayMissiles = GM_getValue('column31' + MetaLocal.Universe);
    } else {
        var DisplayMissiles = false;//Default value if no data has been found
    }
    /////////////////////////////END/////////////GETTING USER SELECTED COLUMN DISPLAYED////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////
    //To know the line title of travel time
    if (GM_getValue('radio0' + MetaLocal.Universe) === true) {
        TextTravelTime = Langue.RETimeTravel.split("|||")[LangueIndex]
    } else {
        if (GM_getValue('radio1' + MetaLocal.Universe) === true) {
            TextTravelTime = Langue.RETimeTravelAR.split("|||")[LangueIndex]
        }
    }

    //To know the COLOR of ATTACK and RECYCLE BUTTONS once clicked and page refreshed (color4 in options) :
    if ((GM_getValue('color4' + MetaLocal.Universe))) {
        GM_addStyle(".BtnClicked:link { background-color: #" + GM_getValue('color4' + MetaLocal.Universe) + ";}");
    } else {
        GM_addStyle(".BtnClicked:link { background-color: #ff0000;}");
    }
    //To know the line title of profits/hour column
    if (GM_getValue('radio10' + MetaLocal.Universe) === true) { //standard
        TextColProfitsHr = Langue.RELootHour.split("|||")[LangueIndex] + '<br />' + Langue.Brut.split("|||")[LangueIndex];
    } else {
        if (GM_getValue('radio11' + MetaLocal.Universe) === true) { //MSU
            TextColProfitsHr = Langue.RELootHour.split("|||")[LangueIndex] + '<br />' + Langue.USM.split("|||")[LangueIndex];
                USMHr = "USM";
            }
        }

    ///////////////////////////////////////////////

    NbColumnsDisplayed = (DisplayLeftLine+DisplayRightLine+DisplayCoord+DisplayMetal+DisplayCristal+DisplayDeut+DisplayTotal+DisplayButinRatio+DisplayFlotte+DisplayDefense+DisplayLoot+DisplayLootUSM+DisplayPlayer+DisplayLinkPT+DisplayLinkGT+DisplayHour+DisplayDelete+DisplayMoreDetails+DisplayTravelTime+DisplayArrivalTime+DisplayBackTime+DisplayProfitsHour);
    //alert(DisplayLeftLine+'.'+DisplayRightLine+'.'+DisplayCoord+'.'+DisplayMetal+'.'+DisplayCristal+'.'+DisplayDeut+'.'+DisplayTotal+'.'+DisplayButinRatio+'.'+DisplayFlotte+'.'+DisplayDefense+'.'+DisplayLoot+'.'+DisplayLootUSM+'.'+DisplayPlayer+'.'+DisplayLinkPT+'.'+DisplayLinkGT+'.'+DisplayHour+'.'+DisplayDelete+'.'+DisplayMoreDetails+'.'+DisplayTravelTime+'.'+DisplayArrivalTime+'.'+DisplayBackTime+'.'+DisplayProfitsHour);
    if (isNaN(NbColumnsDisplayed) === true) { //This is to avoid migration issues (when NbColumnsDisplayed is NotaNumber, it's impossible to sort the board by the head)
        NbColumnsDisplayed = 100;//Used to avoid crashes, shouldn't be used anymore with O-Table 0.15.0
        console.log("[O-Table] : CreateBoardHTML : NbColumnsDisplayed was returning NaN, value has been set to 100");
    }
    //Récupération de la valeur choisie par l'utilisateur pour le non affichage des lignes selon certains critères
    if (GM_getValue('text5' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée --------------- FLOTTE
        var FlotteMaxi = parseInt(GM_getValue('text5' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var FlotteMaxi = 999999999999;
    }
    if (GM_getValue('text6' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- DEFENSE
        var DefenseMaxi = parseInt(GM_getValue('text6' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var DefenseMaxi = 999999999999;
    }
    if (GM_getValue('text7' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- AGE
        var AgeMaxi = parseInt(GM_getValue('text7' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var AgeMaxi = 999;
    }
    if (GM_getValue('text28' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- MINIMAL AMOUNT OF RESOURCES
        var RessMin = parseInt(GM_getValue('text28' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var RessMin = 0;
    }
    //To know if the user want to combine resources or just resources (used for the feature "hide a spy report if resources are less than....")
    //Used to get the propriety name to use to compare spy reports
    var ResOrResCDR = 'Loot';
    if (GM_getValue('radio12' + MetaLocal.Universe) === true) { //only resources selected
        if (GM_getValue('radio14' + MetaLocal.Universe) === true) { //Standard resources
            ResOrResCDR = 'Loot';
        } else {
            if (GM_getValue('radio15' + MetaLocal.Universe) === true) { //MSU resources
                ResOrResCDR = 'USMPille';
            }
        }
    } else {
        if (GM_getValue('radio13' + MetaLocal.Universe) === true) { //resources + debris field
            if (GM_getValue('radio14' + MetaLocal.Universe) === true) { //Standard resources
                ResOrResCDR = 'TotalCDRRes';
            } else {
                if (GM_getValue('radio15' + MetaLocal.Universe) === true) { //MSU resources
                    ResOrResCDR = 'TotalCDRResUSM';
                }
            }
        }
    }
    //Get user option choice to choose between standard / msu resources on "Display a spy report if it's profitable after sending missiles"
    var MIP_Profits_StdMSU = 'LootMIP';
    if (GM_getValue('radio16' + MetaLocal.Universe) === true) { //Standard resources
        MIP_Profits_StdMSU = 'LootMIP';
    } else {
        if (GM_getValue('radio17' + MetaLocal.Universe) === true) { //MSU resources
            MIP_Profits_StdMSU = 'USMPilleMIP';
        }
    }
    //Récupération du choix utilisateur pour : ouvrir les attaques dans un nouvel onglet
    if (GM_getValue('column20' + MetaLocal.Universe) === false) {
        var NewOnglet = '';
    } else {
        var NewOnglet = 'target="_blank"';
    }
    //Récupération du choix utilisateur pour la taille du texte et application d'un style CSS //get user choice for text size and applies CSS style
    if (GM_getValue('DropDown2' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- AGE
        var TextSize = parseInt(GM_getValue('DropDown2' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var TextSize = 100;
    }
    GM_addStyle(".InfosVague { font-size: " + TextSize + "%;  } ");

    //get user setting for max amount of line to keep on the table
    if (GM_getValue('text33' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- MAX AMOUNT OF LINES TO KEEP
        var MaxLines = parseInt(GM_getValue('text33' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var MaxLines = 999;
    }
    var CountLines = 0; // to count the amount of lines on the table

    var NbItems = DatasMsg.length;
    console.log("[O-Table] : Amount of stored spy reports (+secondary waves) : " + NbItems);
    //alert(DisplayMoreDetails);
    //alert(NbItems + ' items html à créer');
    var PT = "PT";
    var GT = "GT";
    var NumeroLigneDisplayed = 0; //Numéro de ligne affiché sur le tableau
    var ColumnTravelTimeTitle = '';
    var ColumnTravelTime = '';

    //console.log("[O-Table] : DisplayPlayer = " + DisplayPlayer);
    //Première ligne du tableau
    var Board = '<div class ="InfosVague"><table class ="TableauRaid">' +
        DisplayColumn(DisplayLeftLine,       '<th class ="FirstLine" id="Id">' + Langue.RELine.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayCoord,          '<th class ="FirstLine" id="RawCoord">' + Langue.RECoords.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayPlayer,         '<th class ="FirstLine" id="PlayerMin">(<span style="color:#ff8080">Act</span>) ' + Langue.REPlayer.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(DisplayHour,           '<th class ="FirstLine" id="AgeSec">' + Langue.REAge.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(DisplayTravelTime,     '<th class ="FirstLine" id="TempsTrajetPT">' + TextTravelTime + '</th>')+
        DisplayColumn(DisplayArrivalTime,    '<th class ="FirstLine" id="HeureArriveePTRaw">' + Langue.HeureArrivee.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(DisplayBackTime,       '<th class ="FirstLine" id="HeureRetourPTRaw">' + Langue.HeureRetour.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(DisplayMetal,          '<th class ="FirstLine" id="MetalPille">' + Langue.REMetal.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(DisplayCristal,        '<th class ="FirstLine" id="CristalPille">' + Langue.RECristal.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayDeut,           '<th class ="FirstLine" id="DeuteriumPille">' + Langue.REDeut.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayTotal,          '<th class ="FirstLine" id="Total">' + Langue.RETotal.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayLoot,           '<th class ="FirstLine" id="Loot">' + Langue.RELoot.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayLootUSM,        '<th class ="FirstLine" id="USMPille">' + Langue.RELootUSM.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayProfitsHour,    '<th class ="FirstLine" id="ProfitsPerHour' + USMHr + '">' + TextColProfitsHr + '</th>') +
        DisplayColumn(DisplayButinRatio,     '<th class ="FirstLine" id="Butin">' + Langue.REButinRatio.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayFlotte,         '<th class ="FirstLine" id="FlotteFinal">' + Langue.REFlotte.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayDefense,        '<th class ="FirstLine" id="DefenseFinal">' + Langue.REDefense.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayMissiles,       '<th class ="FirstLine" id="MIP">' + Langue.Missiles.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayLinkPT,         '<th class ="FirstLine" id="NbPT">' + Langue.PT.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayLinkGT,         '<th class ="FirstLine" id="NbGT">' + Langue.GT.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayLinkRC,         '<th class ="FirstLine" id="TotalRC">' + Langue.RC.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayMoreDetails,    '<th class ="FirstLine"></th>') +
        DisplayColumn(DisplayDelete,         '<th class ="FirstLine"></th>') +
        DisplayColumn(DisplayRightLine,      '<th class ="FirstLine" id="Id">' + Langue.RELine.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(DisplayCoorsdToTravel, '<th class ="FirstLine" id="Id"> Travelled coords </th>');//DEBUG LINE, not activable via options. To activate it, put a true in "DisplayCoorsdToTravel"
    // Données du tableau
    for (var j = 0; j < NbItems; j++){
        //console.log("[O-Table] : Checking recorded spy report n°" + j + ", Coord is " + DatasMsg[j].CoordPlanete + ", Player " + DatasMsg[j].Player);
        if (CountLines < MaxLines) {
            if (DatasMsg[j].Display == DisplayWhat) { //remplacer le 1 par une variable envoyée sur la fonction (lorque l'on affiche la corbeille, display doit être à 0 et lorsque l'on affiche le tableau standard, display doit être à 1
                if (DatasMsg[j].FlotteFinal <= FlotteMaxi || DatasMsg[j][MIP_Profits_StdMSU] > 0) { //Vérifie si la flotte du RE est inférieur au montant maximum souhaité par l'utilisateur
                    if (DatasMsg[j].DefenseFinal <= DefenseMaxi || DatasMsg[j][MIP_Profits_StdMSU] > 0) {//Vérifie si la défense du RE est inférieur au montant maximum souhaité par l'utilisateur
                        if (DatasMsg[j].AgeSec <= (AgeMaxi*3600)) { //Vérifie si l'âge du RE est inférieur au montant maximum souhaité par l'utilisateur
                            if (DatasMsg[j][ResOrResCDR] >= (RessMin)) { //Checks if the spy reports has more resources than the minimum wished by user (default value is 0, standard resources without debris field --> Loot)
                                NumeroLigneDisplayed = NumeroLigneDisplayed + 1;
                                NbItemsDisplayed = NbItemsDisplayed + 1;
//TITLES//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                var Column_FleetTitle = '<FONT color=#FF8F35>' + Langue.Simuler.split("|||")[LangueIndex] + '</FONT><br />' + Langue.RECDR.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].CDRFlotteDisplayed + '<br />' + Langue.RatioCDRFlotte.split("|||")[LangueIndex] + ' : ' + MetaLocal.TxCDRFleet + '% <br />' + Langue.Recycleurs.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].CDRFlotteRCDisplayed;
                                var Column_DefTitle =   '<FONT color=#FF8F35>' + Langue.Simuler.split("|||")[LangueIndex] + '</FONT><br />' + Langue.RECDR.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].CDRDefenseDisplayed + '<br />' + Langue.RatioCDRDefense.split("|||")[LangueIndex] + ' : ' + MetaLocal.TxCDRDef + '% <br />' + Langue.Recycleurs.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].CDRDefenseRCDisplayed;
                                var Column_LootTitle =  '[' + DatasMsg[j].MetalPilleDisplayed + ' <FONT color=#FF8F35> ' + Langue.REMetal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + DatasMsg[j].CristalPilleDisplayed + ' <FONT color=#00A0B6> ' + Langue.RECristal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + DatasMsg[j].DeuteriumPilleDisplayed + ' <FONT color=#2F8900> ' + Langue.REDeut.split("|||")[LangueIndex] + '</FONT>]';
                                var Column_PlayerTitle = Langue.Sonder.split("|||")[LangueIndex];
                                var Column_MIPTitle = '<FONT color=#FF8F35>' + Langue.Simuler.split("|||")[LangueIndex] + '</FONT><br />' + Langue.Couts.split("|||")[LangueIndex] + ' : <br />[' + DatasMsg[j].MIPMDisplayed + ' <FONT color=#FF8F35> ' + Langue.REMetal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + DatasMsg[j].MIPCDisplayed + ' <FONT color=#00A0B6> ' + Langue.RECristal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + DatasMsg[j].MIPDDisplayed + ' <FONT color=#2F8900> ' + Langue.REDeut.split("|||")[LangueIndex] + '</FONT>]';
                                var Column_PTTitle = Langue.PT.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].NbPTDisplayed;
                                var Column_GTTitle = Langue.GT.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].NbGTDisplayed;
//BEGIN SPY REPORT TABLE/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            var Row =DisplayColumn(DisplayLeftLine,      '<td class ="InsideBoard Line tooltipRight" ' + DatasMsg[j].LineColor +  NumeroLigneDisplayed + '</font></td>') + //Si il n'y a pas de crochet > au bout du TD, c'est car il est inclus dans la propriété LineColor
                                DisplayColumn(DisplayCoord,              '<td class ="InsideBoard Coord ">' + '<a class="CoordLink ' + DatasMsg[j].CoordPlanete_Colored + '" href="' + DatasMsg[j].LienGalaxie + '">' + DatasMsg[j].CoordPlanete + " " + DatasMsg[j].Moon + '</a></td>') +
                                DisplayColumn(DisplayPlayer,             '<td class ="InsideBoard PlayerCell tooltipRight" style="font-size: ' + (TextSize - 10) + '% !important;" title="' + Column_PlayerTitle + '">' + DatasMsg[j].Activite + '<div style="display:inline" id="PL' + DatasMsg[j].Id + '">' + DatasMsg[j].Player + '</div>' + DatasMsg[j].PlayerIcon + '</td>') +
                                DisplayColumn(DisplayHour,               '<td class ="InsideBoard" id="AGE' + DatasMsg[j].Id + '">' + DatasMsg[j].AgeDisplayed + '</td>') +
                                DisplayColumn(DisplayTravelTime,         '<td class ="InsideBoard tooltipRight" id="TRAVTIME' + DatasMsg[j].Id + '" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].TempsTrajetDisplayed + '</td>') +
                                DisplayColumn(DisplayArrivalTime,        '<td class ="InsideBoard tooltipRight" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].HeureArriveeDisplayed.split(" ")[1] + '</td>') +
                                DisplayColumn(DisplayBackTime,           '<td class ="InsideBoard tooltipRight" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].HeureRetourDisplayed.split(" ")[1] + '</td>') +
                                DisplayColumn(DisplayMetal,              '<td class ="InsideBoard" style="font-size: ' + (TextSize - 10) + '% !important;">' + DatasMsg[j].MetalPilleDisplayed + '</td>') +
                                DisplayColumn(DisplayCristal,            '<td class ="InsideBoard" style="font-size: ' + (TextSize - 10) + '% !important;">' + DatasMsg[j].CristalPilleDisplayed + '</td>') +
                                DisplayColumn(DisplayDeut,               '<td class ="InsideBoard" style="font-size: ' + (TextSize - 10) + '% !important;">' + DatasMsg[j].DeuteriumPilleDisplayed + '</td>') +
                                DisplayColumn(DisplayTotal,              '<td class ="InsideBoard">' + DatasMsg[j].TotalDisplayed + '</td>') +
                                DisplayColumn(DisplayLoot,               '<td class ="InsideBoard tooltipRight" id="LOOT' + DatasMsg[j].Id + '" title="' + Column_LootTitle + '">' + DatasMsg[j].LootDisplayed + '</td>') +
                                DisplayColumn(DisplayLootUSM,            '<td class ="InsideBoard tooltipRight" id="LOOTUSM' + DatasMsg[j].Id + '" title="' + Column_LootTitle + '">' + DatasMsg[j].USMPilleDisplayed + '</td>') +
                                DisplayColumn(DisplayProfitsHour,        '<td class ="InsideBoard tooltipRight" id="PH' + DatasMsg[j].Id + '" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].ProfitsPerHourDisplayed + '</td>') +
                                DisplayColumn(DisplayButinRatio,         '<td class ="InsideBoard">' + DatasMsg[j].Butin + '</td>') +
                                DisplayColumn(DisplayFlotte,             '<td class ="InsideBoard tooltipRight" title="' + Column_FleetTitle + '"><a class="FltDefCtn" " href="' + DatasMsg[j].Simulation + '" target="_blank">' + DatasMsg[j].FlotteDisplayed + '</a></td>') +
                                DisplayColumn(DisplayDefense,            '<td class ="InsideBoard tooltipRight" title="' + Column_DefTitle + '"><a class="FltDefCtn" href="' + DatasMsg[j].Simulation + '" target="_blank">' + DatasMsg[j].DefenseDisplayed + '</a></td>') +
                                DisplayColumn(DisplayMissiles,           '<td class ="InsideBoard tooltipRight" title="' + Column_MIPTitle + '"><a class="FltDefCtn" href="' + DatasMsg[j].Simulation + '" target="_blank">' + DatasMsg[j].MIPDisplayed + '</a></td>') +
                                DisplayColumn(DisplayLinkPT,             '<td class ="InsideBoard">' + '<a id="PT' + DatasMsg[j].Id + '" class="AttackPTButton tooltipRight' + IsClicked(DatasMsg[j], "PT") + '" title="' + Column_PTTitle + '" href="' + DatasMsg[j].LienPT + '" ' + NewOnglet +  '></a></td>') + //use IsClicked function to attribute a css style depending on if user already clicked on the button or not
                                DisplayColumn(DisplayLinkGT,             '<td class ="InsideBoard">' + '<a id="GT' + DatasMsg[j].Id + '" class="AttackGTButton tooltipRight' + IsClicked(DatasMsg[j], "GT") + '" title="' + Column_GTTitle + '" href="' + DatasMsg[j].LienGT + '" ' + NewOnglet +  '></a></td>') +
                                DisplayColumn(DisplayLinkRC,             '<td class ="InsideBoard tooltipRight" title="' + Langue.Recycler.split("|||")[LangueIndex] + '">' + '<a id="RC' + DatasMsg[j].Id + '"class="RCButton' + IsClicked(DatasMsg[j], "RC") + '" href="' + DatasMsg[j].LienRC + '" ' + NewOnglet +  '></a></td>') +
                                DisplayColumn(DisplayMoreDetails,        '<td class ="InsideBoard"><a id="MoreDetails" class="overlay" href="' + DatasMsg[j].LienDetails + '"></a></td>');
                                if (DisplayWhat === 1) {
                                    Row = Row + DisplayColumn(DisplayDelete,   '<td class ="InsideBoard"><div id="DeleteA"></div>');
                                } else {
                                    Row = Row + DisplayColumn(DisplayDelete,   '<td class ="InsideBoard"><div id="UnDelete"></div>');
                                }
                    Row = Row + DisplayColumn(DisplayRightLine,          '<td class ="InsideBoard Line tooltipRight" ' + DatasMsg[j].LineColor +  NumeroLigneDisplayed + '</font></td>') +//Si il n'y a pas de crochet > au bout du TD, c'est car il est inclus dans la propriété LineColor
                                DisplayColumn(DisplayCoorsdToTravel,     '<td class ="InsideBoard Line ">' +  DatasMsg[j].Gtraversees + ':' + DatasMsg[j].SStraverses + ':' + DatasMsg[j].Postraversees + '</font></td>') +//DEBUG LINE, not activable via options. To activate it, put a true in "DisplayCoorsdToTravel"
                                '</tr>';
                                CountLines = CountLines + 1;
//END OF SPY REPORT TABLE/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                // Vérification de si la ligne est paire ou impaire et attribution du style CSS correspondant
                                if (NumeroLigneDisplayed % 2 === 0) {
                                    Board = Board +'<tr class ="TableLine Pair" id="' + DatasMsg[j].Id + '">' + Row; //Board, première partie du code + tr class paire ou impaire + Row (juste au dessus)

                                } else {
                                    Board = Board +'<tr class ="TableLine Impair" id="' + DatasMsg[j].Id + '">' + Row; //LIGNE A REMETTRE
                                }
                                //Colorisation des textes en fonction des options enregistrées par l'utilisateur (il y a d'abord une vérification de l'enregistrement puis une vérification de si le chiffre est plus important que celui enregistré) Attention : la colorisation aura lieu seulement si l'utilisateur a défni le seuil + la couleur
                                PlayerColor(DatasMsg[j]);
                            }
                        }
                    }
                }
            }
        }
    }
    Board = Board + '</table></div>';
    //alert(Board);
    console.log("[O-Table] : Amount of displayed spy reports : " + NbItemsDisplayed);
    console.log("[O-Table] : HTML creation has been made sucessfully :)");
    return Board;
}

//Fonction de vérification de si un bouton attaquer ou recycler à déja été cliqué auparavant
function IsClicked(DatasMsg, PTorGTorRC)
{
    switch(PTorGTorRC) {
        case "PT":
            if (DatasMsg.PTAttacked == 1) {
                return " BtnClicked";
            } else {
                return "";
            }
            break;
        case "GT":
            if (DatasMsg.GTAttacked == 1) {
                return " BtnClicked";
            } else {
                return "";
            }
            break;
        case "RC":
            if (DatasMsg.RCRecycled == 1) {
                return " BtnClicked";
            } else {
                return "";
            }
            break;
    }
}


//Fonction d'affichage des colonnes
function DisplayColumn(YesNo, Content)
{
    var FinalContent;
    if (YesNo === true) {
        FinalContent = Content;
    } else {
        FinalContent = '';
    }
   return FinalContent;
}



function InfoDatasBoard(DatasMsg,DisplayWhat)
{

    GM_addStyle(".TableauInfos { border: 1px solid #555; text-align: center; width: 100%; margin-top: 15px  } ");
    GM_addStyle(".thTableauInfos { border-left: 1px solid #222; height : 25px;} ");
    GM_addStyle(".LigneInfoBoard { border-left: 1px solid #222;} ");

    var i,j,k; //Calcul du nombre de PT, GT, de la renta totale
    var l,m,n = 0;
    var FirstWaveSumPT = 0;
    var SecondWaveSumPT = 0;
    var ThirdWaveSumPT = 0;
    var FirstWaveSumGT = 0;
    var SecondWaveSumGT = 0;
    var ThirdWaveSumGT = 0;
    var FirstWaveSumLOOT = 0;
    var SecondWaveSumLOOT = 0;
    var ThirdWaveSumLOOT = 0;
    var FirstWaveSumUSM = 0;
    var SecondWaveSumUSM = 0;
    var ThirdWaveSumUSM = 0;
    var FirstWaveSumPerHour = 0;
    var SecondWaveSumPerHour = 0;
    var ThirdWaveSumPerHour = 0;
    var FirstWaveSumPerHourUSM = 0;
    var SecondWaveSumPerHourUSM = 0;
    var ThirdWaveSumPerHourUSM = 0;
    var FirstWaveRatio = 0;
    var SecondWaveRatio = 0;
    var ThirdWaveRatio = 0;
    var MoyFirstWave = 0;
    var MoyScndWave = 0;
    var MoyThirWave = 0;
    var MoyUSMFirstWave = 0;
    var MoyUSMScndWave = 0;
    var MoyUSMThirWave = 0;
    var FirstWaveSumMetal = 0;
    var SecondWaveSumMetal = 0;
    var ThirdWaveSumMetal = 0;
    var FirstWaveSumCristal = 0;
    var SecondWaveSumCristal = 0;
    var ThirdWaveSumCristal = 0;
    var FirstWaveSumDeuterium = 0;
    var SecondWaveSumDeuterium = 0;
    var ThirdWaveSumDeuterium = 0;
    var MoyFirstWavePerHour = 0;
    var MoyFirstWavePerHour_USM = 0;
    var MoySecondWavePerHour = 0;
    var MoySecondWavePerHour_USM = 0;
    var MoyThirdWavePerHour = 0;
    var MoyThirdWavePerHour_USM = 0;
    var Msg = 0;
    var MetaLocal = MetaDatas();
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers
    console.log("[O-Table] : Generating information Table...");

    //Récupération de la valeur choisie par l'utilisateur pour le non affichage des lignes selon certains critères
    if (GM_getValue('text5' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée --------------- FLOTTE
        var FlotteMaxi = parseInt(GM_getValue('text5' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var FlotteMaxi = 999999999999;
    }
    if (GM_getValue('text6' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- DEFENSE
        var DefenseMaxi = parseInt(GM_getValue('text6' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var DefenseMaxi = 999999999999;
    }
    if (GM_getValue('text7' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- AGE
        var AgeMaxi = parseInt(GM_getValue('text7' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var AgeMaxi = 999;
    }
    if (GM_getValue('text28' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- MINIMAL AMOUNT OF RESOURCES
        var RessMin = parseInt(GM_getValue('text28' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var RessMin = 0;
    }
    if (GM_getValue('text18' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- Nombre de slots par vague
        var NbSlots = parseInt(GM_getValue('text18' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var NbSlots = 20;
    }
    if (GM_getValue('column24' + MetaLocal.Universe) === false || GM_getValue('column24' + MetaLocal.Universe) === true) { //Display or show MSU profits line
        var DisplayUSM = GM_getValue('column24' + MetaLocal.Universe);
    } else {
        var DisplayUSM = false;
    }
    if (GM_getValue('column36' + MetaLocal.Universe) === false || GM_getValue('column36' + MetaLocal.Universe) === true) { //Display or show ships per wave line
        var DisplayShipsWave = GM_getValue('column36' + MetaLocal.Universe);
    } else {
        var DisplayShipsWave = true;
    }
    if (GM_getValue('column37' + MetaLocal.Universe) === false || GM_getValue('column37' + MetaLocal.Universe) === true) { //Display or show raw profits for the wave line
        var DisplayRawProfits = GM_getValue('column37' + MetaLocal.Universe);
    } else {
        var DisplayRawProfits = true;
    }
    if (GM_getValue('column38' + MetaLocal.Universe) === false || GM_getValue('column38' + MetaLocal.Universe) === true) { //Display or show average profit per slot line
        var DisplayAvgProfits = GM_getValue('column38' + MetaLocal.Universe);
    } else {
        var DisplayAvgProfits = true;
    }
    if (GM_getValue('column39' + MetaLocal.Universe) === false || GM_getValue('column39' + MetaLocal.Universe) === true) { //Display or show average msu profits line
        var DisplayAvgMSUProfits = GM_getValue('column39' + MetaLocal.Universe);
    } else {
        var DisplayAvgMSUProfits = false;
    }
    if (GM_getValue('column40' + MetaLocal.Universe) === false || GM_getValue('column40' + MetaLocal.Universe) === true) { //Display or show profits per hour line
        var DisplayProfitsPerHour = GM_getValue('column40' + MetaLocal.Universe);
    } else {
        var DisplayProfitsPerHour = false;
    }
    if (GM_getValue('column41' + MetaLocal.Universe) === false || GM_getValue('column41' + MetaLocal.Universe) === true) { //Display or show msu profits per hour line
        var DisplayMSUProfitsPerHour = GM_getValue('column41' + MetaLocal.Universe);
    } else {
        var DisplayMSUProfitsPerHour = false;
    }
    if (GM_getValue('column42' + MetaLocal.Universe) === false || GM_getValue('column42' + MetaLocal.Universe) === true) { //Display or show msu vs raw ratio  line
        var MSUvsRAW = GM_getValue('column42' + MetaLocal.Universe);
    } else {
        var MSUvsRAW = false;
    }
    if (GM_getValue('column43' + MetaLocal.Universe) === false || GM_getValue('column43' + MetaLocal.Universe) === true) { //Display or show msu vs raw ratio  line
        var DisplayAvgProfitsPerHour = GM_getValue('column43' + MetaLocal.Universe);
    } else {
        var DisplayAvgProfitsPerHour = false;
    }
    if (GM_getValue('column44' + MetaLocal.Universe) === false || GM_getValue('column44' + MetaLocal.Universe) === true) { //Display or show msu vs raw ratio  line
        var DisplayAvgMSUProfitsPerHour = GM_getValue('column44' + MetaLocal.Universe);
    } else {
        var DisplayAvgMSUProfitsPerHour = false;
    }
    var PTorGTRawProfitsPerHour = 'ProfitsPerHour';//default value
    var PTorGTMSUProfitsPerHour = 'ProfitsPerHourUSM';//default value
    if (GM_getValue('radio21' + MetaLocal.Universe) === true) { //checks if heavy cargo is selected to compute profits per hour value
        PTorGTRawProfitsPerHour = 'ProfitsPerHour_GT';
    }
    if (GM_getValue('radio23' + MetaLocal.Universe) === true) { //checks if heavy cargo is selected to compute MSU profits per hour value
        PTorGTMSUProfitsPerHour = 'ProfitsPerHourUSM_GT';
    }
    //To know if the user want to combine resources or just resources (used for the feature "hide a spy report if resources are less than....")
    //Used to get the propriety name to use to compare spy reports
    var ResOrResCDR = 'Loot';
    if (GM_getValue('radio12' + MetaLocal.Universe) === true) { //only resources selected
        if (GM_getValue('radio14' + MetaLocal.Universe) === true) { //Standard resources
            ResOrResCDR = 'Loot';
        } else {
            if (GM_getValue('radio15' + MetaLocal.Universe) === true) { //MSU resources
                ResOrResCDR = 'USMPille';
            }
        }
    } else {
        if (GM_getValue('radio13' + MetaLocal.Universe) === true) { //resources + debris field
            if (GM_getValue('radio14' + MetaLocal.Universe) === true) { //Standard resources
                ResOrResCDR = 'TotalCDRRes';
            } else {
                if (GM_getValue('radio15' + MetaLocal.Universe) === true) { //MSU resources
                    ResOrResCDR = 'TotalCDRResUSM';
                }
            }
        }
    }
    //Get user option choice to choose between standard / msu resources on "Display a spy report if it's profitable after sending missiles"
    var MIP_Profits_StdMSU = 'LootMIP';
    if (GM_getValue('radio16' + MetaLocal.Universe) === true) { //Standard resources
        MIP_Profits_StdMSU = 'LootMIP';
    } else {
        if (GM_getValue('radio17' + MetaLocal.Universe) === true) { //MSU resources
            MIP_Profits_StdMSU = 'USMPilleMIP';
        }
    }
    //get user setting for max amount of line to keep on the table
    if (GM_getValue('text33' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- MAX AMOUNT OF LINES TO KEEP
        var MaxLines = parseInt(GM_getValue('text33' + MetaLocal.Universe));
    } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
        var MaxLines = 999;
    }
    var CountLines = 0; // to count the amount of lines on the table

    //-------------------------
    console.log("[O-Table] : Generating first wave in information Table...");
    for (i = 0; i < NbSlots; i) { //Collecte renta Première vague
        if (DatasMsg[Msg]) {
            if (CountLines < MaxLines) {
                if (DatasMsg[Msg].Display == DisplayWhat) { //remplacer le 1 par une variable envoyée sur la fonction (lorque l'on affiche la corbeille, display doit être à 0 et lorsque l'on affiche le tableau standard, display doit être à 1
                    if (DatasMsg[Msg].FlotteFinal <= FlotteMaxi || DatasMsg[Msg][MIP_Profits_StdMSU] > 0) { //Vérifie si la flotte du RE est inférieur au montant maximum souhaité par l'utilisateur
                        if (DatasMsg[Msg].DefenseFinal <= DefenseMaxi || DatasMsg[Msg][MIP_Profits_StdMSU] > 0) {//Vérifie si la défense du RE est inférieur au montant maximum souhaité par l'utilisateur
                            if (DatasMsg[Msg].AgeSec <= (AgeMaxi*3600)) { //Vérifie si l'âge du RE est inférieur au montant maximum souhaité par l'utilisateur
                                if (DatasMsg[Msg][ResOrResCDR] >= (RessMin)) { //Checks if the spy reports has more resources than the minimum wished by user (default value is 0, standard resources without debris field --> Loot)
                                    FirstWaveSumPT = FirstWaveSumPT + DatasMsg[Msg].NbPT;
                                    FirstWaveSumGT = FirstWaveSumGT + DatasMsg[Msg].NbGT;
                                    FirstWaveSumLOOT = FirstWaveSumLOOT + DatasMsg[Msg].Loot;
                                    FirstWaveSumUSM = FirstWaveSumUSM + DatasMsg[Msg].USMPille;
                                    FirstWaveSumMetal = FirstWaveSumMetal + DatasMsg[Msg].MetalPille;
                                    FirstWaveSumCristal = FirstWaveSumCristal + DatasMsg[Msg].CristalPille;
                                    FirstWaveSumDeuterium = FirstWaveSumDeuterium + DatasMsg[Msg].DeuteriumPille;
                                    FirstWaveSumPerHour = FirstWaveSumPerHour + DatasMsg[Msg][PTorGTRawProfitsPerHour];
                                    FirstWaveSumPerHourUSM = FirstWaveSumPerHourUSM + DatasMsg[Msg][PTorGTMSUProfitsPerHour];
                                    i = i + 1;
                                    CountLines = CountLines + 1;
                                }
                            }
                        }
                    }
                }
            }
            Msg = Msg + 1;
        }
        if (DatasMsg[Msg]) {
        } else {
            break;
        }
    }
    l = i;
    //Colorisation de la ligne de renta brute si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes raw profits for first wave if profits are higher than specified value
    if (GM_getValue('text4' + MetaLocal.Universe)) {
        if (FirstWaveSumLOOT > GM_getValue('text4' + MetaLocal.Universe)) {
            if (GM_getValue('color9' + MetaLocal.Universe)) {
                GM_addStyle("#RawAvg1 {color: #" + GM_getValue('color9' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta USM si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU profits for first wave if profits are higher than specified value
    if (GM_getValue('text29' + MetaLocal.Universe)) {
        if (FirstWaveSumUSM > GM_getValue('text29' + MetaLocal.Universe)) {
            if (GM_getValue('color18' + MetaLocal.Universe)) {
                GM_addStyle("#MSUAvg1 {color: #" + GM_getValue('color18' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta par heure brute si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes raw profits per hour for first wave if profits are higher than specified value
    if (GM_getValue('text30' + MetaLocal.Universe)) {
        if (FirstWaveSumPerHour > GM_getValue('text30' + MetaLocal.Universe)) {
            if (GM_getValue('color19' + MetaLocal.Universe)) {
                GM_addStyle("#RawHour1 {color: #" + GM_getValue('color19' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta par heure USM si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU profits per hour for first wave if profits are higher than specified value
    if (GM_getValue('text31' + MetaLocal.Universe)) {
        if (FirstWaveSumPerHourUSM > GM_getValue('text31' + MetaLocal.Universe)) {
            if (GM_getValue('color20' + MetaLocal.Universe)) {
                GM_addStyle("#MSUHour1 {color: #" + GM_getValue('color20' + MetaLocal.Universe) +";}");
            }
        }
    }
    MoyFirstWave = FirstWaveSumLOOT / i;
    MoyUSMFirstWave = FirstWaveSumUSM / i;
    MoyFirstWavePerHour = FirstWaveSumPerHour / i;
    MoyFirstWavePerHour_USM = FirstWaveSumPerHourUSM / i;
    FirstWaveRatio = MoyUSMFirstWave / MoyFirstWave;
    FirstWaveRatio = FirstWaveRatio.toFixed(3);
    //Colorisation de la ligne ratio USM/brut si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU/Raw ratio for first wave if profits are higher than specified value
    if (GM_getValue('text32' + MetaLocal.Universe)) {
        if (FirstWaveRatio > GM_getValue('text32' + MetaLocal.Universe)) {
            if (GM_getValue('color21' + MetaLocal.Universe)) {
                GM_addStyle("#MSURaw1 {color: #" + GM_getValue('color21' + MetaLocal.Universe) +";}");
            }
        }
    }

    //------------------------------------------------------------
    console.log("[O-Table] : Generating second wave in information Table...");
    for (j = 0; j < NbSlots; j) { //Collecte renta Seconde vague
        if (DatasMsg[Msg]) {
            if (CountLines < MaxLines) {
                if (DatasMsg[Msg].Display == DisplayWhat) { //remplacer le 1 par une variable envoyée sur la fonction (lorque l'on affiche la corbeille, display doit être à 0 et lorsque l'on affiche le tableau standard, display doit être à 1
                    if (DatasMsg[Msg].FlotteFinal <= FlotteMaxi || DatasMsg[Msg][MIP_Profits_StdMSU] > 0) { //Vérifie si la flotte du RE est inférieur au montant maximum souhaité par l'utilisateur
                        if (DatasMsg[Msg].DefenseFinal <= DefenseMaxi || DatasMsg[Msg][MIP_Profits_StdMSU] > 0) {//Vérifie si la défense du RE est inférieur au montant maximum souhaité par l'utilisateur
                            if (DatasMsg[Msg].AgeSec <= (AgeMaxi*3600)) { //Vérifie si l'âge du RE est inférieur au montant maximum souhaité par l'utilisateur
                                if (DatasMsg[Msg][ResOrResCDR] >= (RessMin)) { //Checks if the spy reports has more resources than the minimum wished by user (default value is 0, standard resources without debris field --> Loot)
                                    SecondWaveSumPT = SecondWaveSumPT + DatasMsg[Msg].NbPT;
                                    SecondWaveSumGT = SecondWaveSumGT + DatasMsg[Msg].NbGT;
                                    SecondWaveSumLOOT = SecondWaveSumLOOT + DatasMsg[Msg].Loot;
                                    SecondWaveSumUSM = SecondWaveSumUSM + DatasMsg[Msg].USMPille;
                                    SecondWaveSumMetal = SecondWaveSumMetal + DatasMsg[Msg].MetalPille;
                                    SecondWaveSumCristal = SecondWaveSumCristal + DatasMsg[Msg].CristalPille;
                                    SecondWaveSumDeuterium = SecondWaveSumDeuterium + DatasMsg[Msg].DeuteriumPille;
                                    SecondWaveSumPerHour = SecondWaveSumPerHour + DatasMsg[Msg][PTorGTRawProfitsPerHour];
                                    SecondWaveSumPerHourUSM = SecondWaveSumPerHourUSM + DatasMsg[Msg][PTorGTMSUProfitsPerHour];
                                    j = j + 1;
                                    CountLines = CountLines + 1;
                                }
                            }
                        }
                    }
                }
            }
            Msg = Msg + 1;
        }
        if (DatasMsg[Msg]) {
        } else {
            break;
        }
    }
    m = j;
    //Colorisation de la ligne de renta brute si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes raw profits for second wave if profits are higher than specified value
    if (GM_getValue('text4' + MetaLocal.Universe)) {
        if (SecondWaveSumLOOT > GM_getValue('text4' + MetaLocal.Universe)) {
            if (GM_getValue('color9' + MetaLocal.Universe)) {
                GM_addStyle("#RawAvg2 {color: #" + GM_getValue('color9' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta USM si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU profits for second wave if profits are higher than specified value
    if (GM_getValue('text29' + MetaLocal.Universe)) {
        if (SecondWaveSumUSM > GM_getValue('text29' + MetaLocal.Universe)) {
            if (GM_getValue('color18' + MetaLocal.Universe)) {
                GM_addStyle("#MSUAvg2 {color: #" + GM_getValue('color18' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta par heure brute si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes raw profits per hour for Second wave if profits are higher than specified value
    if (GM_getValue('text30' + MetaLocal.Universe)) {
        if (SecondWaveSumPerHour > GM_getValue('text30' + MetaLocal.Universe)) {
            if (GM_getValue('color19' + MetaLocal.Universe)) {
                GM_addStyle("#RawHour2 {color: #" + GM_getValue('color19' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta par heure USM si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU profits per hour for second wave if profits are higher than specified value
    if (GM_getValue('text31' + MetaLocal.Universe)) {
        if (SecondWaveSumPerHourUSM > GM_getValue('text31' + MetaLocal.Universe)) {
            if (GM_getValue('color20' + MetaLocal.Universe)) {
                GM_addStyle("#MSUHour2 {color: #" + GM_getValue('color20' + MetaLocal.Universe) +";}");
            }
        }
    }
    MoyScndWave = SecondWaveSumLOOT / j;
    MoyUSMScndWave = SecondWaveSumUSM / j;
    MoySecondWavePerHour = SecondWaveSumPerHour / j;
    MoySecondWavePerHour_USM = SecondWaveSumPerHourUSM / j;
    SecondWaveRatio = SecondWaveSumUSM / SecondWaveSumLOOT;
    SecondWaveRatio = SecondWaveRatio.toFixed(3);
        //Colorisation de la ligne ratio USM/brut si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU/Raw ratio for second wave if profits are higher than specified value
    if (GM_getValue('text32' + MetaLocal.Universe)) {
        if (SecondWaveRatio > GM_getValue('text32' + MetaLocal.Universe)) {
            if (GM_getValue('color21' + MetaLocal.Universe)) {
                GM_addStyle("#MSURaw2 {color: #" + GM_getValue('color21' + MetaLocal.Universe) +";}");
            }
        }
    }

    //---------------------
    console.log("[O-Table] : Generating third wave in information Table...");
    for (k = 0; k < NbSlots; k) { //Collecte renta Troisième vague
        if (DatasMsg[Msg]) {
            if (CountLines < MaxLines) {
                if (DatasMsg[Msg].Display == DisplayWhat) { //remplacer le 1 par une variable envoyée sur la fonction (lorque l'on affiche la corbeille, display doit être à 0 et lorsque l'on affiche le tableau standard, display doit être à 1
                    if (DatasMsg[Msg].FlotteFinal <= FlotteMaxi || DatasMsg[Msg][MIP_Profits_StdMSU] > 0) { //Vérifie si la flotte du RE est inférieur au montant maximum souhaité par l'utilisateur
                        if (DatasMsg[Msg].DefenseFinal <= DefenseMaxi || DatasMsg[Msg][MIP_Profits_StdMSU] > 0) {//Vérifie si la défense du RE est inférieur au montant maximum souhaité par l'utilisateur
                            if (DatasMsg[Msg].AgeSec <= (AgeMaxi*3600)) { //Vérifie si l'âge du RE est inférieur au montant maximum souhaité par l'utilisateur
                                if (DatasMsg[Msg][ResOrResCDR] >= (RessMin)) { //Checks if the spy reports has more resources than the minimum wished by user (default value is 0, standard resources without debris field --> Loot)
                                    ThirdWaveSumPT = ThirdWaveSumPT + DatasMsg[Msg].NbPT;
                                    ThirdWaveSumGT = ThirdWaveSumGT + DatasMsg[Msg].NbGT;
                                    ThirdWaveSumLOOT = ThirdWaveSumLOOT + DatasMsg[Msg].Loot;
                                    ThirdWaveSumUSM = ThirdWaveSumUSM + DatasMsg[Msg].USMPille;
                                    ThirdWaveSumMetal = ThirdWaveSumMetal + DatasMsg[Msg].MetalPille;
                                    ThirdWaveSumCristal = ThirdWaveSumCristal + DatasMsg[Msg].CristalPille;
                                    ThirdWaveSumDeuterium = ThirdWaveSumDeuterium + DatasMsg[Msg].DeuteriumPille;
                                    ThirdWaveSumPerHour = ThirdWaveSumPerHour + DatasMsg[Msg][PTorGTRawProfitsPerHour];
                                    ThirdWaveSumPerHourUSM = ThirdWaveSumPerHourUSM + DatasMsg[Msg][PTorGTMSUProfitsPerHour];
                                    k = k + 1;
                                    CountLines = CountLines + 1;
                                }
                            }
                        }
                    }
                }
            }
            Msg = Msg + 1;
        }
        if (DatasMsg[Msg]) {
        } else {
            break;
        }
    }
    n = k;
    //Colorisation de la ligne de renta brute si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes raw profits for third wave if profits are higher than specified value
    if (GM_getValue('text4' + MetaLocal.Universe)) {
        if (ThirdWaveSumLOOT > GM_getValue('text4' + MetaLocal.Universe)) {
            if (GM_getValue('color9' + MetaLocal.Universe)) {
                GM_addStyle("#RawAvg3 {color: #" + GM_getValue('color9' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta USM si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU profits for third wave if profits are higher than specified value
    if (GM_getValue('text29' + MetaLocal.Universe)) {
        if (ThirdWaveSumUSM > GM_getValue('text29' + MetaLocal.Universe)) {
            if (GM_getValue('color18' + MetaLocal.Universe)) {
                GM_addStyle("#MSUAvg3 {color: #" + GM_getValue('color18' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta par heure brute si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes raw profits per hour for Third wave if profits are higher than specified value
    if (GM_getValue('text30' + MetaLocal.Universe)) {
        if (ThirdWaveSumPerHour > GM_getValue('text30' + MetaLocal.Universe)) {
            if (GM_getValue('color19' + MetaLocal.Universe)) {
                GM_addStyle("#RawHour3 {color: #" + GM_getValue('color19' + MetaLocal.Universe) +";}");
            }
        }
    }
    //Colorisation de la ligne de renta par heure USM si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU profits per hour for third wave if profits are higher than specified value
    if (GM_getValue('text31' + MetaLocal.Universe)) {
        if (ThirdWaveSumPerHourUSM > GM_getValue('text31' + MetaLocal.Universe)) {
            if (GM_getValue('color20' + MetaLocal.Universe)) {
                GM_addStyle("#MSUHour3 {color: #" + GM_getValue('color20' + MetaLocal.Universe) +";}");
            }
        }
    }
    MoyThirWave = ThirdWaveSumLOOT / k;
    MoyUSMThirWave = ThirdWaveSumUSM / k;
    MoyThirdWavePerHour = ThirdWaveSumPerHour / k;
    MoyThirdWavePerHour_USM = ThirdWaveSumPerHourUSM / k;
    ThirdWaveRatio = ThirdWaveSumUSM / ThirdWaveSumLOOT;
    ThirdWaveRatio = ThirdWaveRatio.toFixed(3);
    //Colorisation de la ligne ratio USM/brut si elle dépasse la valeur indiquée par l'utilisateur -- Colorizes MSU/Raw ratio for third wave if profits are higher than specified value
    if (GM_getValue('text32' + MetaLocal.Universe)) {
        if (ThirdWaveRatio > GM_getValue('text32' + MetaLocal.Universe)) {
            if (GM_getValue('color21' + MetaLocal.Universe)) {
                GM_addStyle("#MSURaw3 {color: #" + GM_getValue('color21' + MetaLocal.Universe) +";}");
            }
        }
    }

    //-------------------------------
    console.log("[O-Table] : Generating html information Table...");
    var PairImpair = 0; //used to put a "pair" or "impair" class

    var Board = '<div id="DIVINFO"><table class="TableauInfos">' +
        '<th class="thTableauInfos"><b>' + Langue.InfoPremiereVague.split("|||")[LangueIndex] + ' </b>(' + l + ' ' + Langue.InfoSlots.split("|||")[LangueIndex] + ')</th>' +
        '<th class="thTableauInfos"><b>' + Langue.InfoSecondeVague.split("|||")[LangueIndex] + '</b>(' + m + ' ' + Langue.InfoSlots.split("|||")[LangueIndex] + ')</th>' +
        '<th class="thTableauInfos"><b>' + Langue.InfoTroisiemeVague.split("|||")[LangueIndex] + '</b>(' + n + ' ' + Langue.InfoSlots.split("|||")[LangueIndex] + ')</th>';
    if (DisplayShipsWave === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.PT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(FirstWaveSumPT) + ' ' + Langue.GT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(FirstWaveSumGT) + '</td><td class="LigneInfoBoard">' + Langue.PT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(SecondWaveSumPT) + ' ' + Langue.GT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(SecondWaveSumGT) + '</td><td class="LigneInfoBoard">' + Langue.PT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(ThirdWaveSumPT) + ' ' + Langue.GT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(ThirdWaveSumGT) + '</td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayRawProfits === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoRenta.split("|||")[LangueIndex] + ' : <div class="tooltipRight" id="RawAvg1" style="display:inline;" title="[' + ThousandSeparator(FirstWaveSumMetal) + ' <FONT color=#FF8F35> ' + Langue.REMetal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + ThousandSeparator(FirstWaveSumCristal) + ' <FONT color=#00A0B6> ' + Langue.RECristal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + ThousandSeparator(FirstWaveSumDeuterium) + ' <FONT color=#2F8900> ' + Langue.REDeut.split("|||")[LangueIndex] + '</FONT>]">' + ThousandSeparator(FirstWaveSumLOOT) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRenta.split("|||")[LangueIndex] + ' : <div id="RawAvg2" style="display:inline;"  class="tooltipRight" title="[' + ThousandSeparator(SecondWaveSumMetal) + ' <FONT color=#FF8F35> ' + Langue.REMetal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + ThousandSeparator(SecondWaveSumCristal) + ' <FONT color=#00A0B6> ' + Langue.RECristal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + ThousandSeparator(SecondWaveSumDeuterium) + ' <FONT color=#2F8900> ' + Langue.REDeut.split("|||")[LangueIndex] + '</FONT>]">' + ThousandSeparator(SecondWaveSumLOOT) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRenta.split("|||")[LangueIndex] + ' : <div id="RawAvg3" style="display:inline;" title="[' + ThousandSeparator(ThirdWaveSumMetal) + ' <FONT color=#FF8F35> ' + Langue.REMetal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + ThousandSeparator(ThirdWaveSumCristal) + ' <FONT color=#00A0B6> ' + Langue.RECristal.split("|||")[LangueIndex] + '</FONT>] <br /> [' + ThousandSeparator(ThirdWaveSumDeuterium) + ' <FONT color=#2F8900> ' + Langue.REDeut.split("|||")[LangueIndex] + '</FONT>]" class="tooltipRight">' + ThousandSeparator(ThirdWaveSumLOOT) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayAvgProfits === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoMoyParSlot.split("|||")[LangueIndex] + ' : <div id="RawAvg1" style="display:inline;">' + ThousandSeparator(parseInt(MoyFirstWave)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyParSlot.split("|||")[LangueIndex] + ' : <div id="RawAvg2" style="display:inline;">' + ThousandSeparator(parseInt(MoyScndWave)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyParSlot.split("|||")[LangueIndex] + ' : <div id="RawAvg3" style="display:inline;">' + ThousandSeparator(parseInt(MoyThirWave)) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayUSM === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoRentaUSM.split("|||")[LangueIndex] + ' : <div id="MSUAvg1" style="display:inline;">' + ThousandSeparator(FirstWaveSumUSM) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRentaUSM.split("|||")[LangueIndex] + ' : <div id="MSUAvg2" style="display:inline;">' + ThousandSeparator(SecondWaveSumUSM) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRentaUSM.split("|||")[LangueIndex] + ' : <div id="MSUAvg3" style="display:inline;" >' + ThousandSeparator(ThirdWaveSumUSM) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayAvgMSUProfits === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoMoyUSMParSlot.split("|||")[LangueIndex] + ' : <div id="MSUAvg1" style="display:inline;">' + ThousandSeparator(parseInt(MoyUSMFirstWave)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyUSMParSlot.split("|||")[LangueIndex] + ' : <div id="MSUAvg2" style="display:inline;">' + ThousandSeparator(parseInt(MoyUSMScndWave)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyUSMParSlot.split("|||")[LangueIndex] + ' : <div id="MSUAvg3" style="display:inline;">' + ThousandSeparator(parseInt(MoyUSMThirWave)) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayProfitsPerHour === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoRentaParHeure.split("|||")[LangueIndex] + ' : <div id="RawHour1" style="display:inline;">' + ThousandSeparator(parseInt(FirstWaveSumPerHour)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRentaParHeure.split("|||")[LangueIndex] + ' : <div id="RawHour2" style="display:inline;">' + ThousandSeparator(parseInt(SecondWaveSumPerHour)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRentaParHeure.split("|||")[LangueIndex] + ' : <div id="RawHour3" style="display:inline;">' + ThousandSeparator(parseInt(ThirdWaveSumPerHour)) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayAvgProfitsPerHour === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoMoyRentaParHeure.split("|||")[LangueIndex] + ' : <div id="RawHour1" style="display:inline;">' + ThousandSeparator(parseInt(MoyFirstWavePerHour)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyRentaParHeure.split("|||")[LangueIndex] + ' : <div id="RawHour2" style="display:inline;">' + ThousandSeparator(parseInt(MoySecondWavePerHour)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyRentaParHeure.split("|||")[LangueIndex] + ' : <div id="RawHour3" style="display:inline;">' + ThousandSeparator(parseInt(MoyThirdWavePerHour)) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayMSUProfitsPerHour === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoRentaParHeureUSM.split("|||")[LangueIndex] + ' : <div id="MSUHour1" style="display:inline;">' + ThousandSeparator(parseInt(FirstWaveSumPerHourUSM)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRentaParHeureUSM.split("|||")[LangueIndex] + ' : <div id="MSUHour2" style="display:inline;">' + ThousandSeparator(parseInt(SecondWaveSumPerHourUSM)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRentaParHeureUSM.split("|||")[LangueIndex] + ' : <div id="MSUHour3" style="display:inline;">' + ThousandSeparator(parseInt(ThirdWaveSumPerHourUSM)) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (DisplayAvgMSUProfitsPerHour === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoMoyRentaParHeureUSM.split("|||")[LangueIndex] + ' : <div id="MSUHour1" style="display:inline;">' + ThousandSeparator(parseInt(MoyFirstWavePerHour_USM)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyRentaParHeureUSM.split("|||")[LangueIndex] + ' : <div id="MSUHour2" style="display:inline;">' + ThousandSeparator(parseInt(MoySecondWavePerHour_USM)) + '</div></td><td class="LigneInfoBoard">' + Langue.InfoMoyRentaParHeureUSM.split("|||")[LangueIndex] + ' : <div id="MSUHour3" style="display:inline;">' + ThousandSeparator(parseInt(MoyThirdWavePerHour_USM)) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (MSUvsRAW === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoRatio.split("|||")[LangueIndex] + ' : <div id="MSURaw1" style="display:inline;">' + FirstWaveRatio + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRatio.split("|||")[LangueIndex] + ' : <div id="MSURaw2" style="display:inline;">' + SecondWaveRatio + '</div></td><td class="LigneInfoBoard">' + Langue.InfoRatio.split("|||")[LangueIndex] + ' : <div id="MSURaw3" style="display:inline;">' + ThirdWaveRatio + '</div></td>';
        PairImpair = PairImpair + 1;
    }

    Board = Board + '</tr></table></div>';
    console.log("[O-Table] : Information table successfully created !");
    return Board;

    function FonctionPairImpair(PairOuImpair) {
        // This function is used to set the class line "Pair" or "Impair"
        if (PairOuImpair % 2 === 0) {
            return 'Pair';
        } else {
            return 'Impair';
        }
    }
}

//Quick filter table

function QuickFilter()

//A Arranger : style css dépendant du tableau récapitulatif

{
    var MetaLocal = MetaDatas();
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers
    GM_addStyle(".TableauQuickFilter { border: 1px solid #555; text-align: left; width: 100%; margin-top: 15px  } ");
    GM_addStyle(".thTableauQuickFilter { border-left: 1px solid #222; height : 25px; text-align: center;} ");
    GM_addStyle(".LigneQuickFilter { border-left: 1px solid #222; height: 25px} ");


    try {//Permet d'effacer le panel d'options rapides s'il est déjà présent
        var Empty = '';
        var Table = document.querySelector("#QUICKFILTER");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
    } catch(err) {}

    try {//Permet d'effacer le panel d'options s'il est déjà présent
        var Empty = '';
        var Table = document.querySelector(".TableauRaid");
        if(Table.outerHTML) {

            var Board = '<div id="QUICKFILTER"><table class="TableauQuickFilter">' +
                '<th colspan="3" class="thTableauQuickFilter"><b>' + Langue.QuickFilter.split("|||")[LangueIndex] + '</b></th>' +
                '<tr class =""><td class="LigneQuickFilter">' + Langue.QuickFilterAge.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text7" value="999" maxlength="3"></label> ' + Langue.OptionsTextesAL.split("|||")[LangueIndex] + '' + '</td><td class="LigneQuickFilter">' + Langue.QuickFilterFlotte.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text5" value="999999999999" maxlength="13"></label></td><td class="LigneQuickFilter">' + Langue.QuickFilterDef.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text6" value="999999999999" maxlength="13"></label></td></tr>'+
                '<tr class =""><td class="LigneQuickFilter">' + Langue.QuickFilterRentaMin.split("|||")[LangueIndex] + '<label><input type="text" class="BigText" id="text28" value="0" maxlength="13"></label></td><td class="LigneQuickFilter"><form style="display:inline;">' + Langue.QuickFilterStd.split("|||")[LangueIndex] + '<input id="radio14" type="radio" name="HideRESmallSTDUSM" checked>' + Langue.QuickFilterUSM.split("|||")[LangueIndex] + '<input id="radio15" type="radio" name="HideRESmallSTDUSM"></form></td><td class="LigneQuickFilter"><form style="display:inline;">' + Langue.QuickFilterRes.split("|||")[LangueIndex] + '<input id="radio12" type="radio" name="RssCDR" checked>' + Langue.QuickFilterResCDR.split("|||")[LangueIndex] +'<input id="radio13" type="radio" name="RssCDR"></form></td></tr>'+
                '<tr class =""><td class="LigneQuickFilter"><label><input type="checkbox" id="cboxquickfilter1">' + Langue.QuickFilterCurGala.split("|||")[LangueIndex] + '</label></td><td colspan="2" class="LigneQuickFilter">' + Langue.QuickFilterGalaxies.split("|||")[LangueIndex] + '<br><label><input type="checkbox" id="cboxquickfilter2">1</label><label><input type="checkbox" id="cboxquickfilter3">2</label><label><input type="checkbox" id="cboxquickfilter4">3</label><label><input type="checkbox" id="cboxquickfilter5">4</label><label><input type="checkbox" id="cboxquickfilter6">5</label><label><input type="checkbox" id="cboxquickfilter7">6</label><label><input type="checkbox" id="cboxquickfilter8">7</label><label><input type="checkbox" id="cboxquickfilter9">8</label><label><input type="checkbox" id="cboxquickfilter10">9</label><label><input type="checkbox" id="cboxquickfilter11">10</label><label><input type="checkbox" id="cboxquickfilter12">11</label><label><input type="checkbox" id="cboxquickfilter13">12</label><label><input type="checkbox" id="cboxquickfilter14" checked>' + Langue.QuickFilterAll.split("|||")[LangueIndex] + '</label></td></tr>'+
                '<tr class =""><td colspan="3" class="LigneQuickFilter"><label><input type="checkbox" id="cboxquickfilter15">' + Langue.QuickFilterTrashbin.split("|||")[LangueIndex] + '</label></td></tr>'+
                '<tr class =""><td colspan="3" class="LigneQuickFilter"><label><input type="checkbox" id="cboxquickfilter16">' + Langue.QuickFilterHidden.split("|||")[LangueIndex] + '</label></td></tr>'+
                '<tr class =""><td class="LigneQuickFilter">' + Langue.QuickFilterMaxLines.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text33" value="999" maxlength="4"></label></td><td colspan="2" class="LigneQuickFilter">' + Langue.QuickFilterSave.split("|||")[LangueIndex] + '</td></tr>'+
                '</table></div>';


            var Design = Board;
            var newElement = document.createElement("div"); // On crée un nouvelle élément div
            newElement.innerHTML = Design; // On écrit le code source qu'il contient
            document.querySelector("#ui-id-14 .TableButton").insertBefore(newElement, document.querySelector("#ui-id-14 .LigneTableButton").nextSibling);

            if (GM_getValue('text7' + MetaLocal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- AGE
                var AgeMaxi = parseInt(GM_getValue('text7' + MetaLocal.Universe));
            } else { //Si aucune donnée sauvegardée, attribution d'une valeur par défaut
                var AgeMaxi = 999;
            }


            console.log("[O-Table] : QuickFilter table successfully created !");

        }
    } catch(err) {}
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FONCTIONS LIEES AUX BOUTONS///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// BOUTON VIDER TABLEAU // EMPTY TABLE BUTTON

//First process, check if user checked the delete protection or not in options
function StartEmptyProcess()
{
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers

    var Meta = MetaDatas();
    if (GM_getValue('column45' + Meta.Universe) === false || GM_getValue('column45' + Meta.Universe) === true) { //Si une valeur a été enregistrée
        var EmptyProtected = GM_getValue('column45' + Meta.Universe);
    } else { //si aucune valeur est enregistrée, par défaut, la variable est false
         var EmptyProtected = false;
    }

    if (EmptyProtected === true) {
        console.log("[O-Table] : Cleaning table is protected, user will need to press Empty button twice in less than one second to clean the table")
        EmptyProtect(Date.now(), 0);
    } else {
        console.log("[O-Table] : Cleaning table is unprotected, calling EmptyTable function")
        EmptyTable()
        HideTable();
    }
    setTimeout(function(){
        document.getElementById("Empty").innerHTML = '&#8239{&#8239' + Langue.BoutonViderScript.split("|||")[LangueIndex] + '&#8239}'
        document.getElementById("Empty").style.color = 'inherit';
    }, 4000);
}


//Full cleaning process
function EmptyTable() {
    var Message = {};
    var MetaLocal = MetaDatas();
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers

    MessageIndex = GM_getValue('MessageIndex'+MetaLocal.Universe, MessageIndex);
    console.log("[O-Table] : Amount of messages going to be deleted : " + MessageIndex);
    for (var i = 0; i < MessageIndex + 1; i++){
        DelStoredRE(i);
    }
    //alert(MessageIndex + ' messages supprimés');
    MessageIndex = 0;
    GM_setValue('MessageIndex'+MetaLocal.Universe, MessageIndex);
    GM_deleteValue('REIdList'+MetaLocal.Universe, IdMessages);
    document.getElementById("Empty").style.color = '#00FF00';
    document.getElementById("Empty").innerHTML = '&#8239{&#8239' + Langue.BoutonViderOK.split("|||")[LangueIndex] + '&#8239}'
    console.log("[O-Table] : Messages successfully deleted");
    //location.reload();
}

//Protected button function
function EmptyProtect(InitialDate, Timer) { //EmptyProtect EmptySecure
    //Init date is the timestamp when user clicked on empty button
    //Timer is set to 0, it must reach 1 for emptying table
    //!\ : to launch cleaning process, user must have clicked twice on empty table in less than one second.
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers

    document.getElementById("Empty").removeEventListener("click", StartEmptyProcess, true) //Old event listener must be deleted, it will be replaced by one different during the 1 second when the scrips waits a secondary user click
    document.getElementById("Empty").addEventListener("click", EmptyProtectWaitUser, true)
    document.getElementById("Empty").innerHTML = '&#8239{&#8239' + Langue.BoutonViderProtected.split("|||")[LangueIndex] + '&#8239}'
    document.getElementById("Empty").style.color = 'orange';
    function EmptyProtectWaitUser()
    {
        Timer = 1;
    }


    setTimeout(function(){
        //At this point, if Timer is equal to 1, it's because user pressed the Empty Table twice. If it's equal to 0, user pressed only once the button
        document.getElementById("Empty").removeEventListener("click", EmptyProtectWaitUser, true)
        document.getElementById("Empty").addEventListener("click", StartEmptyProcess, true)
        if (Timer === 1) {
            EmptyTable()
            HideTable();
        } else {
            document.getElementById("Empty").style.color = '#FF0000';
            document.getElementById("Empty").innerHTML = '&#8239{&#8239' + Langue.BoutonViderFailed.split("|||")[LangueIndex] + '&#8239}'
        }
    }, 1000);


}


//BOUTON CACHER TABLEAU // HIDE TABLE BUTTON
function HideTable() {
    try {//Permet d'effacer le tableau s'il est déjà présent
        var Empty = '';
        var Table = document.querySelector(".InfosVague");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
            setTimeout(function() { GM_addStyle("#AfficherTableau { color: inherit;}");}, 10); //Recolorie le bouton afficher dans sa couleur d'origine
            console.log("[O-Table] : Board hidden successfully");
        }
        TriDone = 0; // Réinisialise le tri à 0 (afin de pouvoir trier à nouveau le tableau automatiquement) -- cette variable passe à 1 lorsque l'utilisateur clique sur un des boutons de tri, ce qui empêche le tableau de se retrier tout seul à ce moment là
    } catch(err) {}
    try {//Permet d'effacer le tableau d'informations s'il est déjà présent
        var Empty = '';
        var Table = document.querySelector("#DIVINFO");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
    } catch(err) {}

}


//BOUTON OPTIONS -- ZONE OPTIONS
function OptionsButton() { //Fonction gérant toute la parte options
    try {//Permet d'effacer le tableau s'il est déjà présent
        var MetaLocal = MetaDatas();
        var Empty = '';
        var Table = document.querySelector(".InfosVague");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
        setTimeout(function() { GM_addStyle("#AfficherTableau { color: inherit;}");}, 10); //Recolorie le bouton afficher dans sa couleur d'origine
    } catch(err) {}
    try {//Permet d'effacer le panel d'options rapides s'il est déjà présent
        var Empty = '';
        var Table = document.querySelector("#QUICKFILTER");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
    } catch(err) {}
    try {//Permet d'effacer le tableau d'informations s'il est déjà présent
        var Empty = '';
        var Table = document.querySelector("#DIVINFO");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
            }
    } catch(err) {}
    try {//Permet d'effacer le tableau d'options s'il est déjà présent
        var Empty = '';
        var Table = document.querySelector("#OptionsDiv");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
            }
    } catch(err) {}
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers
    TriDone = 0; //Réinitialise le fait que le tri ait été fait à 0
    var ZoneCouleurs = ('<div id="OptionsCouleurs"><table id="TableauZoneCouleurs">' + //Création des options dans la zone couleur
                             '<ul>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAA.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color0" value="0C8528" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAB.split("|||")[LangueIndex] + ' :                                                        <label><input type="text" id="color1" value="FFFFFF" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAC.split("|||")[LangueIndex] + ' :                               <label><input type="text" id="color2" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAD.split("|||")[LangueIndex] + ' :                                      <label><input type="text" id="color3" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAE.split("|||")[LangueIndex] + ' :      <label><input type="text" id="color4" value="FF0000" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAA.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text0" value="1000000" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                      <label><input type="text" id="color5" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAB.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text19" value="1000000" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                      <label><input type="text" id="color10" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesBH.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text27" value="1000000" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                      <label><input type="text" id="color11" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAC.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text1" value="1000000" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                     <label><input type="text" id="color6" value="FF0000" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAD.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text2" value="1000000" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                    <label><input type="text" id="color7" value="FF0000" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAF.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color12" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAE.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text3" value="2" maxlength="3"></label> heures, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color8" value="FF0000" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAG.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color13" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAH.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color14" value="00FF00" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAI.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color15" value="FF3010" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAJ.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color16" value="111A21" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAK.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color17" value="18242D" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAL.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text35" value="50" maxlength="3"></label> ' + Langue.OptionsCouleurAN.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color23" value="FFFFFF" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAL.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text34" value="1" maxlength="2"></label> ' + Langue.OptionsCouleurAM.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color22" value="FFFFFF" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' +
                        '</ul>' +
                        '</table></div>');

    var ZoneColonnes = ('<div id="OptionsColonnes"><table id="TableauZoneColonnes">' + //affichage du contenu de la catégorie Affichage des colonnes (1)
                            '<ul>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox0">' + Langue.OptionsCBoxAA.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox1">' + Langue.OptionsCBoxAB.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox2">' + Langue.OptionsCBoxAC.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox3">' + Langue.OptionsCBoxAD.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox4">' + Langue.OptionsCBoxAE.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox5">' + Langue.OptionsCBoxAF.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox6">' + Langue.OptionsCBoxAG.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox7">' + Langue.OptionsCBoxAH.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox8">' + Langue.OptionsCBoxAI.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox9">' + Langue.OptionsCBoxAJ.split("|||")[LangueIndex] + ' </label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox10">' + Langue.OptionsCBoxAK.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox23">' + Langue.OptionsCBoxAL.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox11">' + Langue.OptionsCBoxAM.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox12">' + Langue.OptionsCBoxAN.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox13">' + Langue.OptionsCBoxAO.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox25">' + Langue.OptionsCBoxAS.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox14">' + Langue.OptionsCBoxAP.split("|||")[LangueIndex] + '<label><input type="checkbox" id="cbox34"></label>)</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox15">' + Langue.OptionsCBoxAQ.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox16">' + Langue.OptionsCBoxAR.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox26">' + Langue.OptionsCBoxAT.split("|||")[LangueIndex] + '</label><form style="display:inline;"> (' + Langue.Aller.split("|||")[LangueIndex] + ' <input id="radio0" type="radio" name="TravBack" checked> ' + Langue.AllerRetour.split("|||")[LangueIndex] + ' <input id="radio1" type="radio" name="TravBack"></form>)<form style="display:inline;"> (' + Langue.PT.split("|||")[LangueIndex] + ' <input id="radio2" type="radio" name="PTGTTRAVTIME" checked> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio3" type="radio" name="PTGTTRAVTIME"></form>)' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox27">' + Langue.OptionsCBoxAU.split("|||")[LangueIndex] + '</label><form style="display:inline;"> (' + Langue.PT.split("|||")[LangueIndex] + ' <input id="radio4" type="radio" name="ARTIME" checked> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio5" type="radio" name="ARTIME"></form>)' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox28">' + Langue.OptionsCBoxAV.split("|||")[LangueIndex] + '</label><form style="display:inline;"> (' + Langue.PT.split("|||")[LangueIndex] + ' <input id="radio6" type="radio" name="BATIME" checked> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio7" type="radio" name="BATIME"></form>)' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox29">' + Langue.OptionsCBoxAW.split("|||")[LangueIndex] + '</label><form style="display:inline;"> (' + Langue.PT.split("|||")[LangueIndex] + ' <input id="radio8" type="radio" name="PTGTHOUR" checked> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio9" type="radio" name="PTGTHOUR"></form>)<form style="display:inline;"> (' + Langue.Brut.split("|||")[LangueIndex] + ' <input id="radio10" type="radio" name="STDMSUHOUR" checked> ' + Langue.USM.split("|||")[LangueIndex] + ' <input id="radio11" type="radio" name="STDMSUHOUR"></form>)' +
                                 '<li class="OptionsColonnesContent OPT" title="' + Langue.MIPExplained.split("|||")[LangueIndex] + '"><label><input type="checkbox" id="cbox31">' + Langue.OptionsCBoxAX.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT">' +
                            '</ul>' +
                        '</table></div>');
    var ZoneGlobales = ('<div id="OptionsGlobales"><table id="TableauZoneGlobales">' +
                             '<ul>' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAI.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text5" value="999999999999" maxlength="13"></label>' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAJ.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text6" value="999999999999" maxlength="13"></label>' +
                                  '<li class="OptionsGlobalesContent OPT" title="' + Langue.MIPExplained.split("|||")[LangueIndex] + '"><label><input type="checkbox" id="cbox32">' + Langue.OptionsTextesBK.split("|||")[LangueIndex] + '</label><form style="display:inline;"> ' + Langue.Brut.split("|||")[LangueIndex] + ' <input id="radio16" type="radio" name="PROFITABLEMIP"> ' + Langue.USM.split("|||")[LangueIndex] + ' <input id="radio17" type="radio" name="PROFITABLEMIP" checked></form>)' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesBJ.split("|||")[LangueIndex] + '<label><input type="text" class="BigText" id="text28" value="0" maxlength="13"></label><form style="display:inline;">(' + Langue.Ressource.split("|||")[LangueIndex] + '<input id="radio12" type="radio" name="RssCDR" checked>' +  Langue.RessourceCDR.split("|||")[LangueIndex] + '<input id="radio13" type="radio" name="RssCDR">)</form><form style="display:inline;">(' +  Langue.Brut.split("|||")[LangueIndex] + '<input id="radio14" type="radio" name="HideRESmallSTDUSM" checked>' + Langue.USM.split("|||")[LangueIndex] + '<input id="radio15" type="radio" name="HideRESmallSTDUSM"></form>)' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAK.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text7" value="999" maxlength="3"></label> ' + Langue.OptionsTextesAL.split("|||")[LangueIndex] + '' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesCB.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text33" value="999" maxlength="4"></label> ' + Langue.OptionsTextesCC.split("|||")[LangueIndex] + '' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAM.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text8" value="3" maxlength="4"></label> ' + Langue.OptionsTextesBD.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText"  id="text9" value="2" maxlength="4"></label> ' + Langue.OptionsTextesBE.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text10" value="1" maxlength="4"></label> ' + Langue.OptionsTextesBF.split("|||")[LangueIndex] + '' +
                                  '<li class="OptionsGlobalesContent OPT">--------------------------------------------------------------------------------------------------------------------------' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesBG.split("|||")[LangueIndex] + ' : <select class="DropDownShipsMore" id="DropDown2" style="visibility:visible"><option value="120"> 120% </option><option value="110"> 110% </option><option value="100"> 100% </option><option value="90"> 90% </option><option value="80"> 80% </option><option value="70"> 70% </option><option value="60"> 60% </option></select>' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAP.split("|||")[LangueIndex] + ' <select class="DropDownShipsMore" id="DropDown1" style="visibility:visible"><option value="0"> FR </option><option value="1"> EN </option></select>' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAQ.split("|||")[LangueIndex] + ' : ' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAR.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text11" value="' + Langue.Milliard.split("|||")[LangueIndex] + '" maxlength="15"></label> ' + Langue.OptionsTextesAS.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text12" value="' + Langue.Million.split("|||")[LangueIndex] + '" maxlength="15"></label> ' + Langue.OptionsTextesAT.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text13" value="" maxlength="15"></label>' +
                                  '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox35">' + Langue.OptionsTextesBN.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsGlobalesContent OPT">--------------------------------------------------------------------------------------------------------------------------' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAU.split("|||")[LangueIndex] + ' : <label><input type="checkbox" id="cbox19"></label>' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAV.split("|||")[LangueIndex] + '  <label><input type="text" class="BigText" id="text17" value="400000" maxlength="9"></label>' +
                                  '<li class="OptionsGlobalesContent OPT"><form style="display:inline;">' +  Langue.OptionsTextesBL.split("|||")[LangueIndex] + '<input id="radio18" type="radio" name="SecondesVaguesStdMSU" checked>' + Langue.USM.split("|||")[LangueIndex] + '<input id="radio19" type="radio" name="SecondesVaguesStdMSU"></form>' +
                                  '<li class="OptionsGlobalesContent OPT">--------------------------------------------------------------------------------------------------------------------------' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAG.split("|||")[LangueIndex] + ' <select class="DropDownShipsMore" id="DropDown0" style="visibility:visible"><option value="0"> 0 % </option><option value="5"> 5 % </option><option value="10"> 10 % </option><option value="15"> 15 % </option><option value="20"> 20 % </option><option value="30"> 30 % </option><option value="40"> 40 % </option><option value="50"> 50 % </option><option value="60"> 60 % </option><option value="70"> 70 % </option><option value="80"> 80 % </option><option value="90"> 90 % </option><option value="100"> 100 % </option></select> ' + Langue.OptionsTextesAH.split("|||")[LangueIndex] + '. ' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesBI.split("|||")[LangueIndex] + ' : <select class="DropDownShipsMore" id="DropDown3" style="visibility:visible"><option value="RawCoord">' + Langue.RECoords.split("|||")[LangueIndex] + '</option><option value="PlayerMin">' + Langue.REPlayer.split("|||")[LangueIndex] + '</option><option value="AgeSec">' + Langue.REAge.split("|||")[LangueIndex] + '</option><option value="HeureRetourPTRaw">' + Langue.RETimeTravelSec.split("|||")[LangueIndex] + '</option><option value="MetalPille">' + Langue.REMetal.split("|||")[LangueIndex] + '</option><option value="CristalPille">' + Langue.RECristal.split("|||")[LangueIndex] + '</option><option value="DeuteriumPille">' + Langue.REDeut.split("|||")[LangueIndex] + '</option><option value="Total">' + Langue.RETotal.split("|||")[LangueIndex] + '</option><option value="Loot">' + Langue.RELoot.split("|||")[LangueIndex] + '</option><option value="USMPille">' + Langue.RELootUSM.split("|||")[LangueIndex] + '</option><option value="FlotteFinal">' + Langue.REFlotte.split("|||")[LangueIndex] + '</option><option value="DefenseFinal">' + Langue.REDefense.split("|||")[LangueIndex] + '</option><option value="FlotteFinal">' + Langue.REFlotte.split("|||")[LangueIndex] + '</option><option value="HeureArriveePTRaw">' + Langue.HeureArrivee.split("|||")[LangueIndex] + '</option><option value="HeureRetourPTRaw">' + Langue.HeureRetour.split("|||")[LangueIndex] + '</option></select>' +
                                  '<li class="OptionsGlobalesContent OPT"><label><input type="checkbox" id="cbox20">' + Langue.OptionsTextesAZ.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsGlobalesContent OPT"><label><input type="checkbox" id="cbox33">' + Langue.OptionsTextesBM.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsGlobalesContent OPT"><label><input type="checkbox" id="cbox22">' + Langue.OptionsTextesBA.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsGlobalesContent OPT"><label><input type="checkbox" id="cbox21">' + Langue.OptionsTextesBB.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsGlobalesContent OPT"><label><input type="checkbox" id="cbox45">' + Langue.OptionsTextesCD.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsGlobalesContent OPT"><label><input type="checkbox" id="cbox18">' + Langue.OptionsTextesBC.split("|||")[LangueIndex] + '</label>' +

                                  '<li class="OptionsGlobalesContent OPT">' +
                             '</ul>' +
                        '</table></div>');
    var ZoneTechs = ('<div id="OptionsTechs"><table id="TableauZoneTechs">' +
                             '<ul>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAK.split("|||")[LangueIndex] + '<label><input type="checkbox" id="cbox30"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAA.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text14" value="0" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAB.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text15" value="0" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAC.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text16" value="0" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAF.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text22" value="0" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAG.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text23" value="0" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAH.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text24" value="0" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAD.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text20" value="30" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAE.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text21" value="0" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAJ.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text26" value="9" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAI.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text25" value="499" maxlength="3"></label>' +
                                  '<li class="OptionsTechsContent OPT">' +
                             '</ul>' +
                        '</table></div>');
    var ZoneTableauRecap = ('<div id="OptionsTableauRecap"><table id="TableauZoneRecap">' +
                             '<ul>' +
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox17">' + Langue.OptionsTextesAW.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsTableauRecapContent OPT">--------------------------------------------------------------------------------------------------------------------------' +
                                  '<li class="OptionsTableauRecapContent OPT">' + Langue.OptionsTextesAX.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text18" value="20" maxlength="2"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT">--------------------------------------------------------------------------------------------------------------------------' +
                                  '<li class="OptionsTableauRecapContent OPT" title="' + Langue.TableauCouleurExplainedAA.split("|||")[LangueIndex] + '">' + Langue.OptionsTextesAF.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text4" value="17500000" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color9" value="00FF00" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT" title="' + Langue.TableauCouleurExplainedAB.split("|||")[LangueIndex] + '">' + Langue.OptionsTextesBV.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text29" value="22500000" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color18" value="00FF00" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT" title="' + Langue.TableauCouleurExplainedAC.split("|||")[LangueIndex] + '">' + Langue.OptionsTextesBW.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text30" value="17500000" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color19" value="00FF00" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT" title="' + Langue.TableauCouleurExplainedAD.split("|||")[LangueIndex] + '">' + Langue.OptionsTextesBX.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text31" value="22500000" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color20" value="00FF00" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT">' + Langue.OptionsTextesBY.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text32" value="1.38" maxlength="4"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color21" value="00FF00" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT">--------------------------------------------------------------------------------------------------------------------------' +
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox36"></label>' + Langue.OptionsTextesBP.split("|||")[LangueIndex] + //amount of ships per wave
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox37"></label>' + Langue.OptionsTextesBO.split("|||")[LangueIndex] + //raw profits for the wave
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox24"></label>' + Langue.OptionsTextesAY.split("|||")[LangueIndex] + //msu profits for the wave
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox38"></label>' + Langue.OptionsTextesBQ.split("|||")[LangueIndex] + //average profit per slot
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox39"></label>' + Langue.OptionsTextesBR.split("|||")[LangueIndex] + //average msu profit per slot
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox40"></label>' + Langue.OptionsTextesBS.split("|||")[LangueIndex] + '<form style="display:inline;"> (' + Langue.PT.split("|||")[LangueIndex] + ' <input id="radio20" type="radio" name="PTorGTRawProfitsPerHourRecapTable" checked> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio21" type="radio" name="PTorGTRawProfitsPerHourRecapTable"></form>)' +//profits per hour for the wave
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox43"></label>' + Langue.OptionsTextesBZ.split("|||")[LangueIndex] + //msu vs raw ratio for the wave
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox41"></label>' + Langue.OptionsTextesBT.split("|||")[LangueIndex] + '<form style="display:inline;"> (' + Langue.PT.split("|||")[LangueIndex] + ' <input id="radio22" type="radio" name="PTorGTMSUProfitsPerHourRecapTable" checked> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio23" type="radio" name="PTorGTMSUProfitsPerHourRecapTable"></form>)' +//msu profits per hour for the wave
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox44"></label>' + Langue.OptionsTextesCA.split("|||")[LangueIndex] + //msu vs raw ratio for the wave
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox42"></label>' + Langue.OptionsTextesBU.split("|||")[LangueIndex] + //msu vs raw ratio for the wave
                                  '<li class="OptionsTableauRecapContent OPT">' +
                             '</ul>' +
                        '</table></div>');
    var TableauOptions = ('<div id="OptionsDiv"><table id="OptionsMainTable">' + //affichage des catégories des options (0)
                               '<tr>' +
                                    '<td id="SauvegarderOptions" style="color:green;" > --> ' + Langue.OptionsMainAB.split("|||")[LangueIndex] + ' <-- </td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine" >' + Langue.OptionsMainAA.split("|||")[LangueIndex] + ' </td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + ZoneCouleurs + '</td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + Langue.OptionsMainAC.split("|||")[LangueIndex] + ' </td>' +
                               '</tr><tr>' +
                                     '<td class="OptionsMainLine">' + ZoneColonnes + '</td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + Langue.OptionsMainAD.split("|||")[LangueIndex] + ' </td>' +
                               '</tr></tr>' +
                                     '<td class="OptionsMainLine">' + ZoneGlobales + '</td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + Langue.OptionsMainAE.split("|||")[LangueIndex] + ' </td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + ZoneTechs + '</td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + Langue.OptionsMainAF.split("|||")[LangueIndex] + ' </td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + ZoneTableauRecap + '</td>' +
                               '</tr><tr>' +
                                     '<td class="LastMainLine">' + Langue.Version.split("|||")[LangueIndex] + ' : ' + Version + '</td>' +
                               '</tr><tr>' +
                          '</table></div>');



    //Affichage du tableau HTML
    var newElement = document.createElement("div"); // On crée un nouvelle élément div
    newElement.innerHTML = TableauOptions; // On écrit le code source qu'il contient
    document.querySelector("#ui-id-14 .TableButton:first-child").insertBefore(newElement, document.querySelector("#ui-id-14 .TableButton:first-child").nextSibling);
    GM_addStyle(".OPT:hover { color : #ffffff;} "); //Colorize line in white when user put his mouse hover
    GM_addStyle("input[type=radio] {-moz-transform: scale(0.9, 0.9); width:10px ; height:10px;} ");

    //Default values for cbox : //put a * where it's true
    /////////////////////////////*/////////////*///////////////////////////////////////*/////*///////*/////*/////*/////*//////*/////*////*////*///////////*/////*/////////////////////////////////*//////////////////////////////////*//////////////////////////////////////*//////*/////*////////////////////////////////////////////////////
    ///////////////////////////cbox0//cbox1/cbox2//cbox3//cbox4//cbox5//cbox6//cbx7/cbox8/cbox9/cbox10cbox11cbox12cbx13cbox14cbox15cbox16cbox17cbox18cbox19cbox20/cbox21/cbox22cbox23/cbox24/cbx25/cbox26/cbox27/cbox28/cbox29/cbox30/cbox31/cbox32/cbox33/cbox34/cbox35/cbox36/cbx37/cbx38/cbox39/cbox40//cbox41/cbox42//cbox43/cbox44/cbox45
    var DefaultCbox = new Array(true, false, true, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, false, true, true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false);
    //cbox17 = tableau récapitulatif des vagues
    //cbox19 : secondes vagues par défaut
    //cbox20 : ouvrir les attaques dans un nouvel onglet
    //cbox30 : automatically collects research in research page

    //gestion des données (checkbox) : Affichage des colonnes cochées
    for (var j = 0; j < 46; j++){
        if (GM_getValue('column' + j + MetaLocal.Universe) === false || GM_getValue('column' + j + MetaLocal.Universe) === true) { //Si une valeur a été enregistrée
            console.log("[O-Table Options] : datas from cbox" + j + " found : " + GM_getValue('column' + j + MetaLocal.Universe));
            document.getElementById('cbox' + j ).checked = GM_getValue('column' + j + MetaLocal.Universe);
        } else {
            console.log("[O-Table Options] : datas from cbox" + j + " not found, found, putting default value to this checkbox : " + DefaultCbox[j]);
            document.getElementById('cbox' + j ).checked = DefaultCbox[j];
        }
    }


    //Gestion des couleurs, la boucle for ajoute un style CSS à chaque id comprenant "color", puis ajoute une fonction d'écoute et lorsque la longueur du texte inscrit dans le champ atteint 6, met à jour le background en fonction
    for (var k = 0; k < 24; k++) {
        try {
            if (GM_getValue('color' + k + MetaLocal.Universe)) {
                console.log("[O-Table Options] : datas from color" + k + " found : " + GM_getValue('color' + k + MetaLocal.Universe));
                document.getElementById("color" + k).value = GM_getValue('color' + k + MetaLocal.Universe);
            } else {
                console.log("[O-Table Options] : datas from color" + k + " not found, default value applied");
            }
        } catch (err) {
        }
        GM_addStyle("#color" + k + " { background-color : #" + document.getElementById('color' + k).value + "; padding: 0px 0px 0px 0px; box-shadow:none; border: 1px solid #aaa; height: 15px; width:60px; padding:0px; border-radius: 0px 0px 0px 0px; text-align: center; float: right; clear: both; }");
        document.getElementById('color' + k ).addEventListener("keyup", function(event) //Création du bouton permettant la collecte et la sauvegarde des messages
        {
            if (document.getElementById(this.id)) { //cette partie s'active plus tard (lorsque l'utilisateur a rempli le champ, du coup, k est bloqué à 8 donc il faut utiliser this
                var color1 = document.getElementById(this.id).value;
            GM_addStyle("#" + this.id + " { background-color : #" + color1 + ";} ");
        }
        }, true);
    }

    //Gestion des textes (rentas, heures, autre...)
    for (var m = 0; m < 36; m++){
        try {
            if (GM_getValue('text' + m + MetaLocal.Universe)) {
                console.log("[O-Table Options] : datas from text" + m + " found : " + GM_getValue('text' + m + MetaLocal.Universe));
                document.getElementById("text" + m).value = GM_getValue('text' + m + MetaLocal.Universe);
            }
        } catch (err) {
            console.log("[O-Table Options] : datas from text" + m + " not found, default value applied");
        }
    }
    //gestion des données (DropDown) : Affichage des valeurs dropdown
    for (var o = 0; o < 4; o++){
        try {
            if (GM_getValue('DropDown' + o + MetaLocal.Universe)) {
                console.log("[O-Table Options] : datas from DropDown" + o + " found : " + GM_getValue('DropDown' + o + MetaLocal.Universe));
                document.getElementById("DropDown" + o).value = GM_getValue('DropDown' + o + MetaLocal.Universe);
            } else {
                console.log("[O-Table Options] : datas from DropDown" + o + " not found, default value applied");
                if (o == 0) {
                    document.getElementById("DropDown" + o).value = "20"; ///////////////////////////////////////////////////%ships more
                }
                if (o == 1) {
                    document.getElementById("DropDown" + o).value = LangueIndex; ///////////////////////////////////////////////////LANGUE
                }
                if (o == 2) {
                    document.getElementById("DropDown" + o).value = "100"; ///////////////////////////////////////////////////text size
                }
                if (o == 3) {
                    document.getElementById("DropDown" + o).value = "Loot"; //////////////////////////////////////////////////default sort table
                }
            }
        } catch (err) {
             GM_setValue('DropDown' + o + MetaLocal.Universe, document.getElementById('DropDown' + o).value); //Permet d'inscrire des valeurs dans les enregistrements même si l'utilisateur n'en a jamais mis
        }
    }
    //Gestion des radio button //radio button
    for (var r = 0; r < 24; r++){
        try {
            if (GM_getValue('radio' + r + MetaLocal.Universe) === true || GM_getValue('radio' + r + MetaLocal.Universe) === false) {
                console.log("[O-Table Options] : datas from radio" + r + " found : " + GM_getValue('radio' + r + MetaLocal.Universe));
                document.getElementById("radio" + r).checked = GM_getValue('radio' + r + MetaLocal.Universe);
            } else {
                console.log("[O-Table Options] : datas from radio" + r + " not found, default value applied");
            }
        } catch (err) {
        }
    }

    //Ecoute le champ Langue et modifie les valeurs des indicateurs millions/milliards si l'utilisateur change de valeur// Rajouter un case lorsqu'on ajoute une langue
    //ADD A CASE IN THE SWITCH IF YOU ADD A LANGUAGE
    document.getElementById('DropDown1').addEventListener("change", function(event) {
        var UserLanguage = document.getElementById('DropDown1').value;
        switch (UserLanguage) {
            case "0":
                //alert("FR");
                document.getElementById('text11').value = "Md";
                document.getElementById('text12').value = "M";
                document.getElementById('text13').value = "";
                break;
            case "1":
                //alert("EN");
                document.getElementById('text11').value = "Bn";
                document.getElementById('text12').value = "M";
                document.getElementById('text13').value = "";
                break;
            default:
                //alert("Autre");
                break;
        }
    }, true);

    //Mise en mémoire des colonnes cochées dans l'affichage des colonnes (BOUTON ENREGISTRER EN BAS DES OPTIONS)
    document.getElementById('SauvegarderOptions').addEventListener("click", function(event) //Création du bouton permettant la collecte et la sauvegarde des messages
    {

        for (var i = 0; i < 46; i++) { //Boucle pour les checkbox //saves checkboxes
            GM_setValue('column' + i +  MetaLocal.Universe, document.getElementById('cbox' + i).checked);
        }
        for (var l = 0; l < 24; l++) { //Boucle pour la zone "Couleurs" //saves colors
            GM_setValue('color' + l +  MetaLocal.Universe, document.getElementById('color' + l).value);
        }
        for (var n = 0; n < 36; n++) { //Boucle pour les datas de type "texte" //saves text values
            GM_setValue('text' + n +  MetaLocal.Universe, document.getElementById('text' + n).value);
        }
        for (var p = 0; p < 4; p++) { //Boucle pour les dropdown //saves dropdown
            GM_setValue('DropDown' + p +  MetaLocal.Universe, document.getElementById('DropDown' + p).value);
        }
        for (var q = 0; q < 24; q++) { //Boucle pour les radio //saves radio buttons
            GM_setValue('radio' + q +  MetaLocal.Universe, document.getElementById('radio' + q).checked);
        }
        console.log("[O-Table Options] : Options successfully saved!");
        location.reload(); //Rechargement de la page
    }, true);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FONCTIONS DE GESTION ET RECUPERATION DES DONNEES DES MESSAGES////////////////////////////////GET MESSAGE / COMPUTE DATAS///////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Fonction de création du tableau 2D (variable contenant tous les messages)
function MsgBoard()
{
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers
    var MetaLocal = MetaDatas();
// initialisation de la variable indiquant le numéro du RE
    var MessageNumero = 0;
// initialisation de la variable indiquant le nombre de RE
    var IndexDernierMessage = 0; //Numero permet ensuite lorsque l'on crée une seconde vague de récupérer le dernier Message noté
    var DtMsg = 0;
    var i; //Récupération des messages
    var j; //Gestion des secondes vagues
    var k; //Gestion de la vérif si un message est déjà présent
    var Meta = MetaDatas();
    var Table = new Array();
    var Message;
    var MessageStr;
    var NbItemsSaved = GM_getValue('MessageIndex' + MetaLocal.Universe, MessageIndex);
    console.log("[O-Table] : Nb saved messages : " + NbItemsSaved);
    for (i = 0; i < NbItemsSaved; i++) {
        DtMsg = GetStoredRE(MessageNumero);
        //console.log("[O-Table] : Raw spy report" + MessageNumero + " : " + DtMsg);
        if (DtMsg) { //checks if a message with this id (messagenumer) exists
            //console.log("[O-Table] : Message " + MessageNumero + " raw datas : " + DtMsg);
            Message = ConvertStringToObj(DtMsg);
            Message = ComputeMessage(Message);
            if (Message) { //checks if the message has been successfully computed. A message is not computed when he is older than 24 hours, when this happens, Message is empty.
                if (Message.LineColor == '<font color="red">') {
                    Message.LineColor = 'title="' + Langue.VagueSec.split("|||")[LangueIndex] + '"><font color="red">';
                }
                if (Message.Id) {
                    IndexDernierMessage = IndexDernierMessage + 1;
                    Table.push(Message);
                }
            } else {
                //console.log("[O-Table] : A message older than 24hours has been deleted");
            }
        }
        ///////////////////////Console spy table////////////////////////////////////////////////////DEBUG OPTION

        if (Message) {
        console.log("[O-Table] : Spy Table ---- Message N°" + MessageNumero + " : " + Message.CoordPlanete + " --- Age is " + parseInt(Message.AgeSec / 3600) + " --- id is : " + Message.Id );
        } else {
            console.log("[O-Table] : Spy Table ---- Message N°" + MessageNumero + " : EMPTY");
        }
        ///////////////////////End of Console spy table

        MessageNumero = MessageNumero + 1;
        Message = null;
    }
    //Affichage du tableau sous forme de pop-up :
    return Table;
}


function CollectAndStoreRE(){
    console.log("[O-Table] : Script is starting to get messages {CollectAndStoreRE}");
    var StartExec = new Date().getTime();
// initialisation de la variable indiquant le numéro du RE
    var MessageToCollect = 0;
// initialisation de la variable indiquant le nombre de RE
    var NbRE = NbMessages();
    console.log("[O-Table] : Amount of messages in this page : " + NbRE);
    var DtMsg = '';
    var i;
    var j;
    var k;
    var l;
    var MessageSaved = 0;
    var IdToSave = 0;
    var Meta = MetaDatas();
    console.log("[O-Table] : Value of MessageIndex : " + GM_getValue('MessageIndex' + Meta.Universe, MessageIndex));
    var Message = {};
    var MessageStr;
    var MsgCheck;
    var TotalRessourcesVagueSecondaire = 0;
    var IdMessagesSplit = new Array();
    var IdMessageSame = 0; //Cette variable passe à 1 si un id message identique est trouvé
    //Récupération du choix utilisateur concernant les vagues
    if (GM_getValue('column19' + Meta.Universe) === false || GM_getValue('column19' + Meta.Universe) === true) { //Si une valeur a été enregistrée
        var VagueSecondaireYesorNo = GM_getValue('column19' + Meta.Universe);
    } else { //si aucune valeur est enregistrée, par défaut, la variable est true
         var VagueSecondaireYesorNo = true;
    }
    //Récupération du choix utilisateur concernant la renta à partir de laquelle générer des secondes vagues
    if (GM_getValue('text17' + Meta.Universe)) {
        var MontantRentaVagueSecondaire = GM_getValue('text17' + Meta.Universe);
    } else {
        var MontantRentaVagueSecondaire = 400000;
    }
    //Récupération du *taux de commerce* définis par l'utilisateur
    if (GM_getValue('text8' + Meta.Universe)) { // Métal
        var TxX = GM_getValue('text8' + Meta.Universe);
    } else {
        var TxX = 3; //Valeur par défaut
    }
    if (GM_getValue('text9' + Meta.Universe)) { //Cristal
        var TxY = GM_getValue('text9' + Meta.Universe);
    } else {
        var TxY = 2; //Valeur par défaut
    }
    if (GM_getValue('text10' + Meta.Universe)) { //Deut
        var TxZ = GM_getValue('text10' + Meta.Universe);
    } else {
        var TxZ = 1; //Valeur par défaut
    }
    //Get user option choice to choose between standard / msu resources to create secondary waves
    var SecondeVague_StdMSU = 'TotalRessClassique';
    if (GM_getValue('radio18' + Meta.Universe) === true) { //Standard resources
        SecondeVague_StdMSU = 'TotalRessClassique';
    } else {
        if (GM_getValue('radio19' + Meta.Universe) === true) { //MSU resources
            SecondeVague_StdMSU = 'TotalRessUSM';
        }
    }

    GM_addStyle("#CollecterMessages { color: #FFAA00;}");
    MessageIndex = GM_getValue('MessageIndex' + Meta.Universe, MessageIndex); //get amount of SR already stored in the script
    if (GM_getValue('REIdList' + Meta.Universe)) {
        IdMessages = GM_getValue('REIdList' + Meta.Universe, IdMessages);
        IdMessagesSplit = IdMessages.split(":--:");
    } else {
        IdMessages = 0; //this happens when no spy reports are stored in the script
    }
    console.log("[O-Table] : List of SR Ids already stored in the script : " + GM_getValue('REIdList' + Meta.Universe));
    console.log("[O-Table] : Amount of SR already stored in the script (including second waves too) : " + MessageIndex);
    for (i = 0; i < NbRE; i++) {
        DtMsg = RecupDataMessage(MessageToCollect);
        Message = DtMsg;
        if (Message) {
            console.log("[O-Table] : Checking message n°" + i + " just collected in this page, coord is : " + DtMsg.CoordPlanete);
            for (k = 0; k < IdMessagesSplit.length + 1; k++) {//Cette boucle vérifie l'id message du message et si aucun id ne correspond, renvoie 0, si un id correspond, renvoie 1
                if (Message.IdIg != IdMessagesSplit[k]) {
                    IdMessageSame = IdMessageSame + 0;
                } else {
                    IdMessageSame = IdMessageSame + 1;
                    console.log("[O-Table] : Same ID found");
                }
            }
            if (IdMessageSame === 0) { //Si aucun message n'a correspondu, enregistrement du message
                Message.Id = MessageIndex;
                //checks whole spy database of the script. Finds the first place to save a spy report
                //console.log("[O-Table : value of MessageIndex : " + MessageIndex);
                SetStoredRE(MessageIndex, Message);
                //console.log("[O-Table : value of MessageId : " + Message.Id);
                MessageIndex = MessageIndex + 1;
                IdMessages = (IdMessages + ":--:" + Message.IdIg);
                //Gestion des secondes vagues
                if (VagueSecondaireYesorNo) { //Vérifie si l'utilisateur souhaite ou non créer des secondes vagues
                    var VagueSecondaire =  clone(Message); //Attention, pour les bandits, il génère quand même une seconde vague de 0 renta étant donné que l'on trouve plus de 600k renta sur la première...
                    for (j = 0; j < 5; j++) {
                        //TotalRessourcesVagueSecondaire = parseInt((VagueSecondaire.Metal + VagueSecondaire.Cristal + VagueSecondaire.Deuterium) * (1 - VagueSecondaire.Butin) * VagueSecondaire.Butin); //We remove the looted value from wave one and we compute with what's still there what we will take by using ratio
                        //VagueSecondaire.TotalRessClassique = parseInt((VagueSecondaire.Metal + VagueSecondaire.Cristal + VagueSecondaire.Deuterium) * VagueSecondaire.Butin / 2); old formula
                        VagueSecondaire.TotalRessClassique = parseInt((VagueSecondaire.Metal + VagueSecondaire.Cristal + VagueSecondaire.Deuterium) * (1 - VagueSecondaire.Butin) * VagueSecondaire.Butin);
                        VagueSecondaire.TotalRessUSM = parseInt((VagueSecondaire.Metal + VagueSecondaire.Cristal * (TxX / TxY) + VagueSecondaire.Deuterium * (TxX / TxZ)) * (1 - VagueSecondaire.Butin) * VagueSecondaire.Butin);
                        //alert("Standard : " + VagueSecondaire.TotalRessClassique + " , USM : " + VagueSecondaire.TotalRessUSM);
                        if ( VagueSecondaire[SecondeVague_StdMSU] > (MontantRentaVagueSecondaire)) {
                            //alert(TotalRessourcesVagueSecondaire + '+++' + VagueSecondaire.CoordPlanete);
                           if (parseInt(VagueSecondaire.Metal * (1 - VagueSecondaire.Butin)) + parseInt(VagueSecondaire.Cristal * (1 - VagueSecondaire.Butin)) + parseInt(VagueSecondaire.Deuterium * (1 - VagueSecondaire.Butin)) > 0) {
                                VagueSecondaire.Metal = parseInt(VagueSecondaire.Metal * (1 - VagueSecondaire.Butin));
                                VagueSecondaire.Cristal = parseInt(VagueSecondaire.Cristal * (1 - VagueSecondaire.Butin));
                                VagueSecondaire.Deuterium = parseInt(VagueSecondaire.Deuterium * (1 - VagueSecondaire.Butin));
                                VagueSecondaire.LineColor = '<font color="red">';
                                VagueSecondaire.VagueSecondaire = 1; //Indicator to know if message is a secondary wave or not
                               //console.log("[O-Table : value of MessageIndex : " + MessageIndex);
                                VagueSecondaire.Id = MessageIndex;
                               //console.log("[O-Table : value of VagueSecId : " + VagueSecondaire.Id);
                               //MessageSaved = 0;
                                SetStoredRE(MessageIndex, VagueSecondaire);
                                MessageIndex = MessageIndex + 1;
                           } else {
                               j = 10;
                           }
                        } else {
                            j = 10;
                        }
                    }
                }
            }
        }
        IdMessageSame = 0;
        GM_setValue('REIdList' + Meta.Universe, IdMessages);
        MessageToCollect = MessageToCollect + 1;
        Message = null;
    }
    //alert(MessageToCollect + 'Messages Analysés' + ', Valeur du premier message : ' + GetStoredRE(1));
    //alert(MessageIndex);
    GM_setValue('MessageIndex' + Meta.Universe, MessageIndex);
    //alert(GM_getValue('MessageIndex'+Meta.Universe, MessageIndex));

    var EndExec = new Date().getTime();
    var TimeExec = EndExec - StartExec;
    console.log('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXECUTION COLLECT : ' + TimeExec + 'ms    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
    //Indique à l'utilisateur que la collecte s'est bien executée en passant la couleur du texte du bouton "collecter messages" en vert (avec personnalisation de couleur)
    if ((GM_getValue('color13' + Meta.Universe))) {
        GM_addStyle("#CollecterMessages { color: #" + GM_getValue('color13' + Meta.Universe) + ";}");
    } else {
        GM_addStyle("#CollecterMessages { color: #00FF00;}");
    }
    setTimeout(function() { GM_addStyle("#CollecterMessages { color: inherit;}");}, 750);
}


//Fonction de récupération des messages et de leurs infos //This function collects data from a selected spy report
function RecupDataMessage(MessageNumber)
{
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers


    //Récupération des messages
    var ImproveV6 = 0;
    var AllMessages = document.querySelectorAll("li.msg");
    // Ressources du message
    var Message;
    if(AllMessages[MessageNumber].querySelectorAll('.espionageDefText').length === 0) {
        // Récupération des données Meta (utile pour savoir l'univers) :
        var Meta = MetaDatas();
        // Récupération des data messages
        Message = AllMessages[MessageNumber].querySelectorAll("span.resspan");
        Message.API = (/(sr-[0-9a-z\-]+)/.exec(AllMessages[MessageNumber].querySelectorAll(".icon_apikey")[0].title)[0]);
        Message.IdIg = AllMessages[MessageNumber].getAttribute('data-msg-id');
        Message.Metal = Message[0].textContent;
        Message.Metal = Message.Metal.split(":");
        Message.Metal = Message.Metal[1];
        Message.Metal = parseInt(ConvertRENumbers(Message.Metal)); //Appel de la fonction de transformation des nombres
        Message.Cristal = Message[1].textContent;
        Message.Cristal = Message.Cristal.split(":");
        Message.Cristal = Message.Cristal[1];
        Message.Cristal = parseInt(ConvertRENumbers(Message.Cristal));
        Message.Deuterium = Message[2].textContent;
        Message.Deuterium = Message.Deuterium.split(":");
        Message.Deuterium = Message.Deuterium[1];
        Message.Deuterium = parseInt(ConvertRENumbers(Message.Deuterium));
        // Coordonnées de la planète
        Message.BlueTitle = AllMessages[MessageNumber].querySelector("span.msg_title");
        Message.CoordPlanete = Message.BlueTitle.textContent;
        Message.CoordPlanete = (/[[0-9]+:[0-9]+:[0-9]+]/.exec( Message.CoordPlanete));
        Message.CoordPlanete = (/[0-9]+:[0-9]+:[0-9]+/.exec( Message.CoordPlanete)); //I decided to put a double check to prevent wrong planet names (example, a planet named "3:158:8" would generate an error without this double check. Secondary check is only useful to remove the "[""]" inside the coordinates.
        //Message.CoordPlanete = Message.CoordPlanete.split("[");
        //Message.CoordPlanete = Message.CoordPlanete[1].split("]");
        //Message.CoordPlanete = Message.CoordPlanete[0];
        //Butin Possible, Activité, Nom du joueur, Flotte/Def
        Message.CTN = AllMessages[MessageNumber].querySelectorAll("span.ctn.ctn4");
        try { //Vérification de la présence de ImproveV6 - Initialisation de la variable ImproveV6 indispensable aux vérifications suivantes
            if (AllMessages[MessageNumber].querySelectorAll("span.addGT")[0].textContent) {
                Message.Butin = Message.CTN[5].textContent;
                ImproveV6 = 1;
            }
        } catch(err) {
            Message.Butin = Message.CTN[4].textContent;
        }
        //Transformation de la flotte, try permet d'analyser si la flotte est visible ou non
        try {
            if (ImproveV6 === 0) { //Vérifie la présence de ImproveV6
                Message.Flotte = Message.CTN[5].textContent;
            } else {
                Message.Flotte = Message.CTN[6].textContent;
            }
            Message.Flotte = Message.Flotte.split(":");
            Message.Flotte = Message.Flotte[1];
            Message.FlotteFinal = parseInt(ConvertRENumbers(Message.Flotte));
            Message.FlotteDisplayed = ThousandSeparator(Message.FlotteFinal);
        } catch(err) {
            Message.FlotteFinal = -1; //Permet de quand même afficher le RE et de faire des tris dessus
            Message.FlotteDisplayed = '<span style="color:#ff0000">?</span>';
        }
        //Transformation des défenses, try permet d'analyser si la défense est visible ou non
        try {
            if (ImproveV6 === 0) { //Vérifie la présence de ImproveV6
                Message.Defense = Message.CTN[6].textContent;
            } else {
                Message.Defense = Message.CTN[7].textContent;
            }
            Message.Defense = Message.Defense.split(":");
            Message.Defense = Message.Defense[1];
            Message.DefenseFinal = parseInt(ConvertRENumbers(Message.Defense));
            Message.DefenseDisplayed = ThousandSeparator(Message.DefenseFinal);
        } catch(err) {
            Message.DefenseFinal = -1;//Permet de quand même afficher le RE et de faire des tris dessus
            Message.DefenseDisplayed = '<span style="color:#ff0000">?</span>';
        }
        //Transformation du butin (ratio de butin, attention) ex : 0.5
        Message.Butin = Message.Butin.replace(/[^0-9.]/g, "");
        Message.Butin = Message.Butin / 100;
        //Transformation de l'activité
        if (ImproveV6 === 0) { //Vérifie la présence de ImproveV6
            Message.Activite = Message.CTN[1].textContent.split(":")[1].split(" ")[1];
        } else {
            Message.Activite = Message.CTN[2].textContent.split(":")[1].split(" ")[1];
        }
        switch (Message.Activite) {
            case ">60":
                Message.Activite = '';
                break;
            case "<15":
                Message.Activite = '(<span style="color:#ff0000"><15</span>)';
                break;
            default:
                Message.Activite = '(<span style="color:#ff8080">' + Message.Activite +'</span>)';
                break;
        }
        //Récupération de la date et de l'age du RE
        Message.Date = AllMessages[MessageNumber].querySelectorAll("span.msg_date");
        Message.Date = Message.Date[0].textContent;
        Message.Player= AllMessages[MessageNumber].querySelectorAll(".compacting")[0].querySelectorAll("span")[1].textContent; //Récupération du joueur
        //Elimination des espaces devant le joueur
        Message.Player = Message.Player.substring(2);
        Message.PlayerStatus= AllMessages[MessageNumber].querySelectorAll(".compacting")[0].querySelectorAll("span")[1].className; //Récupération du status joueur
        //Vérification du status du joueur afin de lui attribuer la bonne couleur dans le tableau
        switch(Message.PlayerStatus) {
            case "status_abbr_longinactive":
                //alert("Long Inactif");
                Message.PlayerColor = 0;
                break;
            case "status_abbr_inactive":
                //alert("Inactif");
                Message.PlayerColor = 1;
                break;
            case "status_abbr_active":
                //alert("Actif non honorable");
                Message.PlayerColor = 2;
                break;
            case "status_abbr_honorableTarget":
                //alert("Actif honorable");
                Message.PlayerColor = 3;
                break;
            case "status_abbr_outlaw":
                //alert("Actif Hors la loi");
                Message.PlayerColor = 4;
                break;
            case "status_abbr_vacation":
                //alert("Joueur en MV");
                Message.PlayerColor = 5;
                break;
            case "status_abbr_noob":
                //alert("Joueur débutant");
                Message.PlayerColor = 6;
                break;
            case "status_abbr_strong":
                //alert("Joueur fort");
                Message.PlayerColor = 7;
                break;
        }
        //Recherche d'un statut honorifique et attribue "Nothing" lorsqu'il ne trouve rien
        try {
            Message.PlayerIcon = '&nbsp;<span class="' + AllMessages[MessageNumber].querySelectorAll("span.honorRank")[0].className.split(" tooltip")[0] +'">&nbsp;</span>'; //Récupère les deux premiers noms de class attribués à ce span pour attribuer l'icône correspondant au statut joueur
            Message.Player = Message.Player.substring(1); //Elimine l'espace supplémentaire qu'il y a devant un joueur ayant un icône
        }
        catch(err) {
            Message.PlayerIcon = ''; //Lorsque qu'aucun icône est trouvé, on laisse cet attribut vide
        }
        //Récupération de l'icône lune
        try {
            Message.ClassMoon = AllMessages[MessageNumber].querySelectorAll("figure.planetIcon.moon")[0].className;
            Message.Moon = 3;
        } catch(err) {
            Message.Moon = 1;
        }
        Message.LineColor = 'title="' + Langue.VaguePri.split("|||")[LangueIndex] + '"><font color="white">'; //Permet d'attribuer une couleur au numéro de ligne, blanc lorsqu'il s'agit d'une première vague et jaune quand il s'agit d'une vague secondaire (pas géré ici)
        //Appel de la fonction qui effectue les calculs dans les messages
        Message.Display = 1; //Permet d'indiquer si le message doit être affiché ou non sur le tableau final,
        Message.PTAttacked = 0;
        Message.GTAttacked = 0;
        Message.RCRecycled = 0;
        Message.VagueSecondaire = 0; //Indicator to know if message is a secondary wave or not
        //Sortie des variables
        return Message;
    }
}

//Fonction utilisée pour effectuer les calculs de données dans les messages //This function is used to compute datas inside messages
function ComputeMessage(Message) {
    var Meta = MetaDatas();
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers
    //Récupération du choix qu'a mis l'utilisateur dans "envoyer plus de flotte que nécessaire"
    if (GM_getValue('DropDown0' + Meta.Universe)) {
        var ShipMore = GM_getValue('DropDown0' + Meta.Universe);
    } else {
        var ShipMore = 20; //Valeur par défaut
    }
    //Récupération des techs de l'utilisateur
    if (GM_getValue('text14' + Meta.Universe)) { // Réacteur à combu
        var Combu = GM_getValue('text14' + Meta.Universe);
    } else {
        var Combu = 0; //Valeur par défaut
    }
    if (GM_getValue('text15' + Meta.Universe)) { // Réacteur à impu
        var Impu = GM_getValue('text15' + Meta.Universe);
    } else {
        var Impu = 0; //Valeur par défaut
    }
    if (GM_getValue('text16' + Meta.Universe)) { // Prop
        var Prop = GM_getValue('text16' + Meta.Universe);
    } else {
        var Prop = 0; //Valeur par défaut
    }
    if (GM_getValue('text22' + Meta.Universe)) { //Armes
        var Weapons = GM_getValue('text22' + Meta.Universe);
    } else {
        var Weapons = 0; //Valeur par défaut
    }
    if (GM_getValue('text23' + Meta.Universe)) { //Bouclier
        var Shield = GM_getValue('text23' + Meta.Universe);
    } else {
        var Shield = 0; //Valeur par défaut
    }
    if (GM_getValue('text24' + Meta.Universe)) { //Protection
        var Armour = GM_getValue('text24' + Meta.Universe);
    } else {
        var Armour = 0; //Valeur par défaut
    }
    //Récupération du *taux de commerce* défini par l'utilisateur
    if (GM_getValue('text8' + Meta.Universe)) { // Métal
        var TxX = GM_getValue('text8' + Meta.Universe);
    } else {
        var TxX = 3; //Valeur par défaut
    }
    if (GM_getValue('text9' + Meta.Universe)) { //Cristal
        var TxY = GM_getValue('text9' + Meta.Universe);
    } else {
        var TxY = 2; //Valeur par défaut
    }
    if (GM_getValue('text10' + Meta.Universe)) { //Deut
        var TxZ = GM_getValue('text10' + Meta.Universe);
    } else {
        var TxZ = 1; //Valeur par défaut
    }
    if (GM_getValue('text25' + Meta.Universe)) { //Get user defined amount of solar systems per galaxies
        var NbSS = GM_getValue('text25' + Meta.Universe);
    } else {
        var NbSS = 499;//Default value
    }
    NbSS = parseInt(NbSS);
    if (GM_getValue('text26' + Meta.Universe)) { //Get user defined amount of galaxies in the universe
        var NbG = GM_getValue('text26' + Meta.Universe);
    } else {
        var NbG = 9;//Default value
    }
    NbG = parseInt(NbG);
    /////////////////////////////////////////////////////This part is to colorize values in spy reports line when a value reaches a defined critieria
    if (GM_getValue('color5' + Meta.Universe)) {                                    //Color for profits standard (Loot)
        var LootColor = GM_getValue('color5' + Meta.Universe);
    } else {
        var LootColor = "00FF00" //Default value
    }
    if (GM_getValue('text0' + Meta.Universe)) {                                           //Minimum amount of profits in Loot to colorize in #color5#
        var MinProfitsToColorize = GM_getValue('text0' + Meta.Universe);
    } else {
        var MinProfitsToColorize = 1000000;//Default value
    }
    if (GM_getValue('color10' + Meta.Universe)) {                                       //Color for profits USM (LootUSM)
        var LootUSMColor = GM_getValue('color10' + Meta.Universe);
    } else {
        var LootUSMColor = "00FF00" //Default value
    }
    if (GM_getValue('text19' + Meta.Universe)) {                              //Minimum amount of profits in Loot to colorize in #color10#
        var MinProfitsUSMToColorize = GM_getValue('text19' + Meta.Universe);
    } else {
        var MinProfitsUSMToColorize = 1000000;//Default value
    }
    if (GM_getValue('color8' + Meta.Universe)) {                                //Minimum age to colorize (COLOR)
        var AgeColor = GM_getValue('color8' + Meta.Universe);
    } else {
        var AgeColor = "FF0000";
    }
    if (GM_getValue('text3' + Meta.Universe)) {                                 //Minimum age to colorize (Fleet)
        var MinAgeToColorize = GM_getValue('text3' + Meta.Universe);
    } else {
        var MinAgeToColorize = 2; //Default value
    }
    if (GM_getValue('text1' + Meta.Universe)) {                                 //Minimum fleet to colorize (Fleet)
        var MinFleetToColorize = GM_getValue('text1' + Meta.Universe);
    } else {
        var MinFleetToColorize = 1000000; //Default value
    }
    if (GM_getValue('text1' + Meta.Universe)) {                                 //Minimum def to colorize (Def)
        var MinDefToColorize = GM_getValue('text2' + Meta.Universe);
    } else {
        var MinDefToColorize = 1000000; //Default value
    }
    //Checks if user wants to compute missile profits with standard or MSU --> use a different propriety for each case
    var MIP_Profits_StdMSU = 0; // 0 = Standard resources
    if (GM_getValue('radio16' + Meta.Universe) === true) { //Standard resources
        MIP_Profits_StdMSU = 0; // 0 = Standard resources
    } else {
        if (GM_getValue('radio17' + Meta.Universe) === true) { //MSU resources
            MIP_Profits_StdMSU = 1; //1 = MSU resources
        }
    }
    if (GM_getValue('text27' + Meta.Universe)) {                                 //Minimum profits/hour to colorize (Profits/Hour)
        var MinProfitsHourToColorize = GM_getValue('text27' + Meta.Universe);
    } else {
        var MinProfitsHourToColorize = 1000000; //Default value
    }
        if (GM_getValue('color11' + Meta.Universe)) {                                //profits/hour to colorize (COLOR)
        var ProfitsHourColor = GM_getValue('color11' + Meta.Universe);
    } else {
        var ProfitsHourColor = "00FF00";
    }

    //Used to know if user wants to use "display players that are profitables after sending missiles" feature
    if (GM_getValue('column32' + Meta.Universe) === false || GM_getValue('column32' + Meta.Universe) === true) { //DisplayMissiles
        var ComputeMIPProfits = GM_getValue('column32' + Meta.Universe);
    } else {
        var ComputeMIPProfits = false;//Default value if no data has been found
    }
    //To know if user wants shorter age or complete age
    if (GM_getValue('column34' + Meta.Universe) === true) {
        var SmallerAge = true;
    } else {
        var SmallerAge = false;
    }
    //Used to know what is the minimum amount of distance in GALAXIES used to colorize coordinates
    if (GM_getValue('text34' + Meta.Universe)) {                                 //Minimum def to colorize (Def)
        var MinGtoColorize = GM_getValue('text34' + Meta.Universe);
    } else {
        var MinGtoColorize = 1; //Default value
    }
    //Used to know what is the minimum amount of distance in SOLAR SYSTEMS used to colorize coordinates
    if (GM_getValue('text35' + Meta.Universe)) {                                 //Minimum def to colorize (Def)
        var MinSStoColorize = GM_getValue('text35' + Meta.Universe);
    } else {
        var MinSStoColorize = 50; //Default value
    }


    var TravelTimeType = 1; //This variable is used to know if we want to display the travel or the travel+back time (1=travel, 2=travel+back)
    //If to to know, on the travel time column, if we display only the travel time or if we display the travel + back time (1=travel, 2=travel+back)
    if (GM_getValue('radio0' + Meta.Universe) === true) {
        TravelTimeType = 1;
    } else {
        if (GM_getValue('radio1' + Meta.Universe) === true) {
            TravelTimeType = 2;
        }
    }



	//Gestion de l'âge
    Message.Annee = Message.Date.split(" ")[0].split(".")[2];
    Message.Mois = Message.Date.split(" ")[0].split(".")[1];
    Message.Jour = Message.Date.split(" ")[0].split(".")[0];
    Message.Heure = Message.Date.split(" ")[1].split(":")[0];
    Message.Minute = Message.Date.split(" ")[1].split(":")[1];
    Message.Seconde = Message.Date.split(" ")[1].split(":")[2];
    Message.DateStamp = (new Date(Message.Annee + "/" + Message.Mois + "/" + Message.Jour + " " + Message.Heure + ":" + Message.Minute + ":" + Message.Seconde).getTime()) / 1000;
    Message.AgeSec = Meta.Timestamp - Message.DateStamp;
    Message.AgeDisplayed = secondsToHms(Message.AgeSec);
    if (SmallerAge === true) { //only keep the left part (bigger unit) of time, when user selects "reduced size" on age column
        Message.AgeDisplayed = ">" + Message.AgeDisplayed.split(" ")[0];
    }
    //console.log(Message.AgeSec);
    if ((Message.AgeSec / 3600) >= MinAgeToColorize) {
        Message.AgeDisplayed = '<font color="' + AgeColor + '">' + Message.AgeDisplayed + '</font>'; //Colorize Age in user selected color when a spy report is older than user defined age
    } else {
        Message.AgeDisplayed = '<font>' + Message.AgeDisplayed + '</font>'; //This happens when SR is younger than expected
    }

    //Deletes the SR if the SR is older than one day
    if (Message.AgeSec > 86400) {
        //console.log("[O-Table] : This SR (" + Message.CoordPlanete + ") is older than 24 hour, it will be deleted");
        DelOldSR(Message);
        return;
    }


    //Gestion des ressources
    Message.MetalDisplayed = ThousandSeparator(Message.Metal);
    Message.MetalPille = parseInt(Message.Metal * Message.Butin)
    Message.MetalPilleDisplayed = ThousandSeparator(Message.MetalPille);
    Message.CristalDisplayed = ThousandSeparator(Message.Cristal);
    Message.CristalPille = parseInt(Message.Cristal * Message.Butin)
    Message.CristalPilleDisplayed = ThousandSeparator(Message.CristalPille);
    Message.DeuteriumDisplayed = ThousandSeparator(Message.Deuterium);
    Message.DeuteriumPille = parseInt(Message.Deuterium * Message.Butin);
    Message.DeuteriumPilleDisplayed = ThousandSeparator(Message.DeuteriumPille);
    Message.Total = parseInt(Message.Metal) + parseInt(Message.Cristal) + parseInt(Message.Deuterium);
    Message.TotalDisplayed = ThousandSeparator(Message.Total);


    //Gestion des CDR et du nombre de recycleurs
    Message.CDRFlotte = parseInt(Message.FlotteFinal * (Meta.TxCDRFleet / 100));
    Message.CDRFlotteDisplayed = ThousandSeparator(Message.CDRFlotte);
    Message.CDRFlotteRC = parseInt(Message.CDRFlotte / 20000);
    if (Message.CDRFlotteRC > 0) { //Adds 1 more recycler needed when debris field is bigger than 0
        Message.CDRFlotteRC = Message.CDRFlotteRC + 1;
    }
    Message.CDRFlotteRCDisplayed = ThousandSeparator(Message.CDRFlotteRC);
    Message.CDRDefense = (Message.DefenseFinal * (Meta.TxCDRDef / 100));
    Message.CDRDefRC = parseInt(Message.CDRDefense / 20000);
    if (Message.CDRDefRC > 0) { //Adds 1 more recycler needed when debris field is bigger than 0
        Message.CDRDefRC = Message.CDRDefRC + 1;
    }
    Message.TotalRC = Message.CDRFlotteRC + Message.CDRDefRC;
    Message.TotalCDR = Message.CDRFlotte + Message.CDRDefense;
    Message.CDRDefenseRCDisplayed = ThousandSeparator(Message.CDRDefRC);
    Message.CDRDefenseDisplayed = ThousandSeparator(Message.CDRDefense);


    //Missiles sim
    /*
    if (Message.VagueSecondaire == 1) {
        Message.DefenseToMip = 0;
    } else {
        Message.DefenseToMip = Message.DefenseFinal;
    }
    */
    if (Message.DefenseFinal > 0) {
        Message.MIP = parseInt(Message.DefenseFinal / 120000); //Missiles simulation is based from amount of units and not structure points (as this value isn't findable in spy reports).
        Message.MIPDisplayed = ThousandSeparator(Message.MIP);
    } else {
        Message.MIP = 0;
        Message.MIPDisplayed = 0;
    }
    Message.MIPM = Message.MIP * 12500; //Metal cost
    Message.MIPC =  Message.MIP * 2500; //Cristal cost
    Message.MIPD = Message.MIP * 10000; //Deut cost
    Message.MIPMDisplayed = ThousandSeparator(Message.MIPM);
    Message.MIPCDisplayed = ThousandSeparator(Message.MIPC);
    Message.MIPDDisplayed = ThousandSeparator(Message.MIPD);
    Message.MIPCost = parseInt(Message.MIP * 25000);
    Message.MIPCostDisplayed = ThousandSeparator(Message.MIPCost);
    Message.MIPCostUSM = parseInt(Message.MIPM * TxZ + Message.MIPC * TxY + Message.MIPD * TxX);
    Message.MIPCostUSMDisplayed = ThousandSeparator(Message.MIPCostUSM);



	//Gestion de la galaxie de provenance du joueur
    Message.CoordSplit = Message.CoordPlanete.split(":");
    Message.CoordGalaxie = parseInt(Message.CoordSplit[0]);
    Message.CoordSS = parseInt(Message.CoordSplit[1]);
    Message.CoordPos = parseInt(Message.CoordSplit[2]);
    Message.RawCoord = (Number(Message.CoordGalaxie) * 1000000 + Number(Message.CoordSS) * 100 + Number(Message.CoordPos));

    //Mise en minuscule du nom du joueur (utile pour le tri)
    Message.PlayerMin = Message.Player.toLowerCase();



	//Calcul du pillage
    Message.Loot = parseInt((Message.Total * Message.Butin));
    if (Message.Loot >= MinProfitsToColorize) { //Colorize Loot in this line in "user selected color" when it's bigger than "user selected minium amount of profits"
        Message.LootDisplayed = '<font color="' + LootColor + '">' + ThousandSeparator(Message.Loot) + '</font>';
    } else {
        Message.LootDisplayed = '<font>' + ThousandSeparator(Message.Loot) + '</font>';
    }

	//calcul du nombre PT et GT
    Message.NbPT = parseInt(Message.Loot / 5 * (1 + ShipMore / 100) + 1);
    Message.NbPTDisplayed = ThousandSeparator(Message.NbPT);
    Message.NbGT = parseInt(Message.Loot / 25000 * (1 + ShipMore / 100) + 1);
    Message.NbGTDisplayed = ThousandSeparator(Message.NbGT);

    //Création des liens PT et GT et galaxie
    Message.LienPT = ('https://' + Meta.Universe + '/game/index.php?page=fleet1&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=' + Message.Moon + '&mission=1&routine=3&am210=' + Message.NbPT);
    Message.LienGT = ('https://' + Meta.Universe + '/game/index.php?page=fleet1&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=' + Message.Moon + '&mission=1&routine=3&am203=' + Message.NbGT);
    Message.LienRC = ('https://' + Meta.Universe + '/game/index.php?page=fleet1&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=2&am209=' + Message.TotalRC);
    Message.LienGalaxie = ('https://' + Meta.Universe + '/game/index.php?page=galaxy&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos);
    Message.LienDetails = ('https://' + Meta.Universe + '/game/index.php?page=messages&messageId=' + Message.IdIg + '&tabid=20&ajax=1');
    Message.Simulation = ('http://topraider.eu/index.php?SR_KEY=' + Message.API + '&combu=' + Combu + '&impu=' + Impu + '&prop=' + Prop + '&arme=' + Weapons + '&bouclier=' + Shield + '&protect=' + Armour + '&speed=' + Meta.UniverseFleetSpeed);

    //Vérification de si la planète est une lune ou non - - Checks if the planet is a moon or not
    Message.IsPlanetOrMoon = Message.Moon
    if (Message.Moon == 3) {
        Message.Moon = '<figure class="planetIcon moon tooltip js_hideTipOnMobile" >&nbsp;</figure>';
    } else {
        Message.Moon = '';
    }

    //MSU Loot Value
    Message.USMPille = parseInt(Message.MetalPille + Message.CristalPille * (TxX / TxY) + Message.DeuteriumPille * (TxX / TxZ));
    if (Message.USMPille >= MinProfitsUSMToColorize) { //Colorize Loot in this line in "user selected color" when it's bigger than "user selected minium amount of profits USM"
        Message.USMPilleDisplayed ='<font color="' + LootUSMColor + '">' + ThousandSeparator(Message.USMPille) + '</font>';
    } else {
        Message.USMPilleDisplayed = '<font>' + ThousandSeparator(Message.USMPille) + '</font>'; //When loot usm value is smaller than expected
    }
    //End of MSU Loot Value

    if (ComputeMIPProfits === true) {
        Message.USMPilleMIP = Message.USMPille - Message.MIPCostUSM;
        Message.LootMIP = Message.Loot - Message.MIPCost;
    } else {
        Message.USMPilleMIP = 0;
        Message.LootMIP = 0;
    }


    //Colorization of fleet value
    if (Message.FlotteFinal >= MinFleetToColorize) {
        Message.FlotteDisplayed = '<font class="FltColorized FltDefCtn">' + Message.FlotteDisplayed + '</font>';
    } else {
        Message.FlotteDisplayed = '<font class="FltDefCtn">' + Message.FlotteDisplayed + '</font>'; //Style used to colorize fleet value in table when value is smaller than user defined minimum amount of fleet
    }
    //Colorization of def value
    if (MIP_Profits_StdMSU == 0) {//Temp value, used to colorize defense
        var ProfitsMIP = Message.Loot - Message.MIPCost;
    } else {
        var ProfitsMIP = Message.USMPille - Message.MIPCostUSM;
    }

    if (ProfitsMIP > 0) {
        if (Message.MIPCost > 0) {
            Message.DefenseDisplayed = '<font class="DefMissilesColorized FltDefCtn">' + Message.DefenseDisplayed + '</font>';
            //The script comes here when player defense is profitable to send missiles
        } else {
            Message.DefenseDisplayed = '<font class="FltDefCtn">' + Message.DefenseDisplayed + '</font>'; //Default
            //The script comes here when player defense is equal to 0
        }
    } else {
        if (Message.DefenseFinal >= MinDefToColorize) {
            Message.DefenseDisplayed = '<font class="DefColorized FltDefCtn">' + Message.DefenseDisplayed + '</font>';
            //The script comes here when player defense isn't profitable to destroy with missiles and defense is bigger than user defined amount of def to colorize it
        } else {
            Message.DefenseDisplayed = '<font class="FltDefCtn">' + Message.DefenseDisplayed + '</font>'; //Style used to colorize fleet value in table when value is smaller than user defined minimum amount of def
            //The script comes here when player defense isn't profitable to destroy with missiles and defense is smaller than user defined amount of def to colorize it
        }
    }



    //Total amount of resources that is possible to get with this spy report
    Message.TotalCDRRes = Message.TotalCDR + Message.Loot;
    Message.TotalCDRResUSM = Message.TotalCDR + Message.USMPille;


    //Gestion vitesse PT
    if (Impu >= 5) {
        var PTSpeed = 10000 * (1 + 2 * Impu / 10);
    } else {
        var PTSpeed = 5000 * (1 + Combu / 10);
    }
    //Gestion vitesse GT
    var GTSpeed = 7500 * (1 + Combu / 10);
    Message.TempsTrajetPT = 0;

    //Récupération de la galaxie, ss et pos actuels
    var PlayerG = parseInt(Meta.PlayerCoord.split(":")[0]);
    var PlayerSS = parseInt(Meta.PlayerCoord.split(":")[1]);
    var PlayerPos = parseInt(Meta.PlayerCoord.split(":")[2]);
    var FleetSpeed = parseInt(Meta.UniverseFleetSpeed);
    //alert(typeof PlayerG + typeof PlayerSS + typeof PlayerPos);

    ////////////////////////////////////////////////////////////////////////////////
    //Calcule la distance parcourue (Amount of galaxies//solar systems//positions travelled
    //I know this part of the script is hard to follow, if you want to manually test, take a sheet of paper and try it :)
    var Gtraversees = Math.abs(PlayerG - Message.CoordGalaxie); //Nombre de galaxies traversées pour arriver à destination (ne tient pas en compte les unis circulaires) //amount of galaxies travelled to go to the desintation (don't care of circular universes)
    var SStraverses = Math.abs(PlayerSS - Message.CoordSS); //amount of SS travelled to go to the desintation (don't care of circular universes)
    var Postraversees = Math.abs(PlayerPos - Message.CoordPos); //amount of SS travelled to go to the desintation (don't care of circular universes)
    //alert(typeof Gtraversees + typeof SStraverses + typeof Postraversees + typeof NbG);
    Message.Gtraversees = Gtraversees;
    Message.SStraverses = SStraverses;
    Message.Postraversees = Postraversees;
    //alert(typeof Message.Gtraversees + typeof Message.SStraverses + typeof Message.Postraversees);
    Message.CoordPlanete_Colored = ''; //no specific class for coordplanete

    var CoordColorIndicator = 0;
    if (Gtraversees >= MinGtoColorize) {
        Message.CoordPlanete_Colored = 'Table_GCoords_Colored'; //specific class to colorize coordinates in user specified color (depends of color22/text34 in options)
        CoordColorIndicator = 1;
    }
    if (SStraverses >= MinSStoColorize & CoordColorIndicator === 0) {
        Message.CoordPlanete_Colored = 'Table_SSCoords_Colored'; //specific class to colorize coordinates in user specified color (depends of color23/text35 in options)
    }
    if (Gtraversees != 0) {
        if (Meta.GalaxiesCirculaires == 1) { //Checks if the universe has circular galaxies or not
            //If the amount of galaxies to travel is longer than half of the universe, that means the fleet has to use the circular universe functionality, for this, we need to check the value
            //Example : PlayerG (current player coord) = G9, Message.CoordGalaxie (current spy report coord) = G1, amount of galaxies = 11.
            var NbG_if = NbG / 2 //Example : 11/2
            if (Gtraversees > NbG_if) { //Example : Gtraversees = 9-1 = 8, 8 > (11/2), IF OK
                //if the script is here, that means the amount of galaxies to travel is bigger than half of the universe
                Gtraversees = 0;
                if (PlayerG > Message.CoordGalaxie) { //Example : 9 > 1
                    Gtraversees = NbG + Message.CoordGalaxie; //Example : Gtraversees = 11 + 1 = 12
                    Message.Gtraversees = Gtraversees - PlayerG; //Example : Gtraversses = 12 - 9 = 3 >>>> G9>G10>G11>G1 = 3 galaxies traveled
                } else {
                    if (PlayerG < Message.CoordGalaxie) {
                        Gtraversees =  NbG -  Message.CoordGalaxie;
                        Message.Gtraversees =  Gtraversees +  PlayerG;
                        //alert(Gtraversees + ',' + NbG + ',' + PlayerG + ',' + Message.CoordGalaxie);
                    }
                }
            }
        }
        //If Gtraversees hasn't been modified yet, that's because the amount of galaxies to travel is smaller than half of the universe. By the way, at this part of the script, Gtraversees is always smaller than half of the universe if we are in a circular universe.
        Message.SStraverses = 0;
        Message.Postraversees = 0;
        Message.TempsTrajetPT = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / PTSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
        Message.TempsTrajetPT_A = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / PTSpeed)))) / FleetSpeed);
        Message.TempsTrajetPT_AR = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / PTSpeed)))) / FleetSpeed) * 2;
        Message.TempsTrajetGT = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / GTSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for heavy cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
        Message.TempsTrajetGT_A = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / GTSpeed)))) / FleetSpeed);
        Message.TempsTrajetGT_AR = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / GTSpeed)))) / FleetSpeed) * 2;
    } else {
        if (SStraverses != 0) {
            if (Meta.SystemesCirculaires == 1) { //Checks if the universe has circular systems or not
                var NbSS_if = NbSS / 2;
                if (SStraverses > NbSS_if) {
                    SStraverses = 0;
                    if (PlayerSS > Message.CoordSS) {
                        SStraverses =  NbSS +  Message.CoordSS;
                        Message.SStraverses =  SStraverses -  PlayerSS;
                    } else {
                        if (PlayerSS < Message.CoordSS) {
                            SStraverses =  NbSS -  Message.CoordSS;
                            Message.SStraverses =  SStraverses +  PlayerSS;
                        }
                    }
                }
            }
            Message.Postraversees = 0;
            Message.TempsTrajetPT = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(PTSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
            Message.TempsTrajetPT_A = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(PTSpeed)))) / FleetSpeed);
            Message.TempsTrajetPT_AR = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(PTSpeed)))) / FleetSpeed) * 2;
            Message.TempsTrajetGT = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(GTSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for heavy cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
            Message.TempsTrajetGT_A = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(GTSpeed)))) / FleetSpeed);
            Message.TempsTrajetGT_AR = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(GTSpeed)))) / FleetSpeed) * 2;
        }  else {
            if (Postraversees != 0) {
                if (PlayerPos > Message.CoordPos) {
                    Message.Postraversees = PlayerPos - Message.CoordPos;
                } else {
                    if (PlayerPos < Message.CoordPos) {
                        Postraversees = 0;
                        Message.Postraversees = Message.CoordPos - PlayerPos;
                    }
                }
                Message.TempsTrajetPT = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / FleetSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
                Message.TempsTrajetPT_A = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / FleetSpeed);
                Message.TempsTrajetPT_AR = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / FleetSpeed) * 2;
                Message.TempsTrajetGT = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / GTSpeed))) / FleetSpeed) * TravelTimeType; //Travel time for heavy cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
                Message.TempsTrajetGT_A = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / GTSpeed))) / FleetSpeed);
                Message.TempsTrajetGT_AR = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / GTSpeed))) / FleetSpeed) * 2;
            }
        }
    }
    //alert(Message.CoordPlanete + '-----------------' + Message.Gtraversees +':'+ Message.SStraverses+':'+ Message.Postraversees + '--' + PTSpeed);
    //////////////////////////////////////////////////////////////////////////////////////////////////////

    //Time to travel to the destination (user defined, takes care of TravelTimeType (time travel, or time travel+back)//If the user selected nothing, this will be not computed (and it's not displayed by default, so it's ok)
    //Displayed in infoboxes, convert timestamps in these proprieties in human readable hours
    Message.TempsTrajetPT_ADisplayed = secondsToHms(Message.TempsTrajetPT_A);
    Message.TempsTrajetPT_ARDisplayed = secondsToHms(Message.TempsTrajetPT_AR);
    Message.TempsTrajetGT_ADisplayed = secondsToHms(Message.TempsTrajetGT_A);
    Message.TempsTrajetGT_ARDisplayed = secondsToHms(Message.TempsTrajetGT_AR);
    //checks if the user has selected small or large cargo
    if (GM_getValue('radio2' + Meta.Universe) === true) { //small cargo selected
        //Title = Html title for the column where is displayed item
        Message.TempsTrajetDisplayed = secondsToHms(Message.TempsTrajetPT);
    } else {
        if (GM_getValue('radio3' + Meta.Universe) === true) { //heavy cargo selected
            Message.TempsTrajetDisplayed = secondsToHms(Message.TempsTrajetGT);
        }
    }

    //Compute the clock when your ships arrive to the destination
    Message.HeureArriveePTRaw = Message.TempsTrajetPT_A + Meta.Timestamp;
    Message.HeureArriveeGTRaw = Message.TempsTrajetGT_A + Meta.Timestamp;
    Message.HeureArriveeGTDisplayed = timeConverter(Message.HeureArriveeGTRaw); //Used in infoboxes
    Message.HeureArriveePTDisplayed = timeConverter(Message.HeureArriveePTRaw); //Used in infoboxes
    Message.HeureArriveeDisplayed = timeConverter(Message.HeureArriveePTRaw); //Default value, needed because without this, the script doesn't display spy report table if the user never came into the options (it's because of the split)
    //checks if the user has selected small or large cargo
    if (GM_getValue('radio4' + Meta.Universe) === true) { //small cargo selected
        Message.HeureArriveeDisplayed = timeConverter(Message.HeureArriveePTRaw);
        //Title = Html title for the column where is displayed item
    } else {
        if (GM_getValue('radio5' + Meta.Universe) === true) { //heavy cargo selected
            Message.HeureArriveeDisplayed = timeConverter(Message.HeureArriveeGTRaw);
        }
    }


    //Comput the clocks when your ships comes back
    Message.HeureRetourGTRaw = Message.TempsTrajetGT_AR + Meta.Timestamp;
    Message.HeureRetourPTRaw = Message.TempsTrajetPT_AR + Meta.Timestamp;
    Message.HeureRetourGTDisplayed = timeConverter(Message.HeureRetourGTRaw); //Used in infoboxes
    Message.HeureRetourPTDisplayed = timeConverter(Message.HeureRetourPTRaw); //Used in infoboxes
    Message.HeureRetourDisplayed = timeConverter(Message.HeureRetourPTRaw);//Default value, needed because without this, the script doesn't display spy report table if the user never came into the options (it's because of the split)
    //checks if the user has selected small or large cargo
    if (GM_getValue('radio6' + Meta.Universe) === true) { //small cargo selected
        Message.HeureRetourDisplayed = timeConverter(Message.HeureRetourPTRaw);
        //Title = Html title for the column where is displayed item
    } else {
        if (GM_getValue('radio7' + Meta.Universe) === true) { //heavy cargo selected
            Message.HeureRetourDisplayed = timeConverter(Message.HeureRetourGTRaw);
        }
    }


    //alert(Message.HeureArriveePTDisplayed);
    //alert(Message.TempsTrajetPTDisplayed);

    //Compute the profit/hour and profit/hour USM value
    Message.ProfitsPerHour = parseInt(Message.Loot / (Message.TempsTrajetPT_AR / 3600));
    Message.ProfitsPerHour_GT = parseInt(Message.Loot / (Message.TempsTrajetGT_AR / 3600));
    Message.ProfitsPerHourUSM = parseInt(Message.USMPille / (Message.TempsTrajetPT_AR / 3600));
    Message.ProfitsPerHourUSM_GT = parseInt(Message.USMPille / (Message.TempsTrajetGT_AR / 3600));
    //checks if the user has selected small or large cargo, and after, checks if the user has selected MSU or not
    if (GM_getValue('radio8' + Meta.Universe) === true) { //small cargo selected
        if (GM_getValue('radio10' + Meta.Universe) === true) { //standard values
            Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHour);
            Message.ProfitsPerHourUsed = Message.ProfitsPerHour;
        } else {
            if (GM_getValue('radio11' + Meta.Universe) === true) { //msu values
                Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHourUSM);
                Message.ProfitsPerHourUsed = Message.ProfitsPerHourUSM;
            }
        }
        //Title = Html title for the column where is displayed item
    } else {
        if (GM_getValue('radio9' + Meta.Universe) === true) { //heavy cargo selected
            if (GM_getValue('radio10' + Meta.Universe) === true) { //standard values
                Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHour_GT);
                Message.ProfitsPerHourUsed = Message.ProfitsPerHour_GT;
            } else {
                if (GM_getValue('radio11' + Meta.Universe) === true) { //msu values
                    Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHourUSM_GT);
                    Message.ProfitsPerHourUsed = Message.ProfitsPerHourUSM_GT;
                }
            }
        }
    }
    //Colorization of profits per hour data
    if (Message.ProfitsPerHourUsed >= MinProfitsHourToColorize) { //Colorize Loot in this line in "user selected color" when it's bigger than "user selected minium amount of profits"
        Message.ProfitsPerHourDisplayed = '<font color="' + ProfitsHourColor + '">' + Message.ProfitsPerHourDisplayed + '</font>';
    } else {
        Message.ProfitsPerHourDisplayed = '<font>' + Message.ProfitsPerHourDisplayed + '</font>';
    }

    //TimeTitle is used to create the tooltip of time related columns
    Message.TimeTitle = '(<FONT color=#FF8F35>' + Langue.PT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_A.split("|||")[LangueIndex] + ' : <FONT color=#FF8F35>' + Message.TempsTrajetPT_ADisplayed + '</FONT><br />(<FONT color=#FF8F35>' + Langue.PT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_AR.split("|||")[LangueIndex] + ' : <FONT color=#FF8F35>' + Message.TempsTrajetPT_ARDisplayed + '</FONT><br />(<FONT color=#FF8F35>' + Langue.PT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureArrivee.split("|||")[LangueIndex] + ' : <FONT color=#FF8F35>' + Message.HeureArriveePTDisplayed.split(" ")[1] + '</FONT><br />(<FONT color=#FF8F35>' + Langue.PT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureRetour.split("|||")[LangueIndex] + ' : <FONT color=#FF8F35>' + Message.HeureRetourPTDisplayed.split(" ")[1] + '</FONT><br />' +
                        '(<FONT color=#00A0B6>' + Langue.GT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_A.split("|||")[LangueIndex] + ' : <FONT color=#00A0B6>' + Message.TempsTrajetGT_ADisplayed + '</FONT><br />(<FONT color=#00A0B6>' + Langue.GT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_AR.split("|||")[LangueIndex] + ' : <FONT color=#00A0B6>' + Message.TempsTrajetGT_ARDisplayed + '</FONT><br />(<FONT color=#00A0B6>' + Langue.GT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureArrivee.split("|||")[LangueIndex] + ' : <FONT color=#00A0B6>' + Message.HeureArriveeGTDisplayed.split(" ")[1] + '</FONT><br />(<FONT color=#00A0B6>' + Langue.GT.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureRetour.split("|||")[LangueIndex] + ' : <FONT color=#00A0B6>' + Message.HeureRetourGTDisplayed.split(" ")[1] + '</FONT><br />';
    //alert(Message.ProfitsPerHour);

	return Message;
}


//Tri Des données
function Tri(a,b) {
        if (a[currentSort] < b[currentSort])
            return 1;
        if (a[currentSort] > b[currentSort])
            return -1;
        return 0;
}



//Fonction de transformation d'un RE en chaine de caractères OBJ->STR
function ConvertObjToString(obj) {
    var Txt = (obj.Id + ":--:" + obj.Metal + ":--:" + obj.Cristal + ":--:" + obj.Deuterium + ":--:" + obj.CoordPlanete + ":--:" + obj.Butin + ":--:" + obj.Flotte + ":--:" + obj.FlotteFinal + ":--:" + obj.FlotteDisplayed + ":--:" + obj.Defense + ":--:" + obj.DefenseFinal + ":--:" + obj.DefenseDisplayed + ":--:" + obj.Activite + ":--:" + obj.Date + ":--:" + obj.Player + ":--:" + obj.PlayerStatus + ":--:" + obj.PlayerIcon + ":--:" + obj.LineColor + ":--:" + obj.PlayerColor + ":--:" + obj.Display + ":--:" + obj.PTAttacked + ":--:" + obj.GTAttacked + ":--:" + obj.Moon + ":--:" + obj.IdIg + ":--:" + obj.API + ":--:" + obj.RCRecycled + ":--:" + obj.VagueSecondaire);
    /////////0//////////////////1//////////////////////2//////////////////////////3/////////////////////4//////////////////////////5///////////////////////6////////////////////////7//////////////////8///////////////////////////////9////////////////////////10/////////////////////////11///////////////////////////////12//////////////////13/////////////////////14////////////////////15////////////////////////16///////////////////////17/////////////////////////18/////////////////////////19/////////////////////////20////////////////////////21//////////////////////22/////////////////23//////////////////24///////////////////////25///////////////////////26////////////
    return Txt;
}

//Fonction de transformation d'un message sous forme de chaine de caractère en objet STR->OBJ
function ConvertStringToObj(StrMessage) {
    var SplitStrMessage = StrMessage.split(":--:");
    var Message = {};
    Message.Id = SplitStrMessage[0];
    Message.Metal = Number(SplitStrMessage[1]);
    Message.Cristal = Number(SplitStrMessage[2]);
    Message.Deuterium = Number(SplitStrMessage[3]);
    Message.CoordPlanete = SplitStrMessage[4];
    Message.Butin = Number(SplitStrMessage[5]);
    Message.Flotte = SplitStrMessage[6];
    Message.FlotteFinal = Number(SplitStrMessage[7]);
    Message.FlotteDisplayed = SplitStrMessage[8];
    Message.Defense = SplitStrMessage[9];
    Message.DefenseFinal = Number(SplitStrMessage[10]);
    Message.DefenseDisplayed = SplitStrMessage[11];
    Message.Activite = SplitStrMessage[12];
    Message.Date = SplitStrMessage[13];
    Message.Player = String(SplitStrMessage[14]);
    Message.PlayerStatus = SplitStrMessage[15];
    Message.PlayerIcon = SplitStrMessage[16];
    Message.LineColor = SplitStrMessage[17];
    Message.PlayerColor = SplitStrMessage[18];
    Message.Display = SplitStrMessage[19];
    Message.PTAttacked = SplitStrMessage[20];
    Message.GTAttacked = SplitStrMessage[21];
    Message.Moon = SplitStrMessage[22];
    Message.IdIg = SplitStrMessage[23];
    Message.API =  SplitStrMessage[24];
    Message.RCRecycled = SplitStrMessage[25];
    Message.VagueSecondaire = SplitStrMessage[26];
    return Message;
}


//Fonction d'enregistrement des RE
function SetStoredRE(Index, Message) {
    var MetaLocal = MetaDatas();
    //Appel de la fonction convertissant les objets en chaine de caractères
    StringMessage = ConvertObjToString(Message);
    GM_setValue('MessageStoredNumber'+Index + MetaLocal.Universe, StringMessage);
}


//Fonction de récupération des RE enregistrés
function GetStoredRE(Index) {
    var MetaLocal = MetaDatas();
    var Message = GM_getValue('MessageStoredNumber'+Index + MetaLocal.Universe);
    //console.log("[O-Table] : Datas inside this stored message : " + Message);
    return Message;
}

//Fonction de suppression de RE
function DelStoredRE(Index) {
    var MetaLocal = MetaDatas();
    //alert(Index);
    //alert(GM_getValue('MessageStoredNumber'+Index + MetaLocal.Universe));

    GM_deleteValue('MessageStoredNumber'+Index + MetaLocal.Universe);
}

//Function that deletes a spy report older than 24H
function DelOldSR(SRToDelete) {
    //alert(SRToDelete.Metal);
    var MetaLocal = MetaDatas();
    var IdMessages = GM_getValue('REIdList' + MetaLocal.Universe);

    console.log("[O-Table] : SRid of message going to be deleted : " + SRToDelete.IdIg + "--- Coords of this message : " + SRToDelete.CoordPlanete + " --- Table ID of this message : " + SRToDelete.Id );
    //console.log("[O-Table] : List of SR IDs before deleting the message : " + IdMessages);
    IdMessages = IdMessages.replace(SRToDelete.IdIg + ":--:", "");
    //console.log("[O-Table] : SRid " + SRToDelete.IdIg + " has been removed on the list. New SRid list : " + IdMessages);
    GM_setValue('REIdList' + MetaLocal.Universe, IdMessages);
    DelStoredRE(SRToDelete.Id);



}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FONCTIONS DE TRANSFORMATION DES CHAINES DE CARACTERES//////////////////////////////////CONVERTERS///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Transformation des nombres (nombres transformés en valeurs décimales)
function ConvertRENumbers(Nombre) {
    var Meta = MetaDatas();
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers

    //Récupération du choix utilisateur concernant les indicateurs millions/milliards
    if (GM_getValue('text11' + Meta.Universe)) {
        var IndicateurMilliard = GM_getValue('text11' + Meta.Universe);
    } else {
        var IndicateurMilliard = Langue.Milliard.split("|||")[LangueIndex]; //Récupère la valeur par défaut (correspond à ce qui est inscrit dans la langue)
    }
    if (GM_getValue('text12' + Meta.Universe)) {
        var IndicateurMillions = GM_getValue('text12' + Meta.Universe);
    } else {
        var IndicateurMillions = Langue.Million.split("|||")[LangueIndex]; //Récupère la valeur par défaut (correspond à ce qui est inscrit dans la langue)
    }


    //alert(Nombre);
    var MdFound = Nombre.indexOf(IndicateurMilliard); //ATTENTION LANGUE
    var MFound = Nombre.indexOf(IndicateurMillions); //ATTENTION LANGUE
    if (MdFound > -1) {
        //alert("Miliard trouvé!"); //permet de savoir si un miliard est trouvé
        Nombre = Nombre.replace(/[^0-9\.,\n]|,[^0-9]/g, "");
        Nombre = Nombre.replace(",",".");
        Nombre = Nombre * 1000000000;
    } else {
        if (MFound > -1) {
            //alert("Million trouvé !"); //permet de savoir si un million est trouvé
            Nombre = Nombre.replace(/[^0-9\.,\n]|,[^0-9]/g, "");
            Nombre = Nombre.replace(",",".");
            Nombre = Nombre * 1000000;
        } else { //dans le cas où on a moins d'un million
            Nombre = Nombre.replace(".","");
        }
    }
    return Nombre;
}

//Séparateurs de miliers
// This functions calls FormatNumber function when user wants to see reduced numbers (k, m, bn numbers)
function ThousandSeparator(num) {
    var Meta = MetaDatas();
    //Used to know if user wants to reduce number sizes
    if (GM_getValue('column35' + Meta.Universe) === false || GM_getValue('column35' + Meta.Universe) === true) {
        var ReduceNumbers = GM_getValue('column35' + Meta.Universe);
    } else {
        var ReduceNumbers = false;//Default value if no data has been found
    }

    if (ReduceNumbers === true) {
        return FormatNumber(num);
    } else {
        return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."); //only puts a dot when user doesn't want reduced numbers
    }
}

//Change number format to Bn, M, K for smaller columns
function FormatNumber(num) {
    var Meta = MetaDatas();
    var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers
    //Récupération du choix utilisateur concernant les indicateurs millions/milliards
    if (GM_getValue('text11' + Meta.Universe)) {
        var IndicateurMilliard = GM_getValue('text11' + Meta.Universe);
    } else {
        var IndicateurMilliard = Langue.Milliard.split("|||")[LangueIndex]; //Récupère la valeur par défaut (correspond à ce qui est inscrit dans la langue)
    }
    if (GM_getValue('text12' + Meta.Universe)) {
        var IndicateurMillions = GM_getValue('text12' + Meta.Universe);
    } else {
        var IndicateurMillions = Langue.Million.split("|||")[LangueIndex]; //Récupère la valeur par défaut (correspond à ce qui est inscrit dans la langue)
    }
    if (GM_getValue('text13' + Meta.Universe)) {
        var IndicateurMilliers = GM_getValue('text13' + Meta.Universe);
    } else {
        var IndicateurMilliers = Langue.Milliers.split("|||")[LangueIndex]; //Récupère la valeur par défaut (correspond à ce qui est inscrit dans la langue)
    }
    if (num >= 1000000000) {
        num = num / 10000000;
        num = Math.round(num);
        num = num / 100;
        num = num + IndicateurMilliard;

    } else {
        if (num >= 1000000) {
            num = num / 10000;
            num = Math.round(num);
            num = num / 100;
            num = num + IndicateurMillions;

        } else {
            if (num >= 1000) {
                num = num / 1000;
                num = Math.round(num);
                num = num + IndicateurMilliers;
            }
        }
    }
    return num;
}

//Conversion de secondes en heures, minutes et secondes
function secondsToHms(d) {
    d = Number(d);
    var h = Math.floor(d / 3600);
    var m = Math.floor(d % 3600 / 60);
    var s = Math.floor(d % 3600 % 60);
    return ((h > 0 ? h + "h " + (m < 10 ? "0" : "") : "") + m + "m " + (s < 10 ? "0" : "") + s + "s");
}

function timeConverter(UNIX_timestamp){ //By Chin, http://stackoverflow.com/a/6078873 - modified to fit with ogame clock style standard
    var a = new Date(UNIX_timestamp * 1000);
    var year = a.getFullYear();
    var month = a.getMonth();
    month = addZero(month);
    var date = a.getDate();
    date = addZero(date);
    var hour = a.getHours();
    hour = addZero(hour);
    var min = a.getMinutes();
    min = addZero(min);
    var sec = a.getSeconds();
    sec = addZero(sec);
    var time = date + '.' + month + '.' + year + ' ' + hour + ':' + min + ':' + sec ;
    return time;
}

function addZero(Numvalue){ //add a 0 before the input value
    if (Numvalue < 10) {
        Numvalue = ("0" + Numvalue);
    }
    return Numvalue;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//FONCTIONS DIVERSES//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////

//Comptabilisation du nombre de messages
function NbMessages()
{
    //
    var Messages = document.getElementById("ui-id-14");
    var i=0, NbLi =0;
    while(Messages.getElementsByClassName("msg")[i++]) NbLi++;
    // Affichage du nombre de messages :
    //alert("Nombre de messages :" + NbLi);
    return NbLi;
}

//Récupération de l'univers, de ses attributs, de la position actuelle, du timestamp, langue
function MetaDatas() {
    var Meta = {};
    var CurrentTime = {};
    CurrentTime.RawTime = document.querySelector("li.OGameClock").textContent; //Classic case, get server clock
    CurrentTime.Annee = CurrentTime.RawTime.split(".")[2].split(" ")[0];
    CurrentTime.Mois = CurrentTime.RawTime.split(".")[1].split(" ")[0];
    CurrentTime.Jour = CurrentTime.RawTime.split(".")[0].split(" ")[0];
    CurrentTime.Heure = CurrentTime.RawTime.split(" ")[1].split(":")[0];
    CurrentTime.Minute = CurrentTime.RawTime.split(" ")[1].split(":")[1];
    CurrentTime.Seconde = CurrentTime.RawTime.split(" ")[1].split(":")[2];
    Meta.Universe = document.querySelector("meta[name='ogame-universe']").getAttribute('content');
    Meta.UniverseEcoSpeed = document.querySelector("meta[name='ogame-universe-speed']").getAttribute('content');
    Meta.UniverseFleetSpeed = document.querySelector("meta[name='ogame-universe-speed-fleet']").getAttribute('content');
    Meta.Langue = document.querySelector("meta[name='ogame-language']").getAttribute('content');
    //Meta.Timestamp = document.querySelector("meta[name='ogame-timestamp']").getAttribute('content'); Old Timestamp (non fonctionnel avec des heures décalées)
    Meta.Timestamp = (new Date(CurrentTime.Annee + "/" + CurrentTime.Mois + "/" + CurrentTime.Jour + " " + CurrentTime.Heure + ":" + CurrentTime.Minute + ":" + CurrentTime.Seconde).getTime()) / 1000;
    //alert(Meta.CustomTimeStamp);
    Meta.PlayerCoord = document.querySelector("meta[name='ogame-planet-coordinates']").getAttribute('content');
    Meta.GalaxiesCirculaires = document.querySelector("meta[name='ogame-donut-galaxy']").getAttribute('content');
    Meta.SystemesCirculaires = document.querySelector("meta[name='ogame-donut-system']").getAttribute('content');
    //alert(Meta.Universe + Meta.UniverseEcoSpeed + Meta.UniverseFleetSpeed + Meta.Langue + Meta.Timestamp + Meta.PlayerCoord); //--> Vérification du bon fonctionnement
    //Récupération du % cdr flotte et def //Get Debris freet + defense field ratio
    if (GM_getValue('text20' + Meta.Universe)) { //Flotte //Fleet
        Meta.TxCDRFleet = GM_getValue('text20' + Meta.Universe);
    } else {
        Meta.TxCDRFleet = 30; //Valeur par défaut //Default Value
    }
    if (GM_getValue('text21' + Meta.Universe)) { //Defense //Defense
        Meta.TxCDRDef = GM_getValue('text21' + Meta.Universe);
    } else {
        Meta.TxCDRDef = 0; //Valeur par défaut // Default Value
    }

    return Meta;
}

//Clonage d'objet - Ne fonctionne pas sur les anciens navigateurs (en tout cas sur chrome 35) ---> MAJ : devrait fonctionner maintenant (pas testé ceci dit )
function clone(obj){
    var OBJSTR = ConvertObjToString(obj);
    var OBJCOPY = ConvertStringToObj(OBJSTR);
    return OBJCOPY;
}

//Récupération de la langue

function GetLangue() {
    var MetaLocal = MetaDatas();
    //Récupération du choix qu'a mis l'utilisateur dans la langue
    if (GM_getValue('DropDown0' + MetaLocal.Universe)) {
        var LangueIndex = GM_getValue('DropDown1' + MetaLocal.Universe);
    } else {
        if (MetaLocal.Langue == "fr") { //Config par défaut, lorsqu'aucune option n'est validée
            var LangueIndex = 0; //(FR)
        } else {
            var LangueIndex = 1; //(EN) //Met tout le reste en Anglais
        }
    }
    return LangueIndex;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////VARIABLES GLOBALES////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
var StringMessage; //Variable utilisée dans la sauvegarde des RE sous forme de texte/////////////////////
var IdMessages; //Variable utilisée pour stocker les id messages, ce qui facilite leur vérification lors de l'intégration d'un nouveau message
var MessageIndex = 0; //Variable permettant d'indexer les messages sauvegardés dans le script////////////
var NbColumnsDisplayed = 0; //Variable indiquant le nombre de colonnes affichées dans le tableau HTML (tableau contenant les RE)
var NbItemsDisplayed = 0; //Variable indiquant le nombre de lignes affichées dans le tableau HTML (tableau contenant les RE)
var TriDone = 0; //Variable indiquant au script si un tri a déja été réalisé ou non
var currentID; //Variable utilisée pour les boutons de tri (l'entête du tableau), dans la fonction initialisation tableau. Permet de faire passer un nom de propriété d'objet variable entre la fonction et le trieur
var currentSort = 'Loot'; //Variable used to know by which column to sort the board (user selected) --> default value
if (GM_getValue('DropDown3' + MetaGlobal.Universe)) { //Vérifie la présence d'une donnée sauvegardée ------------------- Tri par défaut
    currentSort = GM_getValue('DropDown3' + MetaGlobal.Universe);
}
var Version = "0.19.0";
var CurrentURL = window.location.href //get current url
var ScriptDisplayed = false; //When this variable is modified to true, the script stops to repeat this line :     setInterval(affiche_script, 300);
var UI_ID_Global; //to know which ui-id the script will select (if there is the chat or not).
var IdLineGLB = ''; //Used to cancel a line deletion




///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////LANGUE////////////////// GLOBALES/////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

// Explications : La variable langue est un objet, dans laquelle on retrouve toutes les langues (un attribut = une zone de texte dans le script).
// Chaque attribut contient plusieurs langues, on split l'attribut avec le bon n° pour sélectionner la bonne langue exemple (FR = 0, EN = 1). On sépare chaque langue avec "|||".
//TEMPLATE : Langue.XXXXXXXX = 'FR' + '|||' + 'EN' + '|||' + OTHER LANGUAGE
var Langue = {};
Langue.BoutonAfficherTableau = 'Afficher Tableau' + '|||' + 'Display Table';
Langue.BoutonAfficherTableauTITLE = 'Affiche le tableau lorsque des RE ont été collectés' + '|||' + 'Displays the board when you have collected some spy reports';
Langue.BoutonCollecterMessages = 'Collecter Messages' + '|||' + 'Get Messages';
Langue.BoutonCollecterMessagesTITLE = 'Collecte les RE présents sur cette page' + '|||' + 'Collects spy reports from this page';
Langue.BoutonMasquerTableau = 'Masquer Tableau' + '|||' + 'Hide Table';
Langue.BoutonMasquerTableauTITLE = 'Cache le tableau lorsqu`il est affiché' + '|||' + 'Hide the board when the board is displayed';
Langue.BoutonOptions = 'Options' + '|||' + 'Options';
Langue.BoutonOptionsTITLE = 'Permet d`accéder aux options du script' + '|||' + 'Access to the script options';
Langue.BoutonViderScript = 'Vider Tableau' + '|||' + 'Empty Table';
Langue.BoutonViderScriptTITLE = 'Vide le tableau de ses REs' + '|||' + 'Empty the spy reports table';

Langue.InfoPremiereVague = 'Première Vague' + '|||' + 'First Wave';
Langue.InfoSecondeVague = 'Seconde Vague' + '|||' + 'Second Wave';
Langue.InfoTroisiemeVague = 'Troisième Vague' + '|||' + 'Third Wave';
Langue.InfoSlots = 'slots' + '|||' + 'slots';
Langue.InfoRenta = 'Renta' + '|||' + 'Profits';
Langue.InfoRentaUSM = 'Renta USM' + '|||' + 'Profits MSU';
Langue.InfoMoyParSlot = 'Moy/Slot' + '|||' + 'Avg/Slot';
Langue.InfoMoyUSMParSlot = 'MoyUSM/Slot' + '|||' + 'MSUAvg/Slot';
Langue.InfoRentaParHeure = 'Renta Heure' + '|||' + 'Profits Hour';
Langue.InfoMoyRentaParHeure = 'Renta Heure/Slot' + '|||' + 'Profits Hour/Slot';
Langue.InfoRentaParHeureUSM = 'Renta Heure USM' + '|||' + 'Profits Hour MSU';
Langue.InfoMoyRentaParHeureUSM = 'Renta USM Heure/Slot' + '|||' + 'MSU Profits Hour/Slot';
Langue.InfoRatio = 'Ratio USM/Brut' + '|||' + 'MSU vs Raw Ratio';

Langue.RELine = '#' + '|||' + '#';
Langue.RELineSec = 'Numéro de ligne' + '|||' + 'Line number';
Langue.RECoords = 'Coords' + '|||' + 'Coords';
Langue.REPlayer = 'Joueur' + '|||' + 'Player';
Langue.REAge = 'Age' + '|||' + 'Age';
Langue.RETimeTravel = 'Voyage' + '|||' + 'Travel';
Langue.RETimeTravelSec = 'Temps de voyage' + '|||' + 'Time travel';
Langue.RETimeTravelAR = 'Voyage A/R' + '|||' + 'Return trip';
Langue.REMetal = 'Métal' + '|||' + 'Metal';
Langue.RECristal = 'Cristal' + '|||' + 'Crystal';
Langue.REDeut = 'Deut' + '|||' + 'Deut';
Langue.RETotal = 'Total' + '|||' + 'Total';
Langue.RELoot = 'Pillage' + '|||' + 'Profits';
Langue.RELootHour = 'Pillage/H' + '|||' + 'Profits/H';
Langue.RELootUSM = 'Pillage USM' + '|||' + 'Profits MSU';
Langue.REButinRatio = 'Ratio' + '|||' + 'Ratio';
Langue.REFlotte = 'Flotte' + '|||' + 'Fleet';
Langue.REDefense = 'Défense' + '|||' + 'Defense';
Langue.RECDR = 'Champ de débris' + '|||' + 'Debris field';
Langue.RatioCDRFlotte = 'Pourcentage CDR Flotte' + '|||' + 'Fleet Debris field ratio';
Langue.RatioCDRDefense = 'Pourcentage CDR Defense' + '|||' + 'Defense Debris field ratio';
Langue.Recycleurs = 'Recycleurs nécessaires' + '|||' + 'Recyclers needed';
Langue.Simuler = 'Cliquer pour simuler' + '|||' + 'Click to simulate';
Langue.Sonder = 'Cliquer pour sonder' + '|||' + 'Click to spy';
Langue.Recycler = 'Cliquer pour envoyer des recycleurs' + '|||' + 'Click to send recyclers';
Langue.TempsTrajet_A = 'Trajet Aller' + '|||' + 'Travel time';
Langue.TempsTrajet_AR = 'Trajet Aller/Retour' + '|||' + 'Travel+Back time';
Langue.HeureArrivee = 'Arrivée à' + '|||' + 'Arrives at';
Langue.HeureRetour = 'Retour à ' + '|||' + 'Back at';
Langue.Missiles = 'MIP' + '|||' + 'Missiles';
Langue.Couts = 'Couts' + '|||' + 'Costs';
Langue.AfficherCorbeille = 'Afficher Corbeille' + '|||' + 'Display Trashbin';
Langue.AfficherUndelete = 'Annuler dernière suppression' + '|||' + 'Cancel last deletion';
Langue.SupprimerAtq = 'Supprimer toutes les cibles attaquées' + '|||' + 'Delete all attacked targets';



Langue.OptionsCouleurAA = 'Couleur lors du passage de la souris sur une ligne' + '|||' + 'Color when you put your mouse above spy reports lines';
Langue.OptionsCouleurAB = 'Couleur des boutons attaquer/recycler par défaut' + '|||' + 'Default attack/recycle buttons (not clicked)';
Langue.OptionsCouleurAC = 'Couleur des boutons attaquer/recycler lorsque l`on passe la souris dessus' + '|||' + 'Color of attack/recycle buttons when you put your mouse above';
Langue.OptionsCouleurAD = 'Couleur des boutons attaquer/recycler lorsque l`on a cliqué dessus' + '|||' + 'Color of attack/recycle buttons when you clicked on it';
Langue.OptionsCouleurAE = 'Couleur des boutons attaquer/recycler lorsque l`on a cliqué et que l`on a actualisé la page' + '|||' + 'Color of attack/recycle buttons when you clicked on it and refreshed the page';
Langue.OptionsCouleurAF = 'Lorsqu`il est rentable de mipper la défense d`un joueur, colorier la défense en' + '|||' + 'When it`s profitable to send missiles on a defense, colorize in';
Langue.OptionsCouleurAG = 'Couleur des boutons principaux lorsqu`ils sont exécutés' + '|||' + 'Main buttons color when executed';
Langue.OptionsCouleurAH = 'Couleur du bouton d`en-tête du tableau lors d`un tri de haut en bas' + '|||' + 'Top table buttons when table is sorted from up to down';
Langue.OptionsCouleurAI = 'Couleur du bouton d`en-tête du tableau lors d`un tri de bas en haut' + '|||' + 'Top table buttons when table is sorted from down to up';
Langue.OptionsCouleurAJ = 'Couleur de fond 1' + '|||' + 'Background color 1';
Langue.OptionsCouleurAK = 'Couleur de fond 2' + '|||' + 'Background color 2';
Langue.OptionsColorierEn = 'colorier en' + '|||' + 'colorize in';


Langue.OptionsTextesAA = 'Lorsque la renta dépasse' + '|||' + 'When profits are bigger than';
Langue.OptionsTextesAB = 'Lorsque la renta USM dépasse' + '|||' + 'When profits MSU are bigger than';
Langue.OptionsTextesAC = 'Lorsque la flotte dépasse' + '|||' + 'When the fleet is bigger than';
Langue.OptionsTextesAD = 'Lorsque la défense dépasse' + '|||' + 'When the defense is bigger than';
Langue.OptionsTextesAE = 'Lorsque l`âge du RE dépasse' + '|||' + 'When the spy report is older than';
Langue.OptionsTextesAF = 'Lorsque la renta d`une vague dépasse' + '|||' + 'When the wave profits are bigger than';
Langue.OptionsTextesAG = 'Envoyer' + '|||' + 'Send';
Langue.OptionsTextesAH = 'de flotte en plus que nécessaire' + '|||' + 'more ships than necessary';
Langue.OptionsTextesAI = 'Ne pas afficher un RE si la flotte dépasse' + '|||' + 'Don`t display a spy report with a fleet bigger than';
Langue.OptionsTextesAJ = 'Ne pas afficher un RE si la défense dépasse' + '|||' + 'Don`t display a spy report with a defense bigger than';
Langue.OptionsTextesAK = 'Ne pas afficher un RE si son âge dépasse' + '|||' + 'Don`t display a spy report older than';
Langue.OptionsTextesAL = 'heures' + '|||' + 'hours';
Langue.OptionsTextesAM = 'Taux de commerce (Pour le taux USM)' + '|||' + 'Trade rates (for MSU)';
Langue.OptionsTextesAP = 'Langue' + '|||' + 'Language';
Langue.OptionsTextesAQ = 'Langue (réglage manuel - à utiliser lorsque la langue n`existe pas)' + '|||' + 'Language (manual setting - to use when you don`t find your language on the list above)';
Langue.OptionsTextesAR = 'Indicateur milliards' + '|||' + 'Billions indicator';
Langue.OptionsTextesAS = 'Indicateur millions' + '|||' + 'Millions indicator';
Langue.OptionsTextesAT = 'Indicateur milliers' + '|||' + 'Thousand indicator';
Langue.OptionsTextesAU = 'Lors de la collecte des messages, générer des secondes vagues (cocher la case)' + '|||' + 'When you collect messages, ask the script to create secondary waves (check the box)';
Langue.OptionsTextesAV = 'Lors de la collecte des messages, générer une seconde vague à partir d`une renta de' + '|||' + 'When you collect messages, generate secondary waves when the profit is higher than';
Langue.OptionsTextesAW = 'Afficher le tableau récapitulatif des vagues' + '|||' + 'Display the information board';
Langue.OptionsTextesAX = 'Tableau récapitulatif : Nombre de slots par vague' + '|||' + 'Info Table : amount of slots per wave';
Langue.OptionsTextesAY = 'Afficher la ligne indiquant la Renta USM d`une vague' + '|||' + 'Info Table : display the line that shows MSU profits for each wave';
Langue.OptionsTextesAZ = 'Ouvrir les attaques dans un nouvel onglet' + '|||' + 'Open attacks in a new tab';
Langue.OptionsTextesBA = 'Collecter automatiquement les Rapports d`espionnages' + '|||' + 'Automatically collect spy reports';
Langue.OptionsTextesBB = 'Afficher automatiquement le tableau lorsque celui-ci contient au moins un Rapport d`espionnage' + '|||' + 'Automatically display the board if it has at least one spy report';
Langue.OptionsTextesBC = 'Affichage pour appareil mobile (en construction)' + '|||' + 'Mobile display style (under construction)';
Langue.OptionsTextesBD = 'de Métal valent' + '|||' + 'of Metal is equal to';
Langue.OptionsTextesBE = 'de Cristal' + '|||' + 'of Crystal is equal to';
Langue.OptionsTextesBF = 'de Deut' + '|||' + 'of Deut';
Langue.OptionsTextesBG = 'Taille du texte dans le tableau contenant les RE' + '|||' + 'Text size in spy reports board';
Langue.OptionsTextesBH = 'Lorsque la renta/heure dépasse' + '|||' + 'When profits/hour are bigger than';
Langue.OptionsTextesBI = 'Trier le tableau à partir de la colonne ' + '|||' + 'Sort the board by using column';
Langue.OptionsTextesBJ = 'Cacher un RE si la renta est inférieure à ' + '|||' + 'Hide a spy report if profits are smaller than';
Langue.OptionsTextesBK = 'Afficher un RE si celui-ci est rentable après avoir envoyé des MIPs (Renta ' + '|||' + 'Show a SR when it`s profitable to send missiles (Profits ';
Langue.OptionsTextesBL = 'Secondes vagues : utiliser les ressources Standard' + '|||' + 'Secondary waves : use standard resources';
Langue.OptionsTextesBM = 'Supprimer automatiquement la ligne après avoir cliqué sur attaquer' + '|||' + 'Automatically delete the line when attack button is licked';
Langue.OptionsTextesBN = 'Utiliser pour les ressources un format de nombre abrégé (k, m, md)' + '|||' + 'For resources values, convert raw numbers to K, M, Bn numbers (ex : 1.000.000 = 1M)';
Langue.OptionsTextesBO = 'Afficher la ligne indiquant la Renta brute d`une vague' + '|||' + 'Display the line that shows profits for each wave';
Langue.OptionsTextesBP = 'Afficher la ligne indiquant le nombre de vaisseaux qu`il faut pour la vague' + '|||' + 'Display the line that shows amount of ships necessary for each wave';
Langue.OptionsTextesBQ = 'Afficher la ligne indiquant la renta moyenne par slot' + '|||' + 'Display the line that shows average profit per slot';
Langue.OptionsTextesBR = 'Afficher la ligne indiquant la renta USM moyenne par slot' + '|||' + 'Display the line that shows average MSU profit per slot';
Langue.OptionsTextesBS = 'Afficher la ligne indiquant la renta par heure pour la vague' + '|||' + 'Display the line that shows profit per hour for the wave';
Langue.OptionsTextesBT = 'Afficher la ligne indiquant la renta par heure USM pour la vague' + '|||' + 'Display the line that shows MSU profit per hour for the wave';
Langue.OptionsTextesBU = 'Afficher la ligne indiquant le ratio renta USM/renta brute pour la vague' + '|||' + 'Display the line that shows MSU profits/raw profits ratio for the wave';
Langue.OptionsTextesBV = 'Lorsque la renta USM d`une vague dépasse' + '|||' + 'When the MSU wave profits are bigger than';
Langue.OptionsTextesBW = 'Lorsque la renta par heure d`une vague dépasse' + '|||' + 'When the wave profits per hour are bigger than';
Langue.OptionsTextesBX = 'Lorsque la renta par heure USM d`une vague dépasse' + '|||' + 'When the MSU wave profits per hour are bigger than';
Langue.OptionsTextesBY = 'Lorsque le ratio USM/Renta brut d`une vague dépasse' + '|||' + 'When the MSU vs Raw profits ratio is bigger than';
Langue.OptionsTextesBZ = 'Afficher la ligne indiquant la moyenne par slot de la renta par heure' + '|||' + 'Display the line that shows average per slot of profit per hour';
Langue.OptionsTextesCA = 'Afficher la ligne indiquant la moyenne par slot de la renta par heure USM' + '|||' + 'Display the line that shows average per slot of MSU profit per hour';
Langue.OptionsTextesCB = 'Conserver uniquement les ' + '|||' + 'Display only the ';
Langue.OptionsTextesCC = ' premières lignes' + '|||' + ' first lines';

Langue.OptionsCBoxAA = 'Afficher les n° de ligne à gauche' + '|||' + 'Display the left line number column';
Langue.OptionsCBoxAB = 'Afficher les n° de ligne à droite' + '|||' + 'Display the right line number column';
Langue.OptionsCBoxAC = 'Afficher les coordonnées' + '|||' + 'Display the coordinates column';
Langue.OptionsCBoxAD = 'Afficher le métal à piller' + '|||' + 'Display the metal profits column';
Langue.OptionsCBoxAE = 'Afficher le cristal à piller' + '|||' + 'Display the crystal profits column';
Langue.OptionsCBoxAF = 'Afficher le deutérium à piller' + '|||' + 'Display the deuterium profits column';
Langue.OptionsCBoxAG = 'Afficher le total des ressources présent sur le RE' + '|||' + 'Display the column containing the total amount of resources inside the RE';
Langue.OptionsCBoxAH = 'Afficher le ratio de butin' + '|||' + 'Display the profit ratio column';
Langue.OptionsCBoxAI = 'Afficher la flotte' + '|||' + 'Display the fleet column';
Langue.OptionsCBoxAJ = 'Afficher la défense' + '|||' + 'Display the defense column';
Langue.OptionsCBoxAK = 'Afficher la quantité de ressources à piller' + '|||' + 'Display the profit column';
Langue.OptionsCBoxAL = 'Afficher la quantité de ressources à piller en USM' + '|||' + 'Display the MSU profit column';
Langue.OptionsCBoxAM = 'Afficher le pseudo des joueurs' + '|||' + 'Display the player name column';
Langue.OptionsCBoxAN = 'Afficher les boutons PT' + '|||' + 'Display the light cargo buttons';
Langue.OptionsCBoxAO = 'Afficher les boutons GT' + '|||' + 'Display the heavy cargo buttons';
Langue.OptionsCBoxAP = 'Afficher l`âge du RE (Affichage abrégé :' + '|||' + 'Display spy report Age column (Reduced informations : ';
Langue.OptionsCBoxAQ = 'Afficher le bouton supprimer' + '|||' + 'Display the delete buttons';
Langue.OptionsCBoxAR = 'Afficher le bouton plus de détails' + '|||' + 'Display the button "More details"';
Langue.OptionsCBoxAS = 'Afficher le bouton Recycleurs' + '|||' + 'Display the Recycle button';
Langue.OptionsCBoxAT = 'Afficher la colonne temps de trajet' + '|||' + 'Display travel time column';
Langue.OptionsCBoxAU = 'Afficher la colonne heure d`arrivée' + '|||' + 'Display the arrival time column';
Langue.OptionsCBoxAV = 'Afficher la colonne heure de retour' + '|||' + 'Display the back time column';
Langue.OptionsCBoxAW = 'Afficher la colonne Renta/Heure' + '|||' + 'Display the Profits/Hour column';
Langue.OptionsCBoxAX = 'Afficher la colonne Nombre de MIP' + '|||' + 'Display the amount of missiles column';

Langue.OptionsTechsAA = 'Réacteur à combustion' + '|||' + 'Combustion drive';
Langue.OptionsTechsAB = 'Réacteur à impulsion' + '|||' + 'Impulse drive';
Langue.OptionsTechsAC = 'Propulsion hyperespace' + '|||' + 'Hyperespace drive';
Langue.OptionsTechsAD = 'Flotte : Pourcentage CDR de l`uni' + '|||' + 'Fleet : Debrits field percent';
Langue.OptionsTechsAE = 'Defense : Pourcentage CDR de l`uni' + '|||' + 'Defense : Debrits field percent';
Langue.OptionsTechsAF = 'Technologie Armes' + '|||' + 'Weapons Technology';
Langue.OptionsTechsAG = 'Technologie Bouclier' + '|||' + 'Shielding Technology';
Langue.OptionsTechsAH = 'Technologie Protection des vaisseaux spatiaux' + '|||' + 'Armour Technology';
Langue.OptionsTechsAI = 'Nombre de systèmes solaires par galaxie' + '|||' + 'Amount of solar systems per galaxies';
Langue.OptionsTechsAJ = 'Nombre de galaxies dans l`univers' + '|||' + 'Amount of galaxies in this universe';
Langue.OptionsTechsAK = 'Page Recherche : Collecter automatiquement les recherches' + '|||' + 'Research Page : Automatically collect researches';

Langue.OptionsMainAA = 'Options de couleurs' + '|||' + 'Color options';
Langue.OptionsMainAB = 'Sauvegarder' + '|||' + 'Save';
Langue.OptionsMainAC = 'Affichage des colonnes' + '|||' + 'Table columns';
Langue.OptionsMainAD = 'Options globales' + '|||' + 'Global options';
Langue.OptionsMainAE = 'Technologies du compte & Paramètres de l`univers' + '|||' + 'Account Techs and Universe Settings';
Langue.OptionsMainAF = 'Tableau récapitulatif' + '|||' + 'Summary table';

Langue.VaguePri = 'Vague Principale' + '|||' + 'First Wave';
Langue.VagueSec = 'Vague Secondaire' + '|||' + 'Secondary wave';

Langue.Aller = 'aller' + '|||' + 'travel';
Langue.AllerRetour = 'aller/retour' + '|||' + 'travel and back';
Langue.PT = 'PT' + '|||' + 'SON';
Langue.GT = 'GT' + '|||' + 'NGC';
Langue.RC = 'RC' + '|||' + 'REC';
Langue.Milliard = 'Md' + '|||' + 'Bn';
Langue.Million = 'M' + '|||' + 'M';
Langue.Milliers = 'K' + '|||' + 'K';
Langue.Brut = 'Standard' + '|||' + 'Standard';
Langue.Ressource = 'Ress' + '|||' + 'Res';
Langue.RessourceCDR = 'Ress+CDR' + '|||' + 'Res+DF';
Langue.USM = 'USM' + '|||' + 'MSU';
Langue.Version = 'O-Table Version' + '|||' + 'O-Table Version';

Langue.MIPExplained = 'Le nombre de missiles reste approximatif car la simulation se base sur la valeur de la défense et non sur ses points de structure (cette valeur n`existe pas dans un RE simple). Le montant de missiles calculé par cette méthode est en moyenne 5% supérieur à ce qu`il devrait être (test effectué sur un panel de 75 défenses). UTILISER un simulateur classique pour obtenir une valeur 100% fiable. Techs utilisées : 0/0/0 vs 0/0/0 (Les techs du défenseur ne sont pas affichées sur un RE simple)' + '|||' + 'Missiles amount is approximate as this simulation is using defense value instead of defense structure points (this value doesn`t exist in SR summary). Amount of missiles computed by this way is on average 5% bigger than with classic simulation (this simulation has been tested on 75 different defenses). A classic simulator MUST BE used to get the most reliable value. Techs used : 0/0/0 vs 0/0/0 (Techs are not shown in smalls Spy reports)';
Langue.TableauCouleurExplainedAA = 'Colorie uniqment la renta brute et la renta par slot' + '|||' + 'Only colorizes raw profits and profits per slot';
Langue.TableauCouleurExplainedAB = 'Colorie uniqment la renta USM et la renta par slot USM' + '|||' + 'Only colorizes MSU profits and MSU profits per slot';
Langue.TableauCouleurExplainedAC = 'Colorie uniqment la renta par heure brute et la renta par heure moyenne par slot' + '|||' + 'Only colorizes profits per hour and average profits per hour per slot';
Langue.TableauCouleurExplainedAD = 'Colorie uniqment la renta par heure USM et la renta par heure moyenne USM par slot' + '|||' + 'Only colorizes profits per hour and average MSU profits per hour per slot';

//NEW PART
Langue.OptionsTextesCD = 'Activer la protection contre les suppressions accidentelles' + '|||' + 'Enable inadvertent delete protection';
Langue.BoutonViderProtected = 'Réappuyer...' + '|||' + 'Press again...';
Langue.BoutonViderOK = 'Vidé !' + '|||' + 'Cleared !';
Langue.BoutonViderFailed = 'Echec' + '|||' + 'Failed';
Langue.OptionsCouleurAL = 'Lorsque la cible est située à plus de' + '|||' + 'When the target is further than ';
Langue.OptionsCouleurAM = 'galaxies, colorier les coords en... ' + '|||' + 'galaxies, colorize coords in...';
Langue.OptionsCouleurAN = 'systèmes solaires, colorier les coords en... ' + '|||' + 'solar systems, colorize coords in...';


Langue.QuickFilter = 'Filtres rapides' + '|||' + 'Quick Filter'
Langue.QuickFilterAge = 'Masquer âge si >' + '|||' + 'Hide age if >'
'note : Langue.OptionsTextesAL is used for "hours" word '
Langue.QuickFilterDef = 'Défense max = ' + '|||' + 'Maximum defence ='
Langue.QuickFilterFlotte = 'Flotte max = ' + '|||' + 'Maximum fleet = '
Langue.QuickFilterRentaMin = 'Renta mini = ' + '|||' + 'Minimum profits ='
Langue.QuickFilterStd = 'Standard' + '|||' + 'Standard '
Langue.QuickFilterUSM = 'USM' + '|||' + 'MSU'
Langue.QuickFilterRes = 'Ressources ' + '|||' + 'Resources'
Langue.QuickFilterResCDR = 'Ressources & CDR' + '|||' + 'Resources & DF'
Langue.QuickFilterQtéFlt = 'Qté de % de flotte suppl. =' + '|||' + '% of additional fleet Qty'
Langue.QuickFilterCurGala = 'Aff. galaxie courante seulement' + '|||' + 'Only show current galaxy'
Langue.QuickFilterGalaxies = 'Afficher galaxies : ' + '|||' + 'Display galaxies :'
Langue.QuickFilterAll = 'Toutes' + '|||' + 'All'
Langue.QuickFilterTrashbin = 'Afficher les éléments de la corbeille et les entourer de rouge' + '|||' + 'Display trashbin lines and enclose in red'
Langue.QuickFilterHidden = 'Afficher les éléments masqués automatiquement et les entourer de blanc' + '|||' + 'Display automatically hidden lines and enclose in white'
Langue.QuickFilterMaxLines = 'Nombre de lignes max' + '|||' + 'Max lines amount = '
Langue.QuickFilterSave = 'Sauvegarder ces options en tant qu`options par défaut' + '|||' + 'Save these options as default settings'


//////////////////////////////////////////////////////////////////////////////////////////////////////
//AUTOCOLLECTS RESEARCH FROM RESEARCH PAGE////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
function research_page(){
    var MetaLocal = MetaDatas();
    if (GM_getValue('column30' + MetaLocal.Universe) === false) {
        console.log("[O-Table] : User selected to not auto collect researches")
    } else {
        var Combustion = parseInt(document.querySelector(".research115").querySelector(".level").textContent.replace(/[^0-9.]/g, "")); //Get level and removes everything except numbers
        var Impulsion = parseInt(document.querySelector(".research117").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Prop_Hyp = parseInt(document.querySelector(".research118").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Weapons = parseInt(document.querySelector(".research109").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Shields = parseInt(document.querySelector(".research110").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Armour = parseInt(document.querySelector(".research111").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        console.log("[O-Table] : Combustion :_" + Combustion + "_- Impulsion :_" + Impulsion + "_- Prop :_" + Prop_Hyp);
        console.log("[O-Table] : Weapons :_" + Weapons + "_- Shields :_" + Shields + "_- Armour :_" + Armour);
        console.log("[O-Table] : Finished to collect research");
        //Recording variables into script
        GM_setValue('text14' +  MetaLocal.Universe, Combustion);
        GM_setValue('text15' +  MetaLocal.Universe, Impulsion);
        GM_setValue('text16' +  MetaLocal.Universe, Prop_Hyp);
        GM_setValue('text22' +  MetaLocal.Universe, Weapons);
        GM_setValue('text23' +  MetaLocal.Universe, Shields);
        GM_setValue('text24' +  MetaLocal.Universe, Armour);
    }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
//INITIALISATION DU SCRIPT/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

function affiche_script()
{
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Cette zone a été largement inspirée de raidstable, je tiens donc à le préciser (Merci à Xanatos, Vulca et Wukodlak pour leur travail)
    if(document.querySelector('#agoButtons')) {
        document.querySelector('#agoButtons').parentNode.removeChild(document.querySelector('#agoButtons')) //Suppression des boutons AGO en haut des messages
        if(document.querySelector('#agoSpyReportOverview'))
        {
            document.querySelector('#agoSpyReportOverview').parentNode.removeChild(document.querySelector('#agoSpyReportOverview')) //Suppression du tableau AGO
        }
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (document.getElementById("AfficherTableau")) { //checks if AfficherTableau button is already displayed
        console.log("[O-Table] : main buttons sucessfully displayed");
    } else {
        try {
            Display();
        } catch(err){
            console.log("[O-Table] : main buttons not displayed, retrying...");
        }
    }
}

//Checks if current page is research and launch a function
if (CurrentURL.search("research") >= 0) {
    console.log("[O-Table] : Current Page is research");
    research_page();
}

//Checks if current page is messages and launch a function
if (CurrentURL.search("messages") >= 0) {
    console.log("[O-Table] : Current Page is messages");
    setInterval(affiche_script, 400);
}