OddWH / O-Table

// ==UserScript==
// @name         O-Table
// @namespace    http://tampermonkey.net/
// @version      2.6.2
// @description  Créateur OddWH
// @author       OddWH
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @grant        GM_listValues
// @include     	*.ogame*gameforge.com/game/index.php?page=messages*
// @include     	*.ogame*gameforge.com/game/index.php?page=ingame&component=research*
// @include     	*.ogame.gameforge.com/game/index.php?page=ingame&component=fleetdispatch*
// @updateURL   https://openuserjs.org/meta/OddWH/O-Table.meta.js
// @downloadURL https://openuserjs.org/install/OddWH/O-Table.user.js
// @license MIT
//
// Copyright OddWH, tous droits réservés. La copie ou modification de ce présent script nécessite l'accord préalable de son auteur.
//
// ==/UserScript==
/* jshint -W097 */

//
'use strict';
//Beta testers : Thanks to Alxan, Yggmen, Iluvatar, Andraud, Pippin, LittleField, Loki... Thanks to the .MiNeUr. !
//Don't forget to update the script version in Version variable



//Translation
//ES : Thanks to Arzorth !! :)

/*
In the Whole script :

How to get data stored on options :

Get the profil used :
var GlobalProfileUsed = GetData('ProfileUsed','', 'Profile1');

Call function GetData :
GetData(Arg1= Profil used 'Arg2=OptionName', 'Arg3=DefaultValue'));

Where :
Arg1 = profileused
Arg2 = name of the option (color1, color2... text35...etc)
Arg3 = Default value (ff0000, ffff00, 1250000, etc)...

example : get the column used to sort the table : GetData(GlobalProfileUsed, 'DropDown3', 'Loot')

*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////VARIABLES GLOBALES////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
var MetaGlobal = MetaDatas();
var LangueIndexGlb = GetLangue();
var StringMessage; //Variable utilisée dans la sauvegarde des RE sous forme de texte/////////////////////
var GlobalProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
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 = GetData(GlobalProfileUsed, 'DropDown3', 'Loot'); //Variable used to know by which column to sort the board (user selected) --> default value is Loot
var OldSorting = currentSort;
var currentRCListSort = GetData('General', 'OptRC1000', 'DateStamp');
var OldcurrentRCListSort = currentRCListSort;
var currentCoordListSort = GetData('General', 'OptRC1000', 'Coord_CoordCalc');
var OldcurrentCoordListSort = currentCoordListSort;
var currentDailyListSort = GetData('General', 'OptRC1000', 'Day_Date'); //Note : n'existe pas, pour l'instant et renvoie donc obligatoirement Day_Date
var OldcurrentDailyListSort = currentDailyListSort;
var currentWeeklyListSort = GetData('General', 'OptRC1000', 'Week_Monday'); //Note : n'existe pas, pour l'instant et renvoie donc obligatoirement Day_Date
var OldcurrentWeeklyListSort = currentWeeklyListSort;
var Version = "2.6.1";
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


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////SR AREA ------------------------- ZONE RAPPORTS ESPIONNAGE////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////





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



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=="';
    Picture.LeftLogo ='"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAABPUlEQVRIS2NkgAIZBdX/MDa16ScPbjOCzAQTtLQI5nCQhYz0sAhm4ahlVEkzKMG4fPE8qhiKbEhkbBKci2EZsiS6zSDH4JMnpB6nZTCDkS1AFgMZDLMYXQ1MDt1xRFmGrhndEGIcAc7UyPmMUDARkic5GKmdQlASCDsH138+QWGwHetWLWOwtbVlEJWUxWonSD4oLIpo94DUB4dHM/xn+Mfw6d07cNkIL4Dr6+sZGhsbcRpGSB5dI7p6DMuIdjaRCpEdP7A+Gw1GYqKMYAIZDcbBH4yg4urnj29gh4IilNoAJVNz8fDBi6u///5B7ALRTEwQmkqAmYUF0m7k4RdCaaD+/49qyX8iLWUEORAJMDIyMYDMAtFfPr5jBFsGAoKiEigW/kO34P9/BgaQchANAkSwmZiZwUrfv34BtgcATY7sDGyowRcAAAAASUVORK5CYII="';
    Picture.LeftLogoGreen ='"data:image/png;base64,"';
    Picture.LeftLogoOrange ='"data:image/png;base64,"';
    Picture.Crayon = '"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEX///8RGiH///+IABUpP04YJC3Dw8NHYE7NAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAHdElNRQfjBQgLCAsCDthyAAAAVklEQVQI1z3OsQ3AMAgEQCjSG+IF+BUygTdwkwHSeP8RAm8lX50eIRD5osY0UTCJcMAIIC7fo35uxBggevfEwQIzUUUhniyIlYUXLPcK+8QUvZn2f/EChJIOqhGbmewAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTktMDUtMDhUMTE6MDg6MTErMDM6MDCyrdM5AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE5LTA1LTA4VDExOjA4OjExKzAzOjAww/BrhQAAAABJRU5ErkJggg=="';

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%; border-collapse: collapse; } "); //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
GM_addStyle(".Pair {background-color: #" + GetData(GlobalProfileUsed, 'color16', '111A21') + ";}");
GM_addStyle(".Pair:hover { background-image: linear-gradient(to bottom, #" + GetData(GlobalProfileUsed, 'color0', '0C8528') + " 0%, #" + GetData(GlobalProfileUsed, 'color16', '111A21') + " 30%, #" + GetData(GlobalProfileUsed, 'color16', '111A21') + " 70%, #" + GetData(GlobalProfileUsed, 'color0', '0C8528') + " 100%); "); //lignes paires, le get value récupère la couleur enregistrée par l'utilisateur

//lignes impaires
GM_addStyle(".Impair {background-color: #" + GetData(GlobalProfileUsed, 'color17', '18242d') + ";}");
GM_addStyle(".Impair:hover {background-image: linear-gradient(to bottom, #" + GetData(GlobalProfileUsed, 'color0', '0C8528') + " 0%, #" + GetData(GlobalProfileUsed, 'color17', '18242d') + " 30%, #" + GetData(GlobalProfileUsed, 'color17', '18242d') + " 70%, #" + GetData(GlobalProfileUsed, 'color0', '0C8528') + " 100%); "); //lignes impaires, le get value récupère la couleur enregistrée par l'utilisateur

//Lignes supprimées (Tableau Quickfilter > afficher les lignes de la corbeille et les encadrer de rouge)
GM_addStyle(".RowDeleted {border-left: 4px solid #FF0000");
//Lignes cachées (Tableau Quickfilter > afficher les lignes masquées automatiquement et les encadrer de blanc)
GM_addStyle(".Hidden {border-left: 4px solid #FFFFFF");

//Boutons attaque
 //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, .AttackSondeButton:link, .AttackGTButton:link, .AttackEclaireurButton:link, .AttackButton:link {display: block; width: 16px; height:16px; background-image: url(" + Picture.Attack + "); background-color: #" + GetData(GlobalProfileUsed, 'color1', 'ffffff') + ";}");
GM_addStyle(".RCButton:link {display: block; width: 16px; height:16px; background-image: url(" + Picture.RC + "); background-color: #" + GetData(GlobalProfileUsed, 'color1', 'ffffff') + ";}");


GM_addStyle(".AttackPTButton:hover, .AttackSondeButton:hover, .AttackGTButton:hover, .AttackEclaireurButton:hover , .AttackButton:hover {background-color: #" + GetData(GlobalProfileUsed, 'color2', '00ff00') +" !important ;}");
GM_addStyle(".RCButton:hover {background-color: #" + GetData(GlobalProfileUsed, 'color2', '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
GM_addStyle(".FltColorized { color:#" + GetData(GlobalProfileUsed, 'color6', 'FF0000') + ";} "); //Style used to colorize fleet value in table


//CSS to colorize def when it reaches the good amount
GM_addStyle(".DefColorized { color:#" + GetData(GlobalProfileUsed, 'color7', 'FF0000') + ";} "); //Style used to colorize fleet value in table

//CSS to colorize def when it's profitable to send missiles
GM_addStyle(".DefMissilesColorized { color:#" + GetData(GlobalProfileUsed, 'color12', '00FF00') + ";} "); //Style used to colorize fleet value in table

//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
GM_addStyle(".Table_GCoords_Colored:link, .Table_GCoords_Colored:visited, .Table_GCoords_Colored:active {text-decoration: none; color:#" + GetData(GlobalProfileUsed, 'color22', 'FFFFFF') + ";}");



//Colorize line coords if the ss distance is bigger than user specified in color23/text35 options
GM_addStyle(".Table_SSCoords_Colored:link, .Table_SSCoords_Colored:visited, .Table_SSCoords_Colored:active {text-decoration: none; color:#" + GetData(GlobalProfileUsed, 'color23', '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;}");
GM_addStyle(".OtableLeftLogo {display: block; cursor: pointer; width: 27px; height:27px; background-image: url(" + Picture.LeftLogo + ");}");

//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("#OptionsProfils {width: 100%;} "); //Lignes principales à dérouler
GM_addStyle("#TableauZoneProfils {width: 100%;}"); //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(".OptionsExport {text-align: left; width: 100%; height: 170 px; width: 100%; } "); //Lignes principales à dérouler



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

//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'].VeryBigText { width:180px; 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 }");
GM_addStyle("textarea.MegaText { width:95%; background-color : #FFFFFF; display: block; margin-left: auto; margin-right: auto; box-shadow:none; border: 1px solid #aaa; height: 150px; padding:0px; border-radius: 0px 0px 0px 0px; !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 ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    var DisplayButton = document.createElement("div"); //Création d'un élément div
    DisplayButton.classList.add('OTableInit');
    DisplayButton.innerHTML = BoardButton(); //Appel de la fonction affichant les boutons du dessus
    var IDsToDisplay = Determine_UiId(Detect_Market());

    document.querySelector(IDsToDisplay[0] + " .tab_inner:first-child").insertBefore(DisplayButton, document.querySelector(IDsToDisplay[0] + " .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,0); //1 = show not deleted spy reports // 0 = not using quickfilter options
    }, true);

    //COLLECT BUTTON
    document.getElementById('CollecterMessages').addEventListener("click", NewCollectAndStoreRE, 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
    document.querySelector('#Plus').addEventListener("click", PlusButton, true);

    //DEBUG BUTTON
    //document.getElementById('DEBUGSR').addEventListener("click", NotUsed, 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");
            var DeleteMultipleButton = document.querySelectorAll("#DELETEMULTIPLE");
            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);
                }
                for (var i = 0; i < DeleteMultipleButton.length; i++) { //Delete multiple lines at once 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);
                    DeleteMultipleButton[i].removeEventListener("click", DeleteMultiple);
                    DeleteMultipleButton[i].addEventListener("click", DeleteMultiple);
                }
                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);



    //Function to launch trashbin when user click on trashbin button
    function TrashbinInit(){ //
        InitialisationTableau('',0,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 = '';
            ModifyRE(IdLineGLB, "Display", 1);
            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") + CurrentTable[i].querySelector(".AttackSondeButton.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';
                ModifyRE(IdLineDeleted, "Display", 0);
                console.log("[O-Table] : Line " + i + " sucessfully deleted");
            }
        }
    }
    //Function to delete multiples lines at once
    function DeleteMultiple(){ //
        var CurrentTable =  document.querySelectorAll(".TableLine");
        var DeleteAtOnce = GetData(ProfileUsed, 'text38', 10); //For + button, amount of lines to delete at once
        console.log('[O-Table] : Deleting the ' + DeleteAtOnce + ' first lines...');

        //Checking if amount of lines visible is at least the amount wished to be deleted, elsewise, we must reduce this amount
        if (DeleteAtOnce > CurrentTable.length) {
            //alert('Le nombre de lignes à supprimer est supérieur au nombre de lignes présent, équilibrage du montant...');
            DeleteAtOnce = CurrentTable.length;
        }
        for (var i = 0; i < DeleteAtOnce; i++) {
            //This part is like a delete button from each line
            var IdLineDeleted = CurrentTable[i].id;
            CurrentTable[i].style.display='none';
            ModifyRE(IdLineDeleted, "Display", 0);
        }
    }
    //END OF + TOOLTIP


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

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


function PlusButton(){
    //Fonction d'affichage du tableau QuickFilter
    //Note : cette fonction est globale car appelée également dans le tableau quickfilter
    QuickFilter();
}


//////////////
//Fonction de création des boutons du tableau
/////////////
function BoardButton()
{
    var LangueIndex = GetLangue();

    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    var DeleteAtOnce = GetData(ProfileUsed, 'text38', 10); //For + button, amount of lines to delete at once

    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><br /><a id=DELETEMULTIPLE >' + Langue.SupprimerVague_Debut.split("|||")[LangueIndex] + DeleteAtOnce + Langue.SupprimerVague_Fin.split("|||")[LangueIndex] +'</a>">&#8239{&#8239+&#8239}</td>' +
                                   //'<li class ="CaseTableButton" id="DEBUGSR">&#8239{&#8239D&#8239}</td>' +

                                  //'<li class ="CaseTableButton"></td>' +
                              '</ul></div>';
    return TableauBoutons;
}


///////////////////////////
function InitialisationTableau(TableauRE,DisplayWhat,UsingQuickFilter) {
    var MetaLocal = MetaDatas();
    var IDsToDisplay = Determine_UiId(Detect_Market());
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    if (GM_getValue('BaseRE-' + 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

        //Get ALL USERS OPTIONS needed to sort and filter the table --> MAJ 0.20
        var GetUsersOptions = UsersOptions(UsingQuickFilter);//Get all users options

        //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 = NewMsgBoard();
            TableauRE.sort(Tri);
            GM_addStyle("#" + currentSort + " { color: #" + GetData(ProfileUsed, 'color14', '00FF00') + "!important; background-color: #151515 !important;} ");
        }
        TriDone = 0;
        var NbItemsTableau = TableauRE.length;
        //alert(NbItemsTableau);

        var DisplayInfos = 0;
        if (GetData(ProfileUsed, 'column17', true) === true) {// by default, information table is shown.
            DisplayInfos = 1;
        }

        if (DisplayInfos == 1) {
            var TableauHTMLInfo = InfoDatasBoard(TableauRE,DisplayWhat,GetUsersOptions); //Tableau d'infos
            var newElementA = document.createElement("div");
            newElementA.innerHTML = TableauHTMLInfo;
            document.querySelector(IDsToDisplay[0] + " .TableButton:first-child").insertBefore(newElementA, document.querySelector(IDsToDisplay[0] + " .TableButton:first-child").nextSibling);
        }


        var TableauHTML = CreateBoardHTML(TableauRE,DisplayWhat,GetUsersOptions); //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(IDsToDisplay[0] + " .TableButton:first-child").insertBefore(newElement, document.querySelector(IDsToDisplay[0] + " .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)
        GM_addStyle("#AfficherTableau { color: #" + GetData(ProfileUsed, 'color13', '00FF00') + ";}");
        //Boutons présents à l'intérieur du tableau//////////////////////////////////////////////////////////////////////////////////////////////////
        ////Bouton suppression de chaque ligne
        //Get amount of spy probes
        var AmountSpyProbes = GetData(ProfileUsed, 'text39', 1);
        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
                    ModifyRE(IdLine, "Display", 0);
                    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
                    ModifyRE(IdLine, "Display", 1);
                    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;
                    ModifyRE(IdLine, "PTAttacked", 1);
                    GM_addStyle("#PT" + IdLine + ".AttackPTButton:visited, #PT" + IdLine + ".AttackPTButton:active { background-color: #" + GetData(ProfileUsed, 'color3', '00FF00') + "!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.
                    if (GetData(ProfileUsed, 'column33', false) === true) { //same thing than classic deletebutton
                        IdLineGLB = IdLine;
                        this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                        ModifyRE(IdLine, "Display", 0);
                        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;
                    ModifyRE(IdLine, "GTAttacked", 1);
                    GM_addStyle("#GT" + IdLine + ".AttackGTButton:visited, #GT" + IdLine + ".AttackGTButton:active { background-color: #" + GetData(ProfileUsed, 'color3', '00FF00') + ";}"); //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.
                    if (GetData(ProfileUsed, 'column33', false) === true) { //same thing than classic deletebutton
                        IdLineGLB = IdLine;
                        this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                        ModifyRE(IdLine, "Display", 0);
                        console.log("[O-Table] : SR deleted successfully");
                    }
                }, true);
            } catch(err){
            }
            try {
                document.querySelectorAll('.AttackSondeButton')[i].addEventListener("click", function(event)                                                  { //AttackButton sonde
                    var SondeAttacked = 1;
                    this.className += " BtnClicked";
                    var IdLine = this.parentNode.parentNode.id;
                    ModifyRE(IdLine, "SondeAttacked", 1);
                    GM_addStyle("#Sonde" + IdLine + ".AttackSondeButton:visited, #Sonde" + IdLine + ".AttackSondeButton:active { background-color: #" + GetData(ProfileUsed, 'color3', '00FF00') + ";}"); //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.
                    if (GetData(ProfileUsed, 'column33', false) === true) { //same thing than classic deletebutton
                        IdLineGLB = IdLine;
                        this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                        ModifyRE(IdLine, "Display", 0);
                        console.log("[O-Table] : SR deleted successfully");
                    }
                }, true);
            } catch(err){
            }
            try {
                document.querySelectorAll('.AttackEclaireurButton')[i].addEventListener("click", function(event)                                                  { //AttackButton Eclaireur
                    var Eclaireur = 1;
                    this.className += " BtnClicked";
                    var IdLine = this.parentNode.parentNode.id;
                    ModifyRE(IdLine, "EclaireurAttacked", 1);
                    GM_addStyle("#Eclaireur" + IdLine + ".AttackEclaireurButton:visited, #Eclaireur" + IdLine + ".AttackEclaireurButton:active { background-color: #" + GetData(ProfileUsed, 'color3', '00FF00') + ";}"); //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.
                    if (GetData(ProfileUsed, 'column33', false) === true) { //same thing than classic deletebutton
                        IdLineGLB = IdLine;
                        this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                        ModifyRE(IdLine, "Display", 0);
                        console.log("[O-Table] : SR deleted successfully");
                    }
                }, true);
            } catch(err){
            }
            try {
                document.querySelectorAll('.AttackButton')[i].addEventListener("click", function(event)                                                  { //AttackButton Not Pre-Selected
                    var Atk = 1;
                    this.className += " BtnClicked";
                    var IdLine = this.parentNode.parentNode.id;
                    ModifyRE(IdLine, "Atk", 1);
                    GM_addStyle("#Atk" + IdLine + ".AttackButton:visited, #Atk" + IdLine + ".AttackButton:active { background-color: #" + GetData(ProfileUsed, 'color3', '00FF00') + ";}"); //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.
                    if (GetData(ProfileUsed, 'column33', false) === true) { //same thing than classic deletebutton
                        IdLineGLB = IdLine;
                        this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                        ModifyRE(IdLine, "Display", 0);
                        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;
                    ModifyRE(IdLine, "RCRecycled", 1);
                    GM_addStyle("#RC" + IdLine + ".RCButton:visited, #RC" + IdLine + ".RCButton:active { background-color: #" + GetData(ProfileUsed, 'color3', '00FF00') + ";}"); //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.
                }, 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 = IdLine + GM_getValue('BaseRE-' + MetaGlobal.Universe).split(IdLine)[1].split(':-|-:')[0];
                    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,AmountSpyProbes);
                    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('SortingSR' + MetaLocal.Universe)) {
                            PairImpair = GM_getValue('SortingSR' + 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 = NewMsgBoard();
                        //tri d'un sens ou d'un autre (en fonction de PairImpair) Le script teste d'abord si il y a changement de colonne, et dans ce cas, le trie se fait toujours de manière descendante et sinon, vérifie l'ordre de tri puis trie dans l'autre sens
                        if (OldSorting == currentID) {
                            if (PairImpair % 2 === 0) {
                                GM_addStyle("#" + currentID + " { color: #" + GetData(ProfileUsed, 'color14', '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 {
                                GM_addStyle("#" + currentID + " { color: #" + GetData(ProfileUsed, 'color15', '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;
                        } else {
                            GM_addStyle("#" + currentID + " { color: #" + GetData(ProfileUsed, 'color14', '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;
                            });
                            PairImpair = 0;
                        }
                        OldSorting = currentID;
                        GM_setValue('SortingSR' + MetaLocal.Universe, PairImpair);
                        InitialisationTableau(TableauRESec,DisplayWhat,0);
                    }, 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 récupération des options utilisateur pour la création du tableau HTML
//New from O-Table 0.20.0
function UsersOptions(UsingQuickFilter)
{

    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    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

    var GetUsersOptions = {};



    if (UsingQuickFilter === 1) { //UsingQuickFilter is equal to 1 only when user pressed on quickfilter "apply" button
        GetUsersOptions.GalaxyShown = "";
        GetUsersOptions.FlotteMaxi = parseInt(document.getElementById("text5").value);
        GetUsersOptions.DefenseMaxi = parseInt(document.getElementById("text6").value);
        GetUsersOptions.AgeMaxi = parseInt(document.getElementById("text7").value);
        GetUsersOptions.RessMin = parseInt(document.getElementById("text28").value);
        GetUsersOptions.MaxLines = parseInt(document.getElementById("text33").value);
        GetUsersOptions.ResOrResCDR = 'Loot';
        if (document.getElementById('radio12').checked === true) { //only resources selected
            if (document.getElementById('radio14').checked === true) { //Standard resources
                GetUsersOptions.ResOrResCDR = 'Loot';
            } else {
                if (document.getElementById('radio15').checked === true) { //MSU resources
                    GetUsersOptions.ResOrResCDR = 'USMPille';
                }
            }
        } else {
            if (document.getElementById('radio13').checked === true) { //resources + debris field
                if (document.getElementById('radio14').checked === true) { //Standard resources
                    GetUsersOptions.ResOrResCDR = 'TotalCDRRes';
                } else {
                    if (document.getElementById('radio15').checked === true) { //MSU resources
                        GetUsersOptions.ResOrResCDR = 'TotalCDRResUSM';
                    }
                }
            }
        }
        for (var i = 2; i < 14; i++){
        //
            if (document.getElementById("cboxquickfilter" + i).checked === true) {
                GetUsersOptions.GalaxyShown = GetUsersOptions.GalaxyShown + (i - 1) + ";";
                }
        }
        //Display Trashbin AND Active targets ?
        GetUsersOptions.DisplayTrashNoTrash = document.getElementById('cboxquickfilter15').checked;
        GetUsersOptions.DisplayHidden = document.getElementById('cboxquickfilter16').checked;

        //Advanced quick filter requests

        GetUsersOptions.AdvancedFilterComparator = document.getElementById('QuickFilterDropDownConditions').value; //Par défaut la valeur est "Skip"
        GetUsersOptions.AdvancedFilterColumn = document.getElementById('QuickFilterDropDownColumns').value; //par défaut la valeur est "" ce qui donne lieu à une recherche de DatasMsg. retournant undefined
        GetUsersOptions.AdvancedFilterValue = document.getElementById('QuickFilterTxt1').value //par défaut la valeur est ""


        //traitement des données entrées par l'utilisateur dans le filtre avancé de QuickFilter

        switch(GetUsersOptions.AdvancedFilterColumn) { //Convert values of GetUsersOptions.AdvancedFilterValue
            case "MetalPille":
            case "CristalPille":
            case "DeuteriumPille":
            case "Total":
            case "Loot":
            case "USMPille":
            case "ProfitsPerHour":
            case "MetalPerHourUsed":
            case "CristalPerHourUsed":
            case "DeutPerHourUsed":
            case "FlotteFinal":
            case "DefenseFinal":
            case "MIP":
                GetUsersOptions.AdvancedFilterValue = parseInt(GetUsersOptions.AdvancedFilterValue.replace(/\D/g,''));
                break;
            case "CoordPlanete":
                //Nothing to do
                break;
                //conversion des durées en secondes
            case "AgeSecCalc":
            case "TempsTrajetSecCalc":
                try {
                    var AgeSplit = GetUsersOptions.AdvancedFilterValue.split(' ');
                    var Hours = 0;
                    var Minutes = 0;
                    var Secondes = 0;
                    if (AgeSplit[2])
                    {
                        Hours = AgeSplit[0].replace(/\D/g,'');
                        Minutes = AgeSplit[1].replace(/\D/g,'');
                        Secondes = AgeSplit[2].replace(/\D/g,'');
                    } else {
                        if(AgeSplit[1]) {
                            Minutes = AgeSplit[0].replace(/\D/g,'');
                            Secondes = AgeSplit[1].replace(/\D/g,'');
                        } else {
                            if (AgeSplit[0]) {
                                Secondes = AgeSplit[0].replace(/\D/g,'');
                            }
                        }
                    }
                    GetUsersOptions.AdvancedFilterValue = ((parseInt(Hours) * 3600) + (parseInt(Minutes) * 60) + parseInt(Secondes));
                }catch(err) {}
                break;
            case "HeureArriveeDisplayed":
            case "HeureRetourDisplayed":
                break;
        }



        /////////////////////////////////////////////NOT USING QUICKFILTER
    } else { //Others cases (display table, etc)
        GetUsersOptions.GalaxyShown = "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;27;28;29;30;31;32;33;34;35;36;37;38;39;40;41;42;43;44;45;46;47;48;49;50"; //Affiche toutes les galaxies
        //Récupération de la valeur choisie par l'utilisateur pour le non affichage des lignes selon certains critères

        GetUsersOptions.FlotteMaxi = GetData(ProfileUsed, 'text5', 999999999999); ////Vérifie la présence d'une donnée sauvegardée ------------------- FLOTTE
        GetUsersOptions.DefenseMaxi = GetData(ProfileUsed, 'text6', 999999999999); ////Vérifie la présence d'une donnée sauvegardée ------------------- DEFENSE
        GetUsersOptions.AgeMaxi = GetData(ProfileUsed, 'text7', 999); ////Vérifie la présence d'une donnée sauvegardée ------------------- AGE
        GetUsersOptions.RessMin = GetData(ProfileUsed, 'text28', 0);////Vérifie la présence d'une donnée sauvegardée ------------------- MINIMAL AMOUNT OF RESOURCES

        //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....") Default choice : Standard, without DF (radio12+14 is true and radio 13+15 is false)
        //Used to get the propriety name to use to compare spy reports
        //radio 12 = resources only, radio 13 = debris + resources, radio 14 = standard resources, radio 15 = MSU resources
        GetUsersOptions.ResOrResCDR = 'Loot';
        if (GetData(ProfileUsed, 'radio12', true) === true) { //only resources selected
            if (GetData(ProfileUsed, 'radio14', true) === true) { //Standard resources
                GetUsersOptions.ResOrResCDR = 'Loot';
            } else {
                if (GetData(ProfileUsed, 'radio15', false) === true) { //MSU resources
                    GetUsersOptions.ResOrResCDR = 'USMPille';
                }
            }
        } else {
            if (GetData(ProfileUsed, 'radio13', false) === true) { //resources + debris field
                if (GetData(ProfileUsed, 'radio14', true) === true) { //Standard resources
                    GetUsersOptions.ResOrResCDR = 'TotalCDRRes';
                } else {
                    if (GetData(ProfileUsed, 'radio15', false) === true) { //MSU resources
                        GetUsersOptions.ResOrResCDR = 'TotalCDRResUSM';
                    }
                }
            }
        }

        //get user setting for max amount of line to keep on the table

        GetUsersOptions.MaxLines = GetData(ProfileUsed, 'text33', 999);////Vérifie la présence d'une donnée sauvegardée ------------------- MAX LINES TO DISPLAY
        GetUsersOptions.DisplayTrashNoTrash = false;
        GetUsersOptions.DisplayHidden = false;

        //Advanced quick filter requests

        GetUsersOptions.AdvancedFilterComparator = 'Skip'; //Skip = valeur par défaut du comparateur. La Lookup table renvoie directement true à la vue de "Skip" pour automatiquement passer le if dans CreateBoardHTML
        GetUsersOptions.AdvancedFilterColumn = ""; //par défaut la valeur est "" ce qui donne lieu à une recherche de DatasMsg. retournant undefined
        GetUsersOptions.AdvancedFilterValue = ""; //par défaut la valeur est ""
    }

    //Toutes les variables ci dessous récupèrent les options dans la partie "affichage des colonnes" des options (fonction OptionsButton)
        //
    /////////////////////////////START/////////////GETTING USER SELECTED COLUMN DISPLAYED//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    GetUsersOptions.DisplayLeftLine = GetData(ProfileUsed, 'column0', true) //DisplayLeftLine
    GetUsersOptions.DisplayRightLine = GetData(ProfileUsed, 'column1', false) //DisplayRightLine
    GetUsersOptions.DisplayCoord = GetData(ProfileUsed, 'column2', true) //DisplayRightLine
    GetUsersOptions.DisplayMetal = GetData(ProfileUsed, 'column3', false) //DisplayMetal
    GetUsersOptions.DisplayCristal = GetData(ProfileUsed, 'column4', false) //DisplayCristal
    GetUsersOptions.DisplayDeut = GetData(ProfileUsed, 'column5', false) //DisplayDeut
    GetUsersOptions.DisplayTotal = GetData(ProfileUsed, 'column6', false) //DisplayTotal
    GetUsersOptions.DisplayButinRatio = GetData(ProfileUsed, 'column7', false) //DisplayButinRatio
    GetUsersOptions.DisplayFlotte = GetData(ProfileUsed, 'column8', true) //DisplayFlotte
    GetUsersOptions.DisplayDefense = GetData(ProfileUsed, 'column9', true) //DisplayDefense
    GetUsersOptions.DisplayLoot = GetData(ProfileUsed, 'column10', true) //DisplayLoot
    GetUsersOptions.DisplayLootUSM = GetData(ProfileUsed, 'column23', false) //DisplayLootUSM
    GetUsersOptions.DisplayPlayer = GetData(ProfileUsed, 'column11', true) //DisplayPlayer
    GetUsersOptions.DisplayLinkSonde = GetData(ProfileUsed, 'column49', false) //DisplayLinkSonde
    GetUsersOptions.DisplayLinkEclaireur = GetData(ProfileUsed, 'column51', false) //DisplayLinkEclaireur
    GetUsersOptions.DisplayLinkAtk = GetData(ProfileUsed, 'column53', false) //DisplayLinkEclaireur
    GetUsersOptions.DisplayLinkPT = GetData(ProfileUsed, 'column12', true) //DisplayLinkPT
    GetUsersOptions.DisplayLinkGT = GetData(ProfileUsed, 'column13', true) //DisplayLinkGT
    GetUsersOptions.DisplayLinkRC = GetData(ProfileUsed, 'column25', true) //DisplayLinkRC
    GetUsersOptions.DisplayHour = GetData(ProfileUsed, 'column14', true) //DisplayHour
    GetUsersOptions.DisplayDelete = GetData(ProfileUsed, 'column15', true) //DisplayDelete
    GetUsersOptions.DisplayMoreDetails = GetData(ProfileUsed, 'column16', true) //DisplayMoreDetails
    GetUsersOptions.DisplayTravelTime = GetData(ProfileUsed, 'column26', false) //DisplayTravelTime
    GetUsersOptions.DisplayArrivalTime = GetData(ProfileUsed, 'column27', false) //DisplayArrivalTime
    GetUsersOptions.DisplayBackTime = GetData(ProfileUsed, 'column28', false) //DisplayBackTime
    GetUsersOptions.DisplayProfitsHour = GetData(ProfileUsed, 'column29', false) //DisplayProfitsHour
    GetUsersOptions.DisplayMetalProfitsHour = GetData(ProfileUsed, 'column46', false) //DisplayMetalProfitsHour
    GetUsersOptions.DisplayCristalProfitsHour = GetData(ProfileUsed, 'column47', false) //DisplayCristalProfitsHour
    GetUsersOptions.DisplayDeuteriumProfitsHour = GetData(ProfileUsed, 'column48', false) //DisplayDeuteriumProfitsHour
    GetUsersOptions.DisplayMissiles = GetData(ProfileUsed, 'column31', false) //DisplayMissiles
    /////////////////////////////END/////////////GETTING USER SELECTED COLUMN DISPLAYED////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //Récupération du % cdr flotte et def //Get Debris freet + defense field ratio
    GetUsersOptions.TxCDRFleet = GetData(ProfileUsed, 'text20', 30);
    GetUsersOptions.TxCDRDef = GetData(ProfileUsed, 'text21', 0);


    ////////////////////////////////////////////////
    //To know the line title of travel time
    //radio0 = Aller, radio1 = aller/retour. Radio0 check par défaut
    GetUsersOptions.TextTravelTime = Langue.RETimeTravel.split("|||")[LangueIndex];
    if (GetData(ProfileUsed, 'radio0', true) === true) {
        GetUsersOptions.TextTravelTime = Langue.RETimeTravel.split("|||")[LangueIndex]
    } else {
        if (GetData(ProfileUsed, 'radio1', false) === true) {
            GetUsersOptions.TextTravelTime = Langue.RETimeTravelAR.split("|||")[LangueIndex]
        }
    }

    //Define profit/hour column name and add id MSU on the table (if necessary)
    GetUsersOptions.USMHr = ''; //Helps to define profits per hour USM id line in the board
    GetUsersOptions.TextColProfitsHr = Langue.RELootHour.split("|||")[LangueIndex];
    //To know the line title of profits/hour column. radio10 = checked, radio 11 not
    if (GetData(ProfileUsed, 'radio10', true) === true) { //standard
        GetUsersOptions.TextColProfitsHr = Langue.RELootHour.split("|||")[LangueIndex] + '<br />' + Langue.Brut.split("|||")[LangueIndex];
    } else {
        if (GetData(ProfileUsed, 'radio11', false) === true) { //MSU
            GetUsersOptions.TextColProfitsHr = Langue.RELootHour.split("|||")[LangueIndex] + '<br />' + Langue.USM.split("|||")[LangueIndex];
            GetUsersOptions.USMHr = "USM";
        }
    }



    //Get user option choice to choose between standard / msu resources on "Display a spy report if it's profitable after sending missiles" default radio16 not checked, radio 17 checked
    GetUsersOptions.MIP_Profits_StdMSU = 'LootMIP';
    if (GetData(ProfileUsed, 'radio16', false) === true) { //Standard resources
        GetUsersOptions.MIP_Profits_StdMSU = 'LootMIP';
    } else {
        if (GetData(ProfileUsed, 'radio17', true) === true) { //MSU resources
            GetUsersOptions.MIP_Profits_StdMSU = 'USMPilleMIP';
        }
    }

    //Récupération du choix utilisateur pour : ouvrir les attaques dans un nouvel onglet
    if (GetData(ProfileUsed, 'column20', true) === false) {
        GetUsersOptions.NewOnglet = '';
    } else {
        GetUsersOptions.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
    GetUsersOptions.TextSize = GetData(ProfileUsed, 'DropDown2', 100);



    GM_addStyle(".InfosVague { font-size: " + GetUsersOptions.TextSize + "%;  } ");
    //To know the COLOR of ATTACK and RECYCLE BUTTONS once clicked and page refreshed (color4 in options) :

    GM_addStyle(".BtnClicked:link { background-color: #" + GetData(ProfileUsed, 'color4', 'ff0000') + ";}");

    //ZONE DEDIEE AU TABLEAU RECAP

    GetUsersOptions.NbSlots = GetData(ProfileUsed, 'text18', 20); //amount of slots per wave
    GetUsersOptions.DisplayUSM = GetData(ProfileUsed, 'column24', false); //Display or show MSU profits line
    GetUsersOptions.DisplayShipsWave = GetData(ProfileUsed, 'column36', true); //Display or show ships per wave line
    GetUsersOptions.DisplayRawProfits = GetData(ProfileUsed, 'column37', true);//Display or show raw profits for the wave line
    GetUsersOptions.DisplayAvgProfits = GetData(ProfileUsed, 'column38', true);//Display or show average profit per slot line
    GetUsersOptions.DisplayAvgMSUProfits = GetData(ProfileUsed, 'column39', false);//Display or show average msu profits line
    GetUsersOptions.DisplayProfitsPerHour = GetData(ProfileUsed, 'column40', false);//Display or show profits per hour line
    GetUsersOptions.DisplayMSUProfitsPerHour = GetData(ProfileUsed, 'column41', false);//Display or show msu profits per hour line
    GetUsersOptions.MSUvsRAW = GetData(ProfileUsed, 'column42', false);//Display or show msu vs raw ratio  line
    GetUsersOptions.DisplayAvgProfitsPerHour = GetData(ProfileUsed, 'column43', false);//Display or show avg profit per hour line
    GetUsersOptions.DisplayAvgMSUProfitsPerHour = GetData(ProfileUsed, 'column44', false);//Display or show msu avg profit per hour line
    GetUsersOptions.DisplayNbSonde = GetData(ProfileUsed, 'column50', false);//Display amount of probes
    GetUsersOptions.DisplayNbEclaireur = GetData(ProfileUsed, 'column52', false);//Display amount of probes


    GetUsersOptions.PTorGTRawProfitsPerHour = 'ProfitsPerHour';//default value
    GetUsersOptions.PTorGTMSUProfitsPerHour = 'ProfitsPerHourUSM';//default value
    if (GetData(ProfileUsed, 'radio21', false) === true) { //checks if heavy cargo is selected to compute profits per hour value
        GetUsersOptions.PTorGTRawProfitsPerHour = 'ProfitsPerHour_GT';
    } else if (GetData(ProfileUsed, 'radio28', false) === true) {
        GetUsersOptions.PTorGTRawProfitsPerHour = 'ProfitsPerHour_Sonde';
    } else if (GetData(ProfileUsed, 'radio34', false) === true) {
        GetUsersOptions.PTorGTRawProfitsPerHour = 'ProfitsPerHour_Eclaireur';
    }
    if (GetData(ProfileUsed, 'radio23', false) === true) { //checks if heavy cargo is selected to compute MSU profits per hour value
        GetUsersOptions.PTorGTMSUProfitsPerHour = 'ProfitsPerHourUSM_GT';
    } else if (GetData(ProfileUsed, 'radio29', false) === true) {
        GetUsersOptions.PTorGTMSUProfitsPerHour = 'ProfitsPerHourUSM_Sonde';
    } else if (GetData(ProfileUsed, 'radio35', false) === true) {
        GetUsersOptions.PTorGTMSUProfitsPerHour = 'ProfitsPerHourUSM_Eclaireur';
    }
    return GetUsersOptions;
}


//Fonction de création du tableau HTML
function CreateBoardHTML(DatasMsg,DisplayWhat,GetUsersOptions) //premier attribut = données des messages, second attribut = afficher corbeille ou afficher tableau, troisième attribut = options utilisateur
{
    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




    var DisplayCoorsdToTravel = false; //Debug column, not activable with script options. Put this variable to true to activate the column.
    var MetaLocal = MetaDatas();


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

    NbColumnsDisplayed = (GetUsersOptions.DisplayLeftLine+GetUsersOptions.DisplayRightLine+GetUsersOptions.DisplayCoord+GetUsersOptions.DisplayMetal+GetUsersOptions.DisplayCristal+GetUsersOptions.DisplayDeut+GetUsersOptions.DisplayTotal+GetUsersOptions.DisplayButinRatio+GetUsersOptions.DisplayFlotte+GetUsersOptions.DisplayDefense+GetUsersOptions.DisplayLoot+GetUsersOptions.DisplayLootUSM+GetUsersOptions.DisplayPlayer+GetUsersOptions.DisplayLinkPT+GetUsersOptions.DisplayLinkGT+GetUsersOptions.DisplayHour+GetUsersOptions.DisplayDelete+GetUsersOptions.DisplayMoreDetails+GetUsersOptions.DisplayTravelTime+GetUsersOptions.DisplayArrivalTime+GetUsersOptions.DisplayBackTime+GetUsersOptions.DisplayProfitsHour+GetUsersOptions.DisplayMetalProfitsHour+GetUsersOptions.DisplayCristalProfitsHour+GetUsersOptions.DisplayDeuteriumProfitsHour+GetUsersOptions.DisplayLinkSonde+GetUsersOptions.DisplayLinkEclaireur);
    //alert(GetUsersOptions.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");
    }


    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 = '';
    var GalaxyFound = '';



    var DisplayGalaxies = GetUsersOptions.GalaxyShown.split(";");
    var AddClassDeleted = ''; //Used to add "Deleted" Class on a row which add a red left line on the row
    var AddClassHidden = ''; //Used to add "Hidden" Class on a rown which add a white left line on the row
    //alert(GetUsersOptions.DisplayHidden);

    //Comptabilisation du temps de création du tableau HTML
    var StartExec = new Date().getTime();

    //Lookup table, thanks to http://jsfiddle.net/jonypawks/Cq8Hd/ and https://stackoverflow.com/questions/10591243/is-there-a-way-to-make-a-comparison-operator-a-variable
    //Lookup table is equal to if (a < b), elsif (a<=b), elsif(a>b), etc.. or a switch
    var comparaisons = {
        '<': function(a, b) { return a < b; },
        '<=': function(a, b) { return a <= b; },
        '>': function(a, b) { return a > b; },
        '>=': function(a, b) { return a >= b; },
        '===': function(a, b) { return a == b; },
        '!==': function(a, b) { return a !== b; },
        //'LIKE': function(a, b) { return s.match(/hello.*/); },
        'Skip': function() { return true} //Skip est la valeur par défaut, la lookup table renvoie toujours true par défaut (true = aucun filtrage effectué, c'est comme si elle n'est pas utilisée). Pas de comparaison effectuée par défaut
    };
    /// Usage sample of lookup table
    //console.log(comparaisons['<'](3, 6));
    //console.log(comparaisons['==='](3, 6));
    //console.log(comparaisons['>']('9:402:13', '3:402:12')); returns true, works with players too
    /*
    if (comparaisons[GetUsersOptions.AdvancedFilterComparator](DatasMsg[0][GetUsersOptions.AdvancedFilterColumn], GetUsersOptions.AdvancedFilterValue) === true) { //note : par défaut, DatasMsg[j][GetUsersOptions.AdvancedFilterColumn] renvoie undefined car GetUsersOption. = undefined (AdvancedFilterColum = "" par défaut)
        alert("case true" + GetUsersOptions.AdvancedFilterValue);
    } else {
        alert("case false" + GetUsersOptions.AdvancedFilterValue);
    }
    */
    // End of sample usage of lookup table
    //--------------for next version, for like function
    //alert('Pillage USM du RE : ' + DatasMsg[0].USMPille + ', la comparaison renvoie' + comparaisons['<'](DatasMsg[0].USMPille, 1000000));





    //console.log("[O-Table] : DisplayPlayer = " + DisplayPlayer);
    //Première ligne du tableau
    var Board = '<div class ="InfosVague"><table class ="TableauRaid">' +
        DisplayColumn(GetUsersOptions.DisplayLeftLine,            '<th class ="FirstLine" id="Id">' + Langue.RELine.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayCoord,               '<th class ="FirstLine" id="RawCoordCalc">' + Langue.RECoords.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayPlayer,              '<th class ="FirstLine" id="PlayerMin">(<span style="color:#ff8080">Act</span>) ' + Langue.REPlayer.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(GetUsersOptions.DisplayHour,                '<th class ="FirstLine" id="AgeSecCalc">' + Langue.REAge.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(GetUsersOptions.DisplayTravelTime,          '<th class ="FirstLine" id="TempsTrajetSecCalc">' + GetUsersOptions.TextTravelTime + '</th>')+
        DisplayColumn(GetUsersOptions.DisplayArrivalTime,         '<th class ="FirstLine" id="TempsTrajetSecCalc">' + Langue.HeureArrivee.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(GetUsersOptions.DisplayBackTime,            '<th class ="FirstLine" id="TempsTrajetSecCalc">' + Langue.HeureRetour.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(GetUsersOptions.DisplayMetal,               '<th class ="FirstLine" id="MetalPille">' + Langue.REMetal.split("|||")[LangueIndex] + '</th>')+
        DisplayColumn(GetUsersOptions.DisplayCristal,             '<th class ="FirstLine" id="CristalPille">' + Langue.RECristal.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayDeut,                '<th class ="FirstLine" id="DeuteriumPille">' + Langue.REDeut.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayTotal,               '<th class ="FirstLine" id="Total">' + Langue.RETotal.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayLoot,                '<th class ="FirstLine" id="Loot">' + Langue.RELoot.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayLootUSM,             '<th class ="FirstLine" id="USMPille">' + Langue.RELootUSM.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayProfitsHour,         '<th class ="FirstLine" id="ProfitsPerHour' + GetUsersOptions.USMHr + '">' + GetUsersOptions.TextColProfitsHr + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayMetalProfitsHour,    '<th class ="FirstLine" id="MetalPerHourUsed">' + Langue.MetH.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayCristalProfitsHour,  '<th class ="FirstLine" id="CristalPerHourUsed">' + Langue.CriH.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayDeuteriumProfitsHour,'<th class ="FirstLine" id="DeutPerHourUsed">' + Langue.DeuH.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayButinRatio,          '<th class ="FirstLine" id="Butin">' + Langue.REButinRatio.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayFlotte,              '<th class ="FirstLine" id="FlotteFinal">' + Langue.REFlotte.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayDefense,             '<th class ="FirstLine" id="DefenseFinal">' + Langue.REDefense.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayMissiles,            '<th class ="FirstLine" id="MIP">' + Langue.Missiles.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayLinkPT,              '<th class ="FirstLine" id="NbPT">' + Langue.PT.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayLinkGT,              '<th class ="FirstLine" id="NbGT">' + Langue.GT.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayLinkSonde,           '<th class ="FirstLine" id="NbSonde">' + Langue.Sonde.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayLinkEclaireur,       '<th class ="FirstLine" id="NbEclaireur">' + Langue.Eclaireur.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayLinkAtk,             '<th class ="FirstLine" id="Atk_NoSelection"></th>') +
        DisplayColumn(GetUsersOptions.DisplayLinkRC,              '<th class ="FirstLine" id="TotalRC">' + Langue.RC.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.DisplayMoreDetails,         '<th class ="FirstLine"></th>') +
        DisplayColumn(GetUsersOptions.DisplayDelete,              '<th class ="FirstLine"></th>') +
        DisplayColumn(GetUsersOptions.DisplayRightLine,           '<th class ="FirstLine" id="Id">' + Langue.RELine.split("|||")[LangueIndex] + '</th>') +
        DisplayColumn(GetUsersOptions.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 < GetUsersOptions.MaxLines) {
            //Checks if user clicked on show hidden lines (QuickFilter)
            if (GetUsersOptions.DisplayHidden === true) { //This is activated only if user checked "display hidden lines".
                //Checks if a row should be hidden by criterias (reverse check)
                if (DatasMsg[j].FlotteFinal > GetUsersOptions.FlotteMaxi || DatasMsg[j].DefenseFinal > GetUsersOptions.DefenseMaxi || DatasMsg[j].AgeSec > (GetUsersOptions.AgeMaxi*3600) || DatasMsg[j][GetUsersOptions.ResOrResCDR] < (GetUsersOptions.RessMin) || comparaisons[GetUsersOptions.AdvancedFilterComparator](DatasMsg[j][GetUsersOptions.AdvancedFilterColumn], GetUsersOptions.AdvancedFilterValue) === false) {
                    AddClassHidden = 'Hidden'; //no Hidden class is added if user didn't check "display hidden lines".
                }
            }
            if (comparaisons[GetUsersOptions.AdvancedFilterComparator](DatasMsg[j][GetUsersOptions.AdvancedFilterColumn], GetUsersOptions.AdvancedFilterValue) === true  || AddClassHidden == 'Hidden') { //note : par défaut, DatasMsg[j][GetUsersOptions.AdvancedFilterColumn] renvoie undefined car GetUsersOption. = undefined (AdvancedFilterColum = "" par défaut)
                if (DatasMsg[j].Display == DisplayWhat || GetUsersOptions.DisplayTrashNoTrash === true) { //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 <= GetUsersOptions.FlotteMaxi || DatasMsg[j][GetUsersOptions.MIP_Profits_StdMSU] > 0 || AddClassHidden == 'Hidden') { //Vérifie si la flotte du RE est inférieur au montant maximum souhaité par l'utilisateur
                        if (DatasMsg[j].DefenseFinal <= GetUsersOptions.DefenseMaxi || DatasMsg[j][GetUsersOptions.MIP_Profits_StdMSU] > 0 || AddClassHidden == 'Hidden') {//Vérifie si la défense du RE est inférieur au montant maximum souhaité par l'utilisateur
                            if (DatasMsg[j].AgeSec <= (GetUsersOptions.AgeMaxi*3600) || AddClassHidden == 'Hidden') { //Vérifie si l'âge du RE est inférieur au montant maximum souhaité par l'utilisateur
                                if (DatasMsg[j][GetUsersOptions.ResOrResCDR] >= (GetUsersOptions.RessMin) || AddClassHidden == 'Hidden') { //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;
                                    //Fonction pour vérifier si la galaxie du RE correspond aux galaxies que l'on veut afficher
                                    GalaxyFound = DisplayGalaxies.find(function(element) {
                                        return element == DatasMsg[j].CoordGalaxie;
                                    });
                                    if (GalaxyFound == DatasMsg[j].CoordGalaxie) {
                                        //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] + ' : ' + GetUsersOptions.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] + ' : ' + GetUsersOptions.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;
                                        var Column_SondeTitle = Langue.SondeLong.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].NbSondeDisplayed;
                                        var Column_EclaireurTitle = Langue.EclaireurLong.split("|||")[LangueIndex] + ' : ' + DatasMsg[j].NbEclaireurDisplayed;
                                        //BEGIN SPY REPORT TABLE/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                        var Row =DisplayColumn(GetUsersOptions.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(GetUsersOptions.DisplayCoord,               '<td class ="InsideBoard Coord ">' + '<a class="CoordLink ' + DatasMsg[j].CoordPlanete_Colored + '" href="' + DatasMsg[j].LienGalaxie + '" ' + GetUsersOptions.NewOnglet +  '">' + DatasMsg[j].CoordPlanete + " " + DatasMsg[j].Moon + '</a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayPlayer,              '<td class ="InsideBoard PlayerCell tooltipRight" style="font-size: ' + (GetUsersOptions.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(GetUsersOptions.DisplayHour,                '<td class ="InsideBoard" id="AGE' + DatasMsg[j].Id + '">' + DatasMsg[j].AgeDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayTravelTime,          '<td class ="InsideBoard tooltipRight" id="TRAVTIME' + DatasMsg[j].Id + '" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].TempsTrajetDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayArrivalTime,         '<td class ="InsideBoard tooltipRight" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].HeureArriveeDisplayedClock + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayBackTime,            '<td class ="InsideBoard tooltipRight" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].HeureRetourDisplayedClock + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayMetal,               '<td class ="InsideBoard" style="font-size: ' + (GetUsersOptions.TextSize - 10) + '% !important;">' + DatasMsg[j].MetalPilleDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayCristal,             '<td class ="InsideBoard" style="font-size: ' + (GetUsersOptions.TextSize - 10) + '% !important;">' + DatasMsg[j].CristalPilleDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayDeut,                '<td class ="InsideBoard" style="font-size: ' + (GetUsersOptions.TextSize - 10) + '% !important;">' + DatasMsg[j].DeuteriumPilleDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayTotal,               '<td class ="InsideBoard">' + DatasMsg[j].TotalDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayLoot,                '<td class ="InsideBoard tooltipRight" id="LOOT' + DatasMsg[j].Id + '" title="' + Column_LootTitle + '">' + DatasMsg[j].LootDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayLootUSM,             '<td class ="InsideBoard tooltipRight" id="LOOTUSM' + DatasMsg[j].Id + '" title="' + Column_LootTitle + '">' + DatasMsg[j].USMPilleDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayProfitsHour,         '<td class ="InsideBoard tooltipRight" id="PH' + DatasMsg[j].Id + '" title="' + DatasMsg[j].TimeTitle + '">' + DatasMsg[j].ProfitsPerHourDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayMetalProfitsHour,    '<td class ="InsideBoard" id="PM' + DatasMsg[j].Id + '">' + DatasMsg[j].MetalPerHourDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayCristalProfitsHour,  '<td class ="InsideBoard" id="PC' + DatasMsg[j].Id + '">' + DatasMsg[j].CristalPerHourDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayDeuteriumProfitsHour,'<td class ="InsideBoard" id="PD' + DatasMsg[j].Id + '">' + DatasMsg[j].DeutPerHourDisplayed + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayButinRatio,          '<td class ="InsideBoard">' + DatasMsg[j].Butin + '</td>') +
                                            DisplayColumn(GetUsersOptions.DisplayFlotte,              '<td class ="InsideBoard tooltipRight" title="' + Column_FleetTitle + '"><a class="FltDefCtn" " href="' + DatasMsg[j].Simulation + '" target="_blank">' + DatasMsg[j].FlotteDisplayed + '</a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayDefense,             '<td class ="InsideBoard tooltipRight" title="' + Column_DefTitle + '"><a class="FltDefCtn" href="' + DatasMsg[j].Simulation + '" target="_blank">' + DatasMsg[j].DefenseDisplayed + '</a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayMissiles,            '<td class ="InsideBoard tooltipRight" title="' + Column_MIPTitle + '"><a class="FltDefCtn" href="' + DatasMsg[j].Simulation + '" target="_blank">' + DatasMsg[j].MIPDisplayed + '</a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayLinkPT,              '<td class ="InsideBoard">' + '<a id="PT' + DatasMsg[j].Id + '" class="AttackPTButton tooltipRight' + IsClicked(DatasMsg[j], "PT") + '" title="' + Column_PTTitle + '" href="' + DatasMsg[j].LienPT + '" ' + GetUsersOptions.NewOnglet +  '></a></td>') + //use IsClicked function to attribute a css style depending on if user already clicked on the button or not
                                            DisplayColumn(GetUsersOptions.DisplayLinkGT,              '<td class ="InsideBoard">' + '<a id="GT' + DatasMsg[j].Id + '" class="AttackGTButton tooltipRight' + IsClicked(DatasMsg[j], "GT") + '" title="' + Column_GTTitle + '" href="' + DatasMsg[j].LienGT + '" ' + GetUsersOptions.NewOnglet +  '></a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayLinkSonde,           '<td class ="InsideBoard">' + '<a id="Sonde' + DatasMsg[j].Id + '" class="AttackSondeButton tooltipRight' + IsClicked(DatasMsg[j], "Sonde") + '" title="' + Column_SondeTitle + '" href="' + DatasMsg[j].LienSonde + '" ' + GetUsersOptions.NewOnglet +  '></a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayLinkEclaireur,       '<td class ="InsideBoard">' + '<a id="Eclaireur' + DatasMsg[j].Id + '" class="AttackEclaireurButton tooltipRight' + IsClicked(DatasMsg[j], "Eclaireur") + '" title="' + Column_EclaireurTitle + '" href="' + DatasMsg[j].LienEclaireur + '" ' + GetUsersOptions.NewOnglet +  '></a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayLinkAtk,             '<td class ="InsideBoard">' + '<a id="Atk' + DatasMsg[j].Id + '" class="AttackButton tooltipRight' + IsClicked(DatasMsg[j], "Atk") + '" href="' + DatasMsg[j].LienAtk + '" ' + GetUsersOptions.NewOnglet +  '></a></td>') +
                                            DisplayColumn(GetUsersOptions.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 + '" ' + GetUsersOptions.NewOnglet +  '></a></td>') +
                                            DisplayColumn(GetUsersOptions.DisplayMoreDetails,         '<td class ="InsideBoard"><a id="MoreDetails" class="overlay" href="' + DatasMsg[j].LienDetails + '"></a></td>');
                                        if (DisplayWhat === 1) {
                                            Row = Row + DisplayColumn(GetUsersOptions.DisplayDelete,   '<td class ="InsideBoard"><div id="DeleteA"></div>');
                                        } else {
                                            Row = Row + DisplayColumn(GetUsersOptions.DisplayDelete,   '<td class ="InsideBoard"><div id="UnDelete"></div>');
                                        }
                                        Row = Row + DisplayColumn(GetUsersOptions.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(GetUsersOptions.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/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                        //This IF checks if the spy report should be in the trashbin and if user checked "Display trashbin lines and enclose in red" in QuickFilter table and add a class to the row
                                        if (DatasMsg[j].Display == 0 && GetUsersOptions.DisplayTrashNoTrash === true) {
                                            AddClassDeleted = 'RowDeleted';
                                            AddClassHidden = ''; //Reset de la classe Hidden pour que le rouge prenne le pas sur le blanc
                                        } else {
                                            AddClassDeleted = '';
                                        }
                                        // 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 ' + AddClassDeleted + ' ' + AddClassHidden + '" 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 ' + AddClassDeleted + ' ' + AddClassHidden + '" id="' + DatasMsg[j].Id + '">' + Row; //LIGNE A REMETTRE
                                        }
                                        //Reset de la variable classe Hidden
                                        AddClassHidden = '';
                                        //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);
    //Comptabilisation du temps de création du tableau
    var EndExec = new Date().getTime();
    var TimeExec = EndExec - StartExec;
    console.log('HTML table time generation : ' + TimeExec + 'ms, for ' + NbItems + 'lines');
    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;
        case "Sonde":
            if (DatasMsg.SondeAttacked == 1) {
                return " BtnClicked";
            } else {
                return "";
            }
        case "Eclaireur":
            if (DatasMsg.EclaireurAttacked == 1) {
                return " BtnClicked";
            } else {
                return "";
            }
            break;
        case "Atk":
            if (DatasMsg.Atk == 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,GetUsersOptions) //premier attribut = données des messages, second attribut = afficher corbeille ou afficher tableau, troisième attribut = options utilisateur
{

    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 FirstWaveSumSonde = 0;
    var SecondWaveSumSonde = 0;
    var ThirdWaveSumSonde = 0;
    var FirstWaveSumEclaireur = 0;
    var SecondWaveSumEclaireur = 0;
    var ThirdWaveSumEclaireur = 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
    var GalaxyFound = '';
    var DisplayGalaxies = GetUsersOptions.GalaxyShown.split(";");
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    var Hidden = '';
    //Lookup table for QuickFilter (more info on CreateBoardHTML function)
    var comparaisons = {
        '<': function(a, b) { return a < b; },
        '<=': function(a, b) { return a <= b; },
        '>': function(a, b) { return a > b; },
        '>=': function(a, b) { return a >= b; },
        '===': function(a, b) { return a == b; },
        '!==': function(a, b) { return a !== b; },
        'Skip': function() { return true} //Skip est la valeur par défaut, la lookup table renvoie toujours true par défaut (true = aucun masquage effectué, c'est comme si elle n'est pas utilisée). Pas de comparaison effectuée par défaut
    };

    console.log("[O-Table] : Generating information Table...");

    function ColorizeInfoTable(WaveNumber, WaveSumLOOT, WaveSumUSM, WaveSumPerHour, WaveSumPerHourUSM, WaveRatio)
    {
        //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 (WaveSumLOOT > GetData(ProfileUsed, 'text4', 17500000)) {
            GM_addStyle("#RawAvg" + WaveNumber + " {color: #" + GetData(ProfileUsed, 'color9', '00FF00') +";}");
        }

        //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 (WaveSumUSM > GetData(ProfileUsed, 'text29', 22500000)) {
            GM_addStyle("#MSUAvg" + WaveNumber + " {color: #" + GetData(ProfileUsed, 'color18', '00FF00') +";}");
        }

        //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 (WaveSumPerHour > GetData(ProfileUsed, 'text30', 17500000)) {
            GM_addStyle("#RawHour" + WaveNumber + " {color: #" + GetData(ProfileUsed, 'color19', '00FF00') +";}");
        }

        //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 (WaveSumPerHourUSM > GetData(ProfileUsed, 'text31', 22500000)) {
            GM_addStyle("#MSUHour" + WaveNumber + " {color: #" + GetData(ProfileUsed, 'color20', '00FF00') +";}");
        }

        //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 (WaveRatio > GetData(ProfileUsed, 'text32', 1.38)) {
            GM_addStyle("#MSURaw" + WaveNumber + " {color: #" + GetData(ProfileUsed, 'color21', '00FF00') +";}");
        }

    }


    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 < (GetUsersOptions.NbSlots * 3); i) { //Collecte renta Première vague
        if (DatasMsg[Msg]) {
            if (CountLines < GetUsersOptions.MaxLines) {
                //Checks if user clicked on show hidden lines (QuickFilter)
                if (GetUsersOptions.DisplayHidden === true) { //This is activated only if user checked "display hidden lines".
                    //Checks if a row should be hidden by criterias (reverse check)
                    if (DatasMsg[Msg].FlotteFinal > GetUsersOptions.FlotteMaxi || DatasMsg[Msg].DefenseFinal > GetUsersOptions.DefenseMaxi || DatasMsg[Msg].AgeSec > (GetUsersOptions.AgeMaxi*3600) || DatasMsg[Msg][GetUsersOptions.ResOrResCDR] < (GetUsersOptions.RessMin) || comparaisons[GetUsersOptions.AdvancedFilterComparator](DatasMsg[Msg][GetUsersOptions.AdvancedFilterColumn], GetUsersOptions.AdvancedFilterValue) === false) {
                        Hidden = 'Hidden'; //no Hidden class is added if user didn't check "display hidden lines".
                    }
                }
                if (comparaisons[GetUsersOptions.AdvancedFilterComparator](DatasMsg[Msg][GetUsersOptions.AdvancedFilterColumn], GetUsersOptions.AdvancedFilterValue) === true  || Hidden == 'Hidden') { //note : par défaut, DatasMsg[Msg][GetUsersOptions.AdvancedFilterColumn] renvoie undefined car GetUsersOption. = undefined (AdvancedFilterColum = "" par défaut)
                    if (DatasMsg[Msg].Display == DisplayWhat || GetUsersOptions.DisplayTrashNoTrash === true) { //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 <= GetUsersOptions.FlotteMaxi || DatasMsg[Msg][GetUsersOptions.MIP_Profits_StdMSU] > 0  || Hidden == 'Hidden') { //Vérifie si la flotte du RE est inférieur au montant maximum souhaité par l'utilisateur
                            if (DatasMsg[Msg].DefenseFinal <= GetUsersOptions.DefenseMaxi || DatasMsg[Msg][GetUsersOptions.MIP_Profits_StdMSU] > 0  || Hidden == 'Hidden') {//Vérifie si la défense du RE est inférieur au montant maximum souhaité par l'utilisateur
                                if (DatasMsg[Msg].AgeSec <= (GetUsersOptions.AgeMaxi*3600)  || Hidden == 'Hidden') { //Vérifie si l'âge du RE est inférieur au montant maximum souhaité par l'utilisateur
                                    if (DatasMsg[Msg][GetUsersOptions.ResOrResCDR] >= (GetUsersOptions.RessMin)  || Hidden == 'Hidden') { //Checks if the spy reports has more resources than the minimum wished by user (default value is 0, standard resources without debris field --> Loot)
                                        //Fonction pour vérifier si la galaxie du RE correspond aux galaxies que l'on veut afficher
                                        GalaxyFound = DisplayGalaxies.find(function(element) {
                                            return element == DatasMsg[Msg].CoordGalaxie;
                                        });
                                        if (GalaxyFound == DatasMsg[Msg].CoordGalaxie) {
                                            if (i < GetUsersOptions.NbSlots) {
                                                FirstWaveSumPT = FirstWaveSumPT + DatasMsg[Msg].NbPT;
                                                FirstWaveSumGT = FirstWaveSumGT + DatasMsg[Msg].NbGT;
                                                FirstWaveSumSonde = FirstWaveSumSonde + DatasMsg[Msg].NbSonde;
                                                FirstWaveSumEclaireur = FirstWaveSumEclaireur + DatasMsg[Msg].NbEclaireur;
                                                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][GetUsersOptions.PTorGTRawProfitsPerHour];
                                                FirstWaveSumPerHourUSM = FirstWaveSumPerHourUSM + DatasMsg[Msg][GetUsersOptions.PTorGTMSUProfitsPerHour];
                                                l = (i + 1);
                                            } else {
                                                if (i < (GetUsersOptions.NbSlots * 2)) {
                                                    SecondWaveSumPT = SecondWaveSumPT + DatasMsg[Msg].NbPT;
                                                    SecondWaveSumGT = SecondWaveSumGT + DatasMsg[Msg].NbGT;
                                                    SecondWaveSumSonde = SecondWaveSumSonde + DatasMsg[Msg].NbSonde;
                                                    SecondWaveSumEclaireur = SecondWaveSumEclaireur + DatasMsg[Msg].NbEclaireur;
                                                    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][GetUsersOptions.PTorGTRawProfitsPerHour];
                                                    SecondWaveSumPerHourUSM = SecondWaveSumPerHourUSM + DatasMsg[Msg][GetUsersOptions.PTorGTMSUProfitsPerHour];
                                                    m = (i - GetUsersOptions.NbSlots + 1);
                                                } else {
                                                    if (i < (GetUsersOptions.NbSlots * 3)) {
                                                        ThirdWaveSumPT = ThirdWaveSumPT + DatasMsg[Msg].NbPT;
                                                        ThirdWaveSumGT = ThirdWaveSumGT + DatasMsg[Msg].NbGT;
                                                        ThirdWaveSumSonde = ThirdWaveSumSonde + DatasMsg[Msg].NbSonde;
                                                        ThirdWaveSumEclaireur = ThirdWaveSumEclaireur + DatasMsg[Msg].NbEclaireur;
                                                        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][GetUsersOptions.PTorGTRawProfitsPerHour];
                                                        ThirdWaveSumPerHourUSM = ThirdWaveSumPerHourUSM + DatasMsg[Msg][GetUsersOptions.PTorGTMSUProfitsPerHour];
                                                        n = (i - (GetUsersOptions.NbSlots * 2) + 1);
                                                    }
                                                }
                                            }
                                            i = i + 1;
                                            CountLines = CountLines + 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

            }
            Msg = Msg + 1;
        }
        if (DatasMsg[Msg]) {
        } else {
            break;
        }
    }

    MoyFirstWave = FirstWaveSumLOOT / l;
    MoyUSMFirstWave = FirstWaveSumUSM / l;
    MoyFirstWavePerHour = FirstWaveSumPerHour / l;
    MoyFirstWavePerHour_USM = FirstWaveSumPerHourUSM / l;
    FirstWaveRatio = MoyUSMFirstWave / MoyFirstWave;
    FirstWaveRatio = FirstWaveRatio.toFixed(3);
    ColorizeInfoTable(1, FirstWaveSumLOOT, FirstWaveSumUSM, FirstWaveSumPerHour, FirstWaveSumPerHourUSM, FirstWaveRatio);

    MoyScndWave = SecondWaveSumLOOT / m;
    MoyUSMScndWave = SecondWaveSumUSM / m;
    MoySecondWavePerHour = SecondWaveSumPerHour / m;
    MoySecondWavePerHour_USM = SecondWaveSumPerHourUSM / m;
    SecondWaveRatio = SecondWaveSumUSM / SecondWaveSumLOOT;
    SecondWaveRatio = SecondWaveRatio.toFixed(3);
    ColorizeInfoTable(2, SecondWaveSumLOOT, SecondWaveSumUSM, SecondWaveSumPerHour, SecondWaveSumPerHourUSM, SecondWaveRatio);

    MoyThirWave = ThirdWaveSumLOOT / n;
    MoyUSMThirWave = ThirdWaveSumUSM / n;
    MoyThirdWavePerHour = ThirdWaveSumPerHour / n;
    MoyThirdWavePerHour_USM = ThirdWaveSumPerHourUSM / n;
    ThirdWaveRatio = ThirdWaveSumUSM / ThirdWaveSumLOOT;
    ThirdWaveRatio = ThirdWaveRatio.toFixed(3);
    ColorizeInfoTable(3, ThirdWaveSumLOOT, ThirdWaveSumUSM, ThirdWaveSumPerHour, ThirdWaveSumPerHourUSM, ThirdWaveRatio);



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

    var FirstWaveSumSondeDisplayed = "";
    var SecondWaveSumSondeDisplayed = "";
    var ThirdWaveSumSondeDisplayed = "";
    if (GetUsersOptions.DisplayNbSonde === true) { //Show amount of probes per wave
        FirstWaveSumSondeDisplayed = Langue.SondeLong.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(FirstWaveSumSonde);
        SecondWaveSumSondeDisplayed = Langue.SondeLong.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(SecondWaveSumSonde);
        ThirdWaveSumSondeDisplayed = Langue.SondeLong.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(ThirdWaveSumSonde);
    }
    var FirstWaveSumEclaireurDisplayed = "";
    var SecondWaveSumEclaireurDisplayed = "";
    var ThirdWaveSumEclaireurDisplayed = "";
    if (GetUsersOptions.DisplayNbEclaireur === true) { //Show amount of probes per wave
        FirstWaveSumEclaireurDisplayed = Langue.EclaireurLong.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(FirstWaveSumEclaireur);
        SecondWaveSumEclaireurDisplayed = Langue.EclaireurLong.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(SecondWaveSumEclaireur);
        ThirdWaveSumEclaireurDisplayed = Langue.EclaireurLong.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(ThirdWaveSumEclaireur);
    }

    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 (GetUsersOptions.DisplayShipsWave === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.PT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(FirstWaveSumPT) + ' ' + Langue.GT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(FirstWaveSumGT)  + ' ' + FirstWaveSumSondeDisplayed + ' ' + FirstWaveSumEclaireurDisplayed +  '</td>'
                                                                          + '<td class="LigneInfoBoard">' + Langue.PT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(SecondWaveSumPT) + ' ' + Langue.GT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(SecondWaveSumGT) + ' ' + SecondWaveSumSondeDisplayed + ' ' + SecondWaveSumEclaireurDisplayed +  '</td>'
                                                                          + '<td class="LigneInfoBoard">' + Langue.PT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(ThirdWaveSumPT) + ' ' + Langue.GT.split("|||")[LangueIndex] + ' : ' + ThousandSeparator(ThirdWaveSumGT) + ' ' + ThirdWaveSumSondeDisplayed + ' ' + ThirdWaveSumEclaireurDisplayed +  '</td>';
        PairImpair = PairImpair + 1;
    }
    if (GetUsersOptions.DisplayRawProfits === true) {
        Board = Board + '<tr class ="' + FonctionPairImpair(PairImpair) + '"><td class="LigneInfoBoard">' + Langue.InfoRenta.split("|||")[LangueIndex] + ' : <div  id="RawAvg1" style="display:inline;" class="tooltipRight" 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;"  class="tooltipRight" 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>]">' + ThousandSeparator(ThirdWaveSumLOOT) + '</div></td>';
        PairImpair = PairImpair + 1;
    }
    if (GetUsersOptions.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 (GetUsersOptions.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 (GetUsersOptions.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 (GetUsersOptions.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 (GetUsersOptions.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 (GetUsersOptions.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 (GetUsersOptions.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 (GetUsersOptions.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
    var IDsToDisplay = Determine_UiId(Detect_Market());
    GM_addStyle(".TableauQuickFilter { border: 1px solid #555; text-align: left; width: 100%; margin-top: 15px; ;} ");//border-spacing: 5px
    GM_addStyle(".thTableauQuickFilter { border-left: 1px solid #222; height : 25px; text-align: center;} ");
    GM_addStyle(".LigneQuickFilter { border-left: 1px solid #222; height: 25px} ");


    //Used for buttons save and apply
    GM_addStyle(".QuickFilterButton {border: 1px dashed #444; padding: 5px 3px 5px 2px ; text-align: center;");
    GM_addStyle(".QuickFilterButton:hover {border: 1px solid #666; text-align: center;");
    GM_addStyle(".QuickFilterTableButtons {border-spacing: 5px; width: 100%;");
    GM_addStyle(".QuickFilterMiniTableButtons {border-spacing: 5px; display: inline-table;");

    //help table

    GM_addStyle(".TableQuickFilterHelp {  text-align: left; width: 99%; margin: 1%; border-spacing: 8px;  } ");//border-spacing: 5px
    GM_addStyle(".TableQuickFilterHelp td { border: 1px dashed #555; text-align: left; padding: 15px; } ");//border-spacing: 5px
    GM_addStyle(".TableQuickFilterHelp th { border: 1px solid #555; text-align: left; border-bottom-width: 3px; text-indent: 50px; text-transform: uppercase; padding: 5px; font-size: 150%; } ");//border-spacing: 5px


    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    var OptionsStored = UsersOptions(0)

    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) {}

    //Création du dropdown des profils
    //<select class="DropDownShipsMore" id="DropDown1" style="visibility:visible"><option value="0"> FR </option><option value="1"> EN </option></select>' exemple de dropdown
    var DropDownProfiles = '<select class="DropDownProfiles" id="DropDownProfiles" style="visibility:visible">';
    for (var c = 1; c < 11; c++)
    {
        if (!(GetData('Profile' + c, 'name', undefined) === undefined)) //Si le résultat est undefined, cela veut dire qu'il n'y a pas de profil enregistré
        {
            //alert(GetData('Profile' + c, 'name', undefined));
            DropDownProfiles = DropDownProfiles + '<option value="Profile' + c + '">' + GetData('Profile' + c, 'name', undefined) + '</option>';
        }
    }
    DropDownProfiles = DropDownProfiles + '</select>';
    //Création du dropdown contenant les colonnes du tableau
    var DropDownColumns = '<select class="DropDownShipsMore" id="QuickFilterDropDownColumns" style="visibility:visible">' +
        '<option value=""></option>' +
        '<option value="CoordPlanete">' + Langue.RECoords.split("|||")[LangueIndex] + '</option>' +
        '<option value="Player">' + Langue.REPlayer.split("|||")[LangueIndex] + '</option>' +
        '<option value="AgeSecCalc">' + Langue.REAge.split("|||")[LangueIndex] + '</option>' +
        '<option value="TempsTrajetSecCalc">' + OptionsStored.TextTravelTime + '</option>' +
        '<option value="HeureArriveeDisplayed">' + Langue.HeureArrivee.split("|||")[LangueIndex] + '</option>' +
        '<option value="HeureRetourDisplayed">' + Langue.HeureRetour.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="ProfitsPerHour' + OptionsStored.USMHr + '">' + OptionsStored.TextColProfitsHr + '</option>' +
        '<option value="MetalPerHourUsed">' + Langue.MetH.split("|||")[LangueIndex] + '</option>' +
        '<option value="CristalPerHourUsed">' + Langue.CriH.split("|||")[LangueIndex] + '</option>' +
        '<option value="DeutPerHourUsed">' + Langue.DeuH.split("|||")[LangueIndex] + '</option>' +
        '<option value="FlotteFinal">' + Langue.REFlotte.split("|||")[LangueIndex] + '</option>' +
        '<option value="DefenseFinal">' + Langue.REDefense.split("|||")[LangueIndex] + '</option>' +
        '<option value="MIP">' + Langue.Missiles.split("|||")[LangueIndex] + '</option>' +
        '</select>';
    //Création du dropdown contenant les conditions

    var DropDownConditions = '<select class="DropDownShipsMore" id="QuickFilterDropDownConditions" style="visibility:visible">' +
        '<option value="Skip"></option>' +
        '<option value="<">' + Langue.QuickFilterInferieur.split("|||")[LangueIndex] + '</option>' +
        '<option value="<=">' + Langue.QuickFilterInferieurEgal.split("|||")[LangueIndex] + '</option>' +
        '<option value=">">' + Langue.QuickFilterSuperieur.split("|||")[LangueIndex] + '</option>' +
        '<option value=">=">' + Langue.QuickFilterSuperieurEgal.split("|||")[LangueIndex] + '</option>' +
        '<option value="===">' + Langue.QuickFilterEgal.split("|||")[LangueIndex] + '</option>' +
        '<option value="!==">' + Langue.QuickFilterDifferent.split("|||")[LangueIndex] + '</option>' +
        '</select>';


    try {
        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" checked>1</label><label><input type="checkbox" id="cboxquickfilter3" checked>2</label><label><input type="checkbox" id="cboxquickfilter4" checked>3</label><label><input type="checkbox" id="cboxquickfilter5" checked>4</label><label><input type="checkbox" id="cboxquickfilter6" checked>5</label><label><input type="checkbox" id="cboxquickfilter7" checked>6</label><label><input type="checkbox" id="cboxquickfilter8" checked>7</label><label><input type="checkbox" id="cboxquickfilter9" checked>8</label><label><input type="checkbox" id="cboxquickfilter10" checked>9</label><br /><label><input type="checkbox" id="cboxquickfilter11" checked>10</label><label><input type="checkbox" id="cboxquickfilter12" checked>11</label><label><input type="checkbox" id="cboxquickfilter13" checked>12</label><label><input type="checkbox" id="cboxquickfilter17" checked>13</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" title="' + Langue.QuickFilterHiddenTITLE.split("|||")[LangueIndex] + '"><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.QuickFilterProfile.split("|||")[LangueIndex] + DropDownProfiles + '</td></tr>' +
                '<tr class =""><td colspan="2" class="LigneQuickFilter"><table class="QuickFilterTableButtons" ><tr><td class ="QuickFilterButton" id="QF_SaveButton">' + Langue.QuickFilterSave.split("|||")[LangueIndex] + '</td></tr></table></td></tr>'+
                '<tr class ="" id="AdvancedFilter"><td colspan="3" class="LigneQuickFilter">' + Langue.QuickFilterAdvanced.split("|||")[LangueIndex] + DropDownColumns + Langue.QuickFilterIs.split("|||")[LangueIndex] + DropDownConditions + ' <input type="text" class="BigText" id="QuickFilterTxt1" value="" maxlength="50"><table class="QuickFilterMiniTableButtons"><td class ="QuickFilterButton" id="DisplayAdvancedHelp">&#8239{&#8239?&#8239}</td></table></td></tr>' +
                '<tr class =""><td class="LigneQuickFilter" colspan="3"><table class="QuickFilterTableButtons"><tr><td class ="QuickFilterButton" id="ApplyToTableButton">&#8239{&#8239' + Langue.BoutonAfficherTableau.split("|||")[LangueIndex] + '&#8239}</td></tr></table></td></tr>'+ //a Table is used to create a button with border spacing
                '</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(IDsToDisplay[0] + " .TableButton").insertBefore(newElement, document.querySelector(IDsToDisplay[0] + " .LigneTableButton").nextSibling);
            document.getElementById("DropDownProfiles").value = ProfileUsed;
            QuickFilterData(ProfileUsed); //Assignation des valeurs aux champs


            //Function used to assign values to QuickFiler field (based on profile used)
            function QuickFilterData(ProfileUsedForDatas)
            {
                //////////////////////////////////////////////////////////////////GETTING DATAS
                //Spy Report Age
                var AgeMaxi = GetData(ProfileUsedForDatas, 'text7', 999); //Vérifie la présence d'une donnée sauvegardée ------------------- AGE
                document.getElementById("text7").value = AgeMaxi;

                //Spy Report Fleet Max
                var FlotteMaxi = GetData(ProfileUsedForDatas, 'text5', 999999999999);//Vérifie la présence d'une donnée sauvegardée ------------------- Flotte max
                document.getElementById("text5").value = FlotteMaxi;

                //Spy Report Def Max
                var DefMaxi = GetData(ProfileUsedForDatas, 'text6', 999999999999);//Vérifie la présence d'une donnée sauvegardée ------------------- Def Max
                document.getElementById("text6").value = DefMaxi;

                //Minimum profits to show
                var MinProfits = GetData(ProfileUsedForDatas, 'text28', 0);//Vérifie la présence d'une donnée sauvegardée ------------------- Min profits
                document.getElementById("text28").value = MinProfits;

                //Minimum profits to show : standard or msu ?
                document.getElementById("radio14").checked = GetData(ProfileUsedForDatas, 'radio14', true);
                document.getElementById("radio15").checked = GetData(ProfileUsedForDatas, 'radio15', false);

                //Minimum profits to show : DF or not DF ?
                document.getElementById("radio12").checked = GetData(ProfileUsedForDatas, 'radio12', true);
                document.getElementById("radio13").checked = GetData(ProfileUsedForDatas, 'radio13', false);

                var MaxLines = parseInt(GetData(ProfileUsedForDatas, 'text33', 999)); //Vérifie la présence d'une donnée sauvegardée ------------------- Max lines
                document.getElementById("text33").value = MaxLines;
            }

            document.getElementById('QuickFilterDropDownColumns').addEventListener("change", function(event) {
                if (document.getElementById('QuickFilterDropDownColumns').value == 'HeureArriveeDisplayed' || document.getElementById('QuickFilterDropDownColumns').value == 'HeureRetourDisplayed')
                {
                    document.getElementById('QuickFilterTxt1').value = MetaLocal.RawTime;
                }
            }, true);


            //Assignation des fonctions aux boutons///////////////////////////////////////////////////////////////////////////////


            //EventListener pour le bouton pour enregistrer ces options sur le profil utilisé
            document.getElementById('QF_SaveButton').addEventListener("click", QFSave, true)
            function QFSave() {
                GM_setValue(ProfileUsed + ':text7' +  MetaLocal.Universe, document.getElementById('text7').value);//age
                GM_setValue(ProfileUsed + ':text5' +  MetaLocal.Universe, document.getElementById('text5').value);//fleet
                GM_setValue(ProfileUsed + ':text6' +  MetaLocal.Universe, document.getElementById('text6').value);//def
                GM_setValue(ProfileUsed + ':text28' +  MetaLocal.Universe, document.getElementById('text28').value);//minprofit
                GM_setValue(ProfileUsed + ':radio14' +  MetaLocal.Universe, document.getElementById('radio14').checked);//ressstandard
                GM_setValue(ProfileUsed + ':radio15' +  MetaLocal.Universe, document.getElementById('radio15').checked);//ressusm
                GM_setValue(ProfileUsed + ':radio12' +  MetaLocal.Universe, document.getElementById('radio12').checked);//ress
                GM_setValue(ProfileUsed + ':radio13' +  MetaLocal.Universe, document.getElementById('radio13').checked);//ress+df
                GM_setValue(ProfileUsed + ':text33' +  MetaLocal.Universe, document.getElementById('text33').value);//maxlines
                GM_setValue('ProfileUsed:' + MetaLocal.Universe, ProfileUsed);
                document.getElementById("QF_SaveButton").style.color = '#00FF00';
                setTimeout(function() {
                    document.getElementById("QF_SaveButton").style.color = '';
                }, 1000);
            }



            //EventListener pour le dropdown des profils, pour changer les options du tableau.
            document.getElementById('DropDownProfiles').addEventListener("change", SwitchProfile, true)
            function SwitchProfile() {
                ProfileUsed = document.getElementById('DropDownProfiles').value;
                QuickFilterData(ProfileUsed);
            }



            var i;
            //Apply To Table Button
            document.getElementById('ApplyToTableButton').addEventListener("click", function(event) //Bouton "appliquer au tableau, rééxécute l'affichage du tableau avec un 1 au dernier paramètre pour indiquer que les paramètres quickfilter doivent être pris en compte
                                                                        {
                InitialisationTableau('',1,1); //First cannot be used here, this is SR raw datas//1 = show not deleted spy reports//Last = 1, to use users options from quickfilter
            }, true);

            document.getElementById('cboxquickfilter14').addEventListener("click", function(event) //eventlistener pour le bouton qui sélectionne toutes les galaxies. Permet de cocher/décocher tous les boutons des galaxies à la fois
                                                                          {
                if (document.getElementById('cboxquickfilter14').checked === true) { //checked ? okay, then check all galaxies
                    //alert("Checked!");//
                    for (i = 2; i < 14; i++){
                        document.getElementById('cboxquickfilter' + i).checked = true;
                    }
                    document.getElementById('cboxquickfilter17').checked = true;

                    // but... uncheck "only current galaxy"
                    document.getElementById('cboxquickfilter1').checked = false;
                } else {
                    if (document.getElementById('cboxquickfilter14').checked === false) { //unchecked ? okay, uncheck all galaxies
                        //alert("Unchecked!");//
                        for (i = 2; i < 14; i++){
                            document.getElementById('cboxquickfilter' + i).checked = false;
                        }
                        document.getElementById('cboxquickfilter17').checked = false;
                    }
                }
            }, true);
            document.getElementById('cboxquickfilter1').addEventListener("click", function(event) //eventlistener pour le bouton qui sélectionne seulement la galaxie actuelle. Déselectionne tous les autres boutons de galaxie
                                                                         {

                if (document.getElementById('cboxquickfilter1').checked === true) { //checked ? okay, then uncheck all buttons
                    //alert("Checked!");//
                    for (i = 2; i < 15; i++){
                        document.getElementById('cboxquickfilter' + i).checked = false;
                    }
                    document.getElementById('cboxquickfilter17').checked = false;
                    //And Checks current galaxy
                    document.getElementById('cboxquickfilter' + (parseInt(MetaLocal.PlayerCoord.split(":")[0]) + 1)).checked = true;
                } else {
                    if (document.getElementById('cboxquickfilter1').checked === false) { //unchecked ? okay, check all buttons
                        //alert("Unchecked!");//
                        for (i = 2; i < 15; i++){
                            document.getElementById('cboxquickfilter' + i).checked = true;
                        }
                        document.getElementById('cboxquickfilter17').checked = true;
                    }
                }
            }, true);
            for (i = 2; i < 14; i++){
                document.getElementById('cboxquickfilter' + i).addEventListener("click", function(event, i) //EventListener pour les numéros de galaxie. Si un est décoché, décoche le bouton "all" et le bouton "Check current galaxy" et si tous sont sélectionnées, coche le bouton all
                                                                                {
                    //
                    if (this.checked === false) {
                        document.getElementById('cboxquickfilter14').checked = false;
                        document.getElementById('cboxquickfilter1').checked = false;
                    }
                    if (this.checked === true) {
                        document.getElementById('cboxquickfilter1').checked = false;
                    }
                    //this if checks if all galaxies are selected, then it checks "all" checkboxes
                    if (this.checked === true && document.getElementById('cboxquickfilter2').checked === true && document.getElementById('cboxquickfilter3').checked === true && document.getElementById('cboxquickfilter4').checked === true && document.getElementById('cboxquickfilter5').checked === true && document.getElementById('cboxquickfilter6').checked === true && document.getElementById('cboxquickfilter7').checked === true && document.getElementById('cboxquickfilter8').checked === true && document.getElementById('cboxquickfilter9').checked === true && document.getElementById('cboxquickfilter10').checked === true && document.getElementById('cboxquickfilter11').checked === true && document.getElementById('cboxquickfilter12').checked === true && document.getElementById('cboxquickfilter13').checked === true && document.getElementById('cboxquickfilter17').checked === true) {
                        document.getElementById('cboxquickfilter14').checked = true;
                    }

                }, true);
            }





            document.getElementById('DisplayAdvancedHelp').addEventListener("click", displayhelp, true); //EventListener pour le bouton d'aide des filtres avancés
            function displayhelp()
            {
                try {//Permet d'effacer le menu d'aide si déjà présent
                    var Empty = '';
                    var Table = document.querySelector("#HelpInfos");
                    if(Table.outerHTML) {
                        Table.outerHTML = Empty;
                    }
                } catch(err) {}

                //désactive le bouton afficher aide et le remplace par un bouton masquer aide
                this.removeEventListener("click", displayhelp, true);
                this.innerHTML = "{&#8239X&#8239}";
                this.addEventListener("click", hidehelp, true); //EventListenener pour cacher le menu d'aide et recréer le bouton d'origine
                function hidehelp()
                {
                    this.innerHTML = "{&#8239?&#8239}";
                    this.removeEventListener("click", hidehelp, true);
                    this.addEventListener("click", displayhelp, true);
                    try {//Permet d'effacer le menu d'aide si déjà présent
                        var Empty = '';
                        var Table = document.querySelector("#HelpInfos");
                        if(Table.outerHTML) {
                            Table.outerHTML = Empty;
                        }
                    } catch(err) {}
                }

                var Html_Help = '<td colspan="3" class="LigneQuickFilter"><table class="TableQuickFilterHelp"><th>' + Langue.QuickFilterHelpTh.split("|||")[LangueIndex] + '</th>';

                switch(document.getElementById('QuickFilterDropDownColumns').value) { //Convert values of GetUsersOptions.AdvancedFilterValue
                    case "MetalPille":
                    case "CristalPille":
                    case "DeuteriumPille":
                    case "Total":
                    case "Loot":
                    case "USMPille":
                    case "ProfitsPerHour":
                    case "MetalPerHourUsed":
                    case "CristalPerHourUsed":
                    case "DeutPerHourUsed":
                    case "FlotteFinal":
                    case "DefenseFinal":
                    case "MIP":
                        Html_Help = Html_Help + '<tr><td>' + Langue.QuickFilterHelpFormat.split("|||")[LangueIndex] + ' ' + Langue.REMetal.split("|||")[LangueIndex] + ', ' + Langue.RECristal.split("|||")[LangueIndex] + ', ' + Langue.REDeut.split("|||")[LangueIndex] + ', ' + Langue.RETotal.split("|||")[LangueIndex] + ', ' + Langue.RELoot.split("|||")[LangueIndex] + ', ' + Langue.RELootUSM.split("|||")[LangueIndex] + ', ' + OptionsStored.TextColProfitsHr.replace('<br />', " ") + ', ' + Langue.MetH.split("|||")[LangueIndex] + ', ' + Langue.CriH.split("|||")[LangueIndex] + ', ' + Langue.DeuH.split("|||")[LangueIndex] + ', ' + Langue.REFlotte.split("|||")[LangueIndex] + ', ' + Langue.REDefense.split("|||")[LangueIndex] + ', ' + Langue.Missiles.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpDecimale.split("|||")[LangueIndex] + '</td></tr>';
                        break;
                    case "CoordPlanete":
                        Html_Help = Html_Help + '<tr><td>' + Langue.QuickFilterHelpCoord.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpCoordFormat.split("|||")[LangueIndex] + '</td></tr>';
                        break;
                    case "AgeSecCalc":
                    case "TempsTrajetDisplayed":
                        Html_Help = Html_Help + '<tr><td>' + Langue.QuickFilterHelpDuree.split("|||")[LangueIndex] + Langue.REAge.split("|||")[LangueIndex] + ', ' + OptionsStored.TextTravelTime +
                            '<br />' + Langue.QuickFilterHelpDureeFormat.split("|||")[LangueIndex] + '</td></tr>';
                        break;
                    case "HeureArriveeDisplayed":
                    case "HeureRetourDisplayed":
                        Html_Help = Html_Help + '<tr><td>' + Langue.QuickFilterHelpHeure.split("|||")[LangueIndex] + Langue.HeureArrivee.split("|||")[LangueIndex] + ', ' + Langue.HeureRetour.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpHeureFormat.split("|||")[LangueIndex] + '</td></tr>';
                        break;
                    case "Player":
                        Html_Help = Html_Help + '<tr><td>' + Langue.QuickFilterHelpPseudo.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpPseudoFormat.split("|||")[LangueIndex] + '</td></tr>';
                        break;
                    default:
                        Html_Help = Html_Help + '<tr><td>' + Langue.QuickFilterHelpFormat.split("|||")[LangueIndex] + ' ' + Langue.REMetal.split("|||")[LangueIndex] + ', ' + Langue.RECristal.split("|||")[LangueIndex] + ', ' + Langue.REDeut.split("|||")[LangueIndex] + ', ' + Langue.RETotal.split("|||")[LangueIndex] + ', ' + Langue.RELoot.split("|||")[LangueIndex] + ', ' + Langue.RELootUSM.split("|||")[LangueIndex] + ', ' + OptionsStored.TextColProfitsHr.replace('<br />', " ") + ', ' + Langue.MetH.split("|||")[LangueIndex] + ', ' + Langue.CriH.split("|||")[LangueIndex] + ', ' + Langue.DeuH.split("|||")[LangueIndex] + ', ' + Langue.REFlotte.split("|||")[LangueIndex] + ', ' + Langue.REDefense.split("|||")[LangueIndex] + ', ' + Langue.Missiles.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpDecimale.split("|||")[LangueIndex] + '</td></tr>' +
                            '<tr><td>' + Langue.QuickFilterHelpCoord.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpCoordFormat.split("|||")[LangueIndex] + '</td></tr>' +
                            '<tr><td>' + Langue.QuickFilterHelpPseudo.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpPseudoFormat.split("|||")[LangueIndex] + '</td></tr>' +
                            '<tr><td>' + Langue.QuickFilterHelpDuree.split("|||")[LangueIndex] + Langue.REAge.split("|||")[LangueIndex] + ', ' + OptionsStored.TextTravelTime +
                            '<br />' + Langue.QuickFilterHelpDureeFormat.split("|||")[LangueIndex] + '</td></tr>' +
                            '<tr><td>' + Langue.QuickFilterHelpHeure.split("|||")[LangueIndex] + Langue.HeureArrivee.split("|||")[LangueIndex] + ', ' + Langue.HeureRetour.split("|||")[LangueIndex] +
                            '<br />' + Langue.QuickFilterHelpHeureFormat.split("|||")[LangueIndex] + '</td></tr>';

                        break;
                }
                Html_Help = Html_Help + '</table></td>';

                var HelpDesign = Html_Help;
                var HelpElement = document.createElement("tr"); // On crée un nouvelle élément div
                HelpElement.id = 'HelpInfos';
                HelpElement.innerHTML = HelpDesign; // On écrit le code source qu'il contient
                document.querySelector("#AdvancedFilter").parentNode.insertBefore(HelpElement, document.querySelector("#AdvancedFilter").nextSibling);
            }


            //REPRENDRE LA
            //Transformation du bouton "+" en bouton "-"
            document.querySelector('#Plus').removeEventListener("click", PlusButton, true);
            document.querySelector('#Plus').addEventListener("click", MoinsButton, true);
            document.querySelector('#Plus').textContent = '{ - }';


            function MoinsButton(){
                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) {}
                document.querySelector('#Plus').textContent = '{ + }';
                document.querySelector('#Plus').removeEventListener("click", MoinsButton, true);
                document.querySelector('#Plus').addEventListener("click", PlusButton, true);
            }

            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();
    var ProfileUsed = GetData('ProfileUsed','',  'Profile1'); //Default value is "Profile1"
    var EmptyProtected = GetData(ProfileUsed,'column45', 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

    //Couleurs
    document.getElementById("Empty").style.color = '#00FF00';
    document.getElementById("Empty").innerHTML = '&#8239{&#8239' + Langue.BoutonViderOK.split("|||")[LangueIndex] + '&#8239}'
    //Suppression Base RE
    GM_deleteValue('BaseRE-'+MetaLocal.Universe);

    //Ancien système (à garder lors de la migration pour supprimer les anciens messages)
    if(GM_getValue('MessageIndex'+MetaLocal.Universe)) {
        MessageIndex = GM_getValue('MessageIndex'+MetaLocal.Universe, MessageIndex);
        console.log("[O-Table] : Old method : Amount of messages going to be deleted : " + MessageIndex);
        for (var i = 0; i < MessageIndex + 1; i++){
            GM_deleteValue('MessageStoredNumber'+i + MetaLocal.Universe); //A GARDER POUR LA MIGRATION
        }
        MessageIndex = 0;
        GM_setValue('MessageIndex'+MetaLocal.Universe, MessageIndex);
        GM_deleteValue('REIdList'+MetaLocal.Universe, IdMessages);
    }

    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
    var IDsToDisplay = Determine_UiId(Detect_Market());
    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) {}

    //Used for buttons inside options area
    GM_addStyle(".OptionsButtons {border: 1px dashed #444; padding: 5px 3px 5px 2px ; text-align: center; width: 50%");
    GM_addStyle(".OptionsButtons:hover {border: 1px solid #666; text-align: center;");
    GM_addStyle(".OptionsButtonsDisabled {border: 1px dashed #333; padding: 5px 3px 5px 2px ; text-align: center; width: 50%; color:#444");
    GM_addStyle(".OptionsTableButtons {border-spacing: 5px; width: 100%;");
    GM_addStyle(".SmallOptionsButtons {border: 1px dashed #444; padding: 3px 3px 3px 2px ; text-align: center; display: inline;");
    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 ZoneProfils = ('<div id="OptionsProfils"><table id="TableauZoneProfils">' + //Création des options dans la zone profils
                                 '<tr><td class="OptionsGlobalesContent OPT"><table class="OptionsTableButtons"><tr><td class ="OptionsButtons" id="CreateNewProfile">' + Langue.OptionsProfilAB.split("|||")[LangueIndex] + '</td>' +
                                                                                                                   '<td class ="OptionsButtons" id="ModifyName">' + Langue.OptionsProfilAC.split("|||")[LangueIndex] + '</td></tr></table></td></tr>' +
                                 '<tr id="LineProfile"><td class="OptionsGlobalesContent OPT"><form id="ProfilesForm" <form><input id="RadioProfile1" type="radio" name="ProfilesChoice"><label id="LabelRadioProfile1">' + Langue.OptionsProfilAD.split("|||")[LangueIndex] + '</label></form></td></tr>' +
                                 '<tr><td class="OptionsGlobalesContent OPT"><table class="OptionsTableButtons"><tr><td class ="OptionsButtons" id="DeleteProfile">' + Langue.OptionsProfilAE.split("|||")[LangueIndex] + '</td></tr></table></td></tr>' +
                                 '<tr><td class="OptionsGlobalesContent OPT"></td></tr>' +
                        '</table></div>');
    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" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAB.split("|||")[LangueIndex] + ' :                                                        <label><input type="text" id="color1" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAC.split("|||")[LangueIndex] + ' :                               <label><input type="text" id="color2" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAD.split("|||")[LangueIndex] + ' :                                      <label><input type="text" id="color3" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAE.split("|||")[LangueIndex] + ' :      <label><input type="text" id="color4" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAA.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text0" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                      <label><input type="text" id="color5" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAB.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text19" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                      <label><input type="text" id="color10" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesBH.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text27" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                      <label><input type="text" id="color11" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAC.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text1" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                     <label><input type="text" id="color6" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAD.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text2" maxlength="13"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                    <label><input type="text" id="color7" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAF.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color12" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsTextesAE.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text3" maxlength="3"></label> heures, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color8" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAG.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color13" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAH.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color14" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAI.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color15" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAJ.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color16" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAK.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color17" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAL.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text35" maxlength="3"></label> ' + Langue.OptionsCouleurAN.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color23" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAL.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text34" maxlength="2"></label> ' + Langue.OptionsCouleurAM.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color22" maxlength="6"></label>' +
                                 '<li class="OptionsCouleursContent OPT">' + Langue.OptionsCouleurAO.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text40" maxlength="3"></label> ' + Langue.OptionsCouleurAP.split("|||")[LangueIndex] + ' :                                             <label><input type="text" id="color24" 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="cbox49">' + Langue.OptionsCBoxBB.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox51">' + Langue.OptionsCBoxBC.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox53">' + Langue.OptionsCBoxBD.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"> ' + 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio3" type="radio" name="PTGTTRAVTIME"> ' + Langue.SondeLong.split("|||")[LangueIndex] + '<input id="radio24" type="radio" name="PTGTTRAVTIME">' + Langue.EclaireurLong.split("|||")[LangueIndex] + '<input id="radio30" 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio5" type="radio" name="ARTIME"> ' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio25" type="radio" name="ARTIME">' + Langue.EclaireurLong.split("|||")[LangueIndex] + ' <input id="radio31" 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio7" type="radio" name="BATIME"> ' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio26" type="radio" name="BATIME">' + Langue.EclaireurLong.split("|||")[LangueIndex] + ' <input id="radio32" 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio9" type="radio" name="PTGTHOUR"> ' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio27" type="radio" name="PTGTHOUR"> ' + Langue.EclaireurLong.split("|||")[LangueIndex] + ' <input id="radio33" type="radio" name="PTGTHOUR"></form>)<form style="display:inline;"> (' + Langue.Brut.split("|||")[LangueIndex] + ' <input id="radio10" type="radio" name="STDMSUHOUR"> ' + Langue.USM.split("|||")[LangueIndex] + ' <input id="radio11" type="radio" name="STDMSUHOUR"></form>)' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox46">' + Langue.OptionsCBoxAY.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox47">' + Langue.OptionsCBoxAZ.split("|||")[LangueIndex] + '</label>' +
                                 '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="cbox48">' + Langue.OptionsCBoxBA.split("|||")[LangueIndex] + '</label>' +
                                 '<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" maxlength="13"></label>' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAJ.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text6" 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"></form>)' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesBJ.split("|||")[LangueIndex] + '<label><input type="text" class="BigText" id="text28" maxlength="13"></label><form style="display:inline;">(' + Langue.Ressource.split("|||")[LangueIndex] + '<input id="radio12" type="radio" name="RssCDR">' +  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">' + 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" maxlength="3"></label> ' + Langue.OptionsTextesAL.split("|||")[LangueIndex] + '' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesCB.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text33" maxlength="4"></label> ' + Langue.OptionsTextesCC.split("|||")[LangueIndex] + '' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesAM.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text8" maxlength="4"></label> ' + Langue.OptionsTextesBD.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText"  id="text9" maxlength="4"></label> ' + Langue.OptionsTextesBE.split("|||")[LangueIndex] + ' <label><input type="text" class="SmallText" id="text10" 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><option value="2"> ES </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" maxlength="15"></label> ' + Langue.OptionsTextesAS.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text12" maxlength="15"></label> ' + Langue.OptionsTextesAT.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text13" 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" maxlength="9"></label>' +
                                  '<li class="OptionsGlobalesContent OPT"><form style="display:inline;">' +  Langue.OptionsTextesBL.split("|||")[LangueIndex] + '<input id="radio18" type="radio" name="SecondesVaguesStdMSU">' + 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="1"> 1 % </option><option value="2"> 2 % </option><option value="3"> 3 % </option><option value="5"> 5 % </option><option value="7"> 7 % </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] + '<label><input type="checkbox" id="cbox54"></label>' +
                                  '<li class="OptionsGlobalesContent OPT">' + Langue.OptionsTextesBI.split("|||")[LangueIndex] + ' : <select class="DropDownShipsMore" id="DropDown3" style="visibility:visible"><option value="RawCoordCalc">' + Langue.RECoords.split("|||")[LangueIndex] + '</option><option value="PlayerMin">' + Langue.REPlayer.split("|||")[LangueIndex] + '</option><option value="AgeSecCalc">' + Langue.REAge.split("|||")[LangueIndex] + '</option><option value="TempsTrajetSecCalc">' + 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="TempsTrajetSecCalc">' + Langue.HeureArrivee.split("|||")[LangueIndex] + '</option><option value="TempsTrajetSecCalc">' + Langue.HeureRetour.split("|||")[LangueIndex] + '</option><option value="ProfitsPerHourUsed">' + Langue.RELootHour.split("|||")[LangueIndex] + '</option><option value="MetalPerHourUsed">' + Langue.MetH.split("|||")[LangueIndex] + '</option><option value="CristalPerHourUsed">' + Langue.CriH.split("|||")[LangueIndex] + '</option><option value="DeutPerHourUsed">' + Langue.DeuH.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">' + Langue.OptionsTextesCE.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text38" maxlength="3"></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" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAB.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text15" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAC.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text16" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAF.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text22" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAG.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text23" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAH.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text24" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAL.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text36" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAD.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text20" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAE.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text21" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAJ.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text26" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAI.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text25" maxlength="3"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAM.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text37" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAN.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text39" maxlength="2"></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" 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" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color9" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT" title="' + Langue.TableauCouleurExplainedAB.split("|||")[LangueIndex] + '">' + Langue.OptionsTextesBV.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text29" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color18" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT" title="' + Langue.TableauCouleurExplainedAC.split("|||")[LangueIndex] + '">' + Langue.OptionsTextesBW.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text30" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color19" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT" title="' + Langue.TableauCouleurExplainedAD.split("|||")[LangueIndex] + '">' + Langue.OptionsTextesBX.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text31" maxlength="10"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color20" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT">' + Langue.OptionsTextesBY.split("|||")[LangueIndex] + ' <label><input type="text" class="BigText" id="text32" maxlength="4"></label>, ' + Langue.OptionsColorierEn.split("|||")[LangueIndex] + ' :                                                   <label><input type="text" id="color21" maxlength="6"></label>' +
                                  '<li class="OptionsTableauRecapContent OPT">--------------------------------------------------------------------------------------------------------------------------' +
                                  '<li class="OptionsTableauRecapContent OPT"><label><input type="checkbox" id="cbox36"></label>' + Langue.OptionsTextesBP.split("|||")[LangueIndex] + ' (+ ' + Langue.SondeLong.split("|||")[LangueIndex] + ' <label><input type="checkbox" id="cbox50"></label> + ' + Langue.EclaireurLong.split("|||")[LangueIndex] + ' <label><input type="checkbox" id="cbox52"></label> )' + //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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio21" type="radio" name="PTorGTRawProfitsPerHourRecapTable">' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio28" type="radio" name="PTorGTRawProfitsPerHourRecapTable">' + Langue.EclaireurLong.split("|||")[LangueIndex] + ' <input id="radio34" 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio23" type="radio" name="PTorGTMSUProfitsPerHourRecapTable">' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio29" type="radio" name="PTorGTMSUProfitsPerHourRecapTable">' + Langue.EclaireurLong.split("|||")[LangueIndex] + ' <input id="radio35" 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.OptionsProfilAA.split("|||")[LangueIndex] + ' </td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + ZoneProfils + '</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(IDsToDisplay[0] + " .TableButton:first-child").insertBefore(newElement, document.querySelector(IDsToDisplay[0] + " .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;} ");


    //COUNT EVERY OPTIONS DISPLAYED. Used to get and save datas, very important
    var NbCheckBox = document.querySelector('#OptionsMainTable').querySelectorAll('input[id*="cbox"]').length; //attention : les premières options commencent avec l'id 0. Par ex pour 49cbox, le dernier id sera cbox48
    var NbColors = document.querySelector('#OptionsMainTable').querySelectorAll('input[id*="color"]').length;
    var NbTexts = document.querySelector('#OptionsMainTable').querySelectorAll('input[id*="text"]').length;
    var NbDropDown = document.querySelector('#OptionsMainTable').querySelectorAll('select[id*="DropDown"]').length;
    var NbRadio = document.querySelector('#OptionsMainTable').querySelectorAll('input[id*="radio"]').length;
    //alert("cbox=" + NbCheckBox + " colors=" + NbColors + " texts=" + NbTexts + " dropdown=" + NbDropDown + " radio=" + NbRadio);



    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////------------------------------------------/////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////DATAS MIGRATION TO PROFILES (v1.0 O-Table)/////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////------------------------------------------/////////////////////////////////////////////////////////////////
    //Datas used to test : one of the first option O-Table had, which cannot be set to nothing. Data chosen to check : % extra amount of ships to send when attacking. Datas in dropdown are always existing if there is options saved by users.
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    if (GM_getValue('DropDown0' + MetaLocal.Universe)) { //DropDown0 = extra amount of ships option
        console.log('[O-Table] : Data Migration script : there are datas stored on old options. Migrating these datas to the new profile feature (v1.0 O-Table)');
        if (!(GM_getValue('Profile1:DropDown0' + MetaLocal.Universe))) { // ! = negation, or IF NOT
            console.log('[O-Table] : Data Migration script : no datas stored on profile1 settings. Process to migration launched.');
            //Migration part
            for (var z = 0; z < NbCheckBox; z++) { //Boucle pour les checkbox //saves checkboxes
                if (!(GM_getValue('column' + z + MetaLocal.Universe) === undefined)) //if not undefined...
                {
                    GM_setValue('Profile1:column' + z +  MetaLocal.Universe, GM_getValue('column' + z + MetaLocal.Universe));
                    console.log('[O-Table] : Migrating column' + z + ' value (' + GM_getValue('column' + z + MetaLocal.Universe) + ') to Profile1:column' + z + ' successfully (value stored : ' + GM_getValue('Profile1:column' + z + MetaLocal.Universe) + ')');
                    GM_deleteValue('column' + z + MetaLocal.Universe);
                }
            }
            for (var y = 0; y < NbColors; y++) { //Boucle pour la zone "Couleurs" //saves colors
                if (!(GM_getValue('color' + y + MetaLocal.Universe) === undefined)) //if not undefined...
                {
                    GM_setValue('Profile1:color' + y +  MetaLocal.Universe, GM_getValue('color' + y + MetaLocal.Universe));
                    console.log('[O-Table] : Migrating color' + y + ' value (' + GM_getValue('color' + y + MetaLocal.Universe) + ') to Profile1:color' + y + ' successfully (value stored : ' + GM_getValue('Profile1:color' + y + MetaLocal.Universe) + ')');
                    GM_deleteValue('color' + y + MetaLocal.Universe);
                }
            }
            for (var x = 0; x < NbTexts; x++) { //Boucle pour les datas de type "texte" //saves text values
                if (!(GM_getValue('text' + x + MetaLocal.Universe) === undefined)) //if not undefined...
                {
                    GM_setValue('Profile1:text' + x +  MetaLocal.Universe, GM_getValue('text' + x + MetaLocal.Universe));
                    console.log('[O-Table] : Migrating text' + x + ' value (' + GM_getValue('text' + x + MetaLocal.Universe) + ') to Profile1:text' + x + ' successfully (value stored : ' + GM_getValue('Profile1:text' + x + MetaLocal.Universe) + ')');
                    GM_deleteValue('text' + x + MetaLocal.Universe);
                }
            }
            for (var w = 0; w < NbDropDown; w++) { //Boucle pour les dropdown //saves dropdown
                if (!(GM_getValue('DropDown' + w + MetaLocal.Universe) === undefined)) //if not undefined...
                {
                    GM_setValue('Profile1:DropDown' + w +  MetaLocal.Universe, GM_getValue('DropDown' + w + MetaLocal.Universe));
                    console.log('[O-Table] : Migrating DropDown' + w + ' value (' + GM_getValue('DropDown' + w + MetaLocal.Universe) + ') to Profile1:DropDown' + w + ' successfully (value stored : ' + GM_getValue('Profile1:DropDown' + w + MetaLocal.Universe) + ')');
                    GM_deleteValue('DropDown' + w + MetaLocal.Universe);
                }
            }
            for (var v = 0; v < NbRadio; v++) { //Boucle pour les radio //saves radio buttons
                if (!(GM_getValue('radio' + v + MetaLocal.Universe) === undefined)) //if not undefined...
                {
                    GM_setValue('Profile1:radio' + v +  MetaLocal.Universe, GM_getValue('radio' + v + MetaLocal.Universe));
                    console.log('[O-Table] : Migrating radio' + v + ' value (' + GM_getValue('radio' + v + MetaLocal.Universe) + ') to Profile1:radio' + v + ' successfully (value stored : ' + GM_getValue('Profile1:radio' + v + MetaLocal.Universe) + ')');
                    GM_deleteValue('radio' + v + MetaLocal.Universe);
                }
            }

        } else {
            console.log('[O-Table] : There are already data stored on Profile1. Migration process cancelled');
        }
    } else {
        console.log('[O-Table] : There is no datas stored on old options. No migration to the new profile feature needed (v1.0 O-Table)');
    }



    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////------------------------------------------/////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////END OF DATAS MIGRATION PART (v1.0 O-Table)/////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////------------------------------------------/////////////////////////////////////////////////////////////////

    //Get profile used (saved)
    var ProfileUsed = GetData('ProfileUsed','', undefined); //Default value is undefined, first launch of the sript results in undefined.
    if (ProfileUsed === undefined)
    {
        //Quand l'utilisateur clique sur créer profil, le script vérifie si le nom d'un profil existe. Il faut donc en pré enregistrer un pour éviter d'écraser le premier profil.
        GM_setValue('Profile1:name' + MetaLocal.Universe, document.getElementById('LabelRadioProfile1').textContent); //ex : Profile1name:s123-fr.ogame.gameforge.com
        ProfileUsed = 'Profile1';
    }
    //alert(ProfileUsed);

    GetOptions(0);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////FUNCTIONS AND BUTTONS PART
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function GetOptions(CallIndicator)
    {


        if (CallIndicator === 0 ) { //Callindicator est à 0 quand les options sont chargées la première fois.
            //gestion des profils : (name) : affichage des boutons radios et création des noms.
            var FirstOccurence = true;
            for (var c = 1; c < 11; c++)
            {
                if (!(GetData('Profile' + c, 'name', undefined) === undefined)) //Si le résultat est undefined, cela veut dire qu'il n'y a encore aucun profil présent
                {
                    //alert(GetData('Profile' + c, 'name', undefined));
                    if (FirstOccurence === true) { //Le premier bouton de profil est déjà présent, il faut donc remplacer ses infos
                        document.getElementById('RadioProfile1').id = ('RadioProfile' + c);
                        document.getElementById('LabelRadioProfile1').id = ('LabelRadioProfile' + c);
                        document.getElementById('LabelRadioProfile' + c).textContent = GetData('Profile' + c, 'name', 'PROFILE_NAME_NOT_DEFINED');
                        FirstOccurence = false;
                    } else { //Les autres boutons doivent être créés
                        document.getElementById('ProfilesForm').innerHTML = document.getElementById('ProfilesForm').innerHTML + '<br><input id="RadioProfile' + c + '" type="radio" name="ProfilesChoice"><label id="LabelRadioProfile' + c + '">' + GetData('Profile' + c, 'name', 'PROFILE_NAME_NOT_DEFINED') + '</label>'; //add a radio button

                    }
                }
            }
        }
        if (CallIndicator === 1) { //CallIndicator is equal to 1 when user clicked on a radio profile button. This helps to find the button
            ProfileUsed = document.querySelector('input[name = "ProfilesChoice"]:checked').id.split('Radio')[1]; //cherche le bouton radio coché; Il faut utiliser le bouton coché pour charger les options, et non le profil utilisé par défaut
        }
        //alert(ProfileUsed);
        document.getElementById('Radio' + ProfileUsed).checked = true;


        //gestion des données (checkbox) : Affichage des colonnes cochées
        //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/cbox46/cbox47/cbox48/cbox49cbox50/cbox51/cbox52/cbox53//cbox54
        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, false, false, 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
        for (var j = 0; j < NbCheckBox; j++){
            document.getElementById('cbox' + j ).checked = GetData(ProfileUsed, 'column' + j, 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
        /////////////////////////color///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////
        var DefaultColors = new Array("0C8528", "FFFFFF", "00FF00", "00FF00", "FF0000", "00FF00", "FF0000", "FF0000", "FF0000", "00FF00", "00FF00", "00FF00", "00FF00", "00FF00", "00FF00", "FF3010", "111A21", "18242D", "00FF00", "00FF00", "00FF00", "00FF00", "FFFFFF", "FFFFFF", "FF0000");
        for (var k = 0; k < NbColors; k++) {
            document.getElementById("color" + k).value = GetData(ProfileUsed, 'color' + k, DefaultColors[k]); //Default value is equal to the value by default in html code
            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...)
        ///////////////////////text//////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/////27////////28////29/////////////30//////////31////////32/////33////34////35//36//37/////38///39///40//
        var DefaultTexts = new Array("1000000", "1000000", "1000000", "2", "17500000", "999999999999", "999999999999", "999", "3", "2", "1", Langue.Milliard.split("|||")[LangueIndex], Langue.Million.split("|||")[LangueIndex], Langue.Milliers.split("|||")[LangueIndex], "0", "0", "0", "400000", "20", "1000000", "30", "0", "0", "0", "0", "499", "9", "1000000", "0", "22500000", "17500000", "22500000", "1.38", "999", "1", "50", "0", "5", "10", "1", "999");
        for (var m = 0; m < NbTexts; m++){
            document.getElementById("text" + m).value = GetData(ProfileUsed, 'text' + m, DefaultTexts[m]) //default value is equal to the value by default in the text field
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //gestion des données (DropDown) : Affichage des valeurs dropdown
        document.getElementById("DropDown0").value = GetData(ProfileUsed, 'DropDown0', '20'); //% Extra ships
        document.getElementById("DropDown1").value = GetData(ProfileUsed, 'DropDown1', LangueIndex); //Default language
        document.getElementById("DropDown2").value = GetData(ProfileUsed, 'DropDown2', '100'); //Text size
        document.getElementById("DropDown3").value = GetData(ProfileUsed, 'DropDown3', 'Loot'); //Column to sort
        //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 = "K";
                    break;
                case "1":
                    //alert("EN");
                    document.getElementById('text11').value = "Bn";
                    document.getElementById('text12').value = "M";
                    document.getElementById('text13').value = "K";
                    break;
                case "2":
                    //alert("ES");
                    document.getElementById('text11').value = "G";
                    document.getElementById('text12').value = "M";
                    document.getElementById('text13').value = "K";
                    break;
                default:
                    //alert("Autre");
                    break;
            }
        }, true);

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Gestion des radio button //radio button
        ////////////////////////radio//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////27///////28/////29////30//////31/////32////33//////34/////35///
        var DefaultRadio = new Array(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, false, true, true, false, true, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false);
        for (var r = 0; r < NbRadio; r++){
            document.getElementById("radio" + r).checked = GetData(ProfileUsed, 'radio' + r, DefaultRadio[r]);
        }
    }
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////BOUTONS///////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //PROFILES RADIO BUTTONS
    RadioProfileClick(); //called once when the options are generated
    function RadioProfileClick()//Function used to load profile data when clicking on a radio profile button. (called when user click on options buttons and when user create a new profile)
    {
        var AllProfiles= document.querySelectorAll("input[name='ProfilesChoice'").length; //counts all inputs radio buttons
        for (var a = 1; a < (AllProfiles + 1); a++) {
            document.querySelectorAll("input[name='ProfilesChoice'")[(a - 1)].addEventListener("click", ProfileClick, true); //QuerySelectorAll est nécessaire car il peut manquer par exemple l'id 3 entre l'id 2 et 4 si le profil a été supprimé
        }
    }
    function RemoveRadioProfileClick() //remove assigned function on radio profile buttons
    {
        var AllProfiles= document.querySelectorAll("input[name='ProfilesChoice'").length; //counts all inputs radio buttons
        for (var a = 1; a < (AllProfiles + 1); a++) {
            document.querySelectorAll("input[name='ProfilesChoice'")[(a - 1)].removeEventListener("click", ProfileClick, true);
        }
    }
    function ProfileClick()
    {
        GetOptions(1); //1 is used to change ProfileUsed value in GetOption function
    }





    // SAVE BUTTON
    //Mise en mémoire de toutes les 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 < NbCheckBox; i++) { //Boucle pour les checkbox //saves checkboxes
            GM_setValue(ProfileUsed + ':column' + i +  MetaLocal.Universe, document.getElementById('cbox' + i).checked);
        }
        for (var l = 0; l < NbColors; l++) { //Boucle pour la zone "Couleurs" //saves colors
            GM_setValue(ProfileUsed + ':color' + l +  MetaLocal.Universe, document.getElementById('color' + l).value);
        }
        for (var n = 0; n < NbTexts; n++) { //Boucle pour les datas de type "texte" //saves text values
            GM_setValue(ProfileUsed + ':text' + n +  MetaLocal.Universe, document.getElementById('text' + n).value);
        }
        for (var p = 0; p < NbDropDown; p++) { //Boucle pour les dropdown //saves dropdown
            GM_setValue(ProfileUsed + ':DropDown' + p +  MetaLocal.Universe, document.getElementById('DropDown' + p).value);
        }
        for (var q = 0; q < NbRadio; q++) { //Boucle pour les radio //saves radio buttons
            GM_setValue(ProfileUsed + ':radio' + q +  MetaLocal.Universe, document.getElementById('radio' + q).checked);
        }
        //Profile Used :
        GM_setValue('ProfileUsed:' + MetaLocal.Universe, document.querySelector('input[name = "ProfilesChoice"]:checked').id.split('Radio')[1]); //Get the first checked radio button in the input names profileschoices, and then split the id to get "Profile1", "Profile2", etc...
        var AllProfiles= document.querySelectorAll("input[name='ProfilesChoice'").length; //counts all inputs radio buttons
        for (var b = 1; b < (AllProfiles + 1); b++) { //save all profiles names ex : ('Profile1:name:s123-fr.ogame.ogameforge.com, General')
            GM_setValue(document.querySelectorAll("input[name='ProfilesChoice'")[(b - 1)].id.split('Radio')[1] + ':name' + MetaLocal.Universe, document.querySelector("#ProfilesForm").querySelectorAll("label")[(b - 1)].textContent);
            //alert(document.querySelectorAll("input[name='ProfilesChoice'")[(b - 1)].id.split('Radio')[1] + ':name' + MetaLocal.Universe); //alerts pour afficher le nom du profil
            //alert(document.querySelector("#ProfilesForm").querySelectorAll("label")[(b - 1)].textContent);
        }
        //
        console.log("[O-Table Options] : Options successfully saved!");
        location.reload(); //Rechargement de la page
    }, true);

    //BOUTON CREATE NEW PROFILE
    var CreateButtonUsed = false;
    if (document.querySelectorAll("input[name='ProfilesChoice'").length < 10) { //checks if there are less than 10 profiles already saved, then add the eventlistener or change the button class
        document.getElementById('CreateNewProfile').addEventListener("click", addnewprofile, true);
    } else {
        document.getElementById('CreateNewProfile').classList.remove("OptionsButtons");//modifie le CSS pour supprimer CSS OptionsButton
        document.getElementById('CreateNewProfile').classList.add("OptionsButtonsDisabled");
    }

    function addnewprofile()
    {
        var AllProfiles= document.querySelectorAll("input[name='ProfilesChoice'").length; //counts all inputs radio buttons
        if (AllProfiles < 10) { //max profiles amount = 10
            var IdNewProfil = '';
            for (var aa = 1; aa < 11; aa++) {
                if (GetData('Profile' + aa, 'name', undefined) === undefined)
                {
                    // alert('Profile' + aa + 'doesnt exist');
                    IdNewProfil = aa;
                    aa = 11;
                }
            }
            document.getElementById('ProfilesForm').innerHTML = document.getElementById('ProfilesForm').innerHTML + '<br><input id="RadioProfile' + IdNewProfil + '" type="radio" name="ProfilesChoice"><label id="LabelRadioProfile' + IdNewProfil + '">' + Langue.OptionsProfilAF.split("|||")[LangueIndex] + '</label>'; //add a new radio button
            this.removeEventListener("click", addnewprofile, true); //removes eventlistener
            CreateButtonUsed = true;
            document.getElementById('CreateNewProfile').classList.remove("OptionsButtons");//modifie le CSS pour supprimer CSS OptionsButton
            document.getElementById('CreateNewProfile').classList.add("OptionsButtonsDisabled");
            document.getElementById('RadioProfile' + IdNewProfil).checked = true;
            GetOptions(1);
            RemoveRadioProfileClick();
            RadioProfileClick();

        }
    }

    //BOUTON MODIFY PROFILE NAME
    document.getElementById('ModifyName').addEventListener("click", modifyprofile, true); //Fonction séparée pour pouvoir la rappeler après avoir cliqué sur "annuler modification"
    function modifyprofile()
    {
        var ProfileSelected = document.querySelector('input[name = "ProfilesChoice"]:checked').id; //cherche le bouton radio coché
        var ProfileName = document.getElementById('Label' + ProfileSelected).textContent; //récupère le nom actuel du profil.
        //Création du formulaire pour changer le nom du profil
        document.getElementById('Label' + ProfileSelected).innerHTML = '<input type="text" class="VeryBigText" id="TextProfile" value="' + ProfileName + '" maxlength="50">&#8239&#8239<div class ="SmallOptionsButtons" id="ValidRename">' + Langue.OptionsProfilAH.split("|||")[LangueIndex] + '</div>'; //remplace le texte correspondant au nom du profil par un formulaire

        //Désactive le bouton pour modifier les profils et le remplace par un bouton "annuler"
        this.removeEventListener("click", modifyprofile, true); //removes eventlistener pour modifier le profil (évite de modifier plusieurs noms à la fois)
        this.innerHTML = Langue.OptionsProfilAG.split("|||")[LangueIndex]; //modifie le nom de la case

        //Disable buttons Create new profile and delete profile (helps to avoid bugs)
        document.getElementById('CreateNewProfile').removeEventListener("click", addnewprofile, true) //Si un nouveau profil est créé sans que le bouton valider soit appuyé, le bouton valider perd sont eventlistener
        document.getElementById('CreateNewProfile').classList.remove("OptionsButtons");//modifie le CSS pour supprimer CSS OptionsButton
        document.getElementById('CreateNewProfile').classList.add("OptionsButtonsDisabled");
        document.getElementById('DeleteProfile').removeEventListener("click", deleteprofile, true); //Désactive également le bouton deleteprofile
        document.getElementById('DeleteProfile').classList.remove("OptionsButtons");//modifie le CSS pour supprimer CSS OptionsButton
        document.getElementById('DeleteProfile').classList.add("OptionsButtonsDisabled");

        //Création du bouton annuler à la place du bouton modifier profil et création du bouton valider pour valider le nouveau nom
        document.getElementById('ModifyName').addEventListener("click", cancelmodification, true); //crée une nouvelle fonction sur ce bouton qui permet d'annuler les modifs
        document.getElementById('ValidRename').addEventListener("click", validateren, true); //Bouton valider à côté du champ texte quand on modifie le nom d'un profil

        ///------------------------------------------------------------FUNCTION PART------------------------------------------------------
        //boutons créés quand on clique sur modifier (cancelmodification et validateren)
        function cancelmodification () {
            this.innerHTML = Langue.OptionsProfilAC.split("|||")[LangueIndex];
            this.removeEventListener("click", cancelmodification, true);
            document.getElementById('ModifyName').addEventListener("click", modifyprofile, true); //recrée le bouton original
            if (CreateButtonUsed === false) {
                //Restore Add new profile button only if it hasn't been clicked before
                document.getElementById('CreateNewProfile').addEventListener("click", addnewprofile, true); //recréer le bouton créer profil original
                document.getElementById('CreateNewProfile').classList.remove("OptionsButtonsDisabled");//modifie le CSS pour supprimer CSS OptionsButton
                document.getElementById('CreateNewProfile').classList.add("OptionsButtons");
            }
            //Restore deletebutton
            document.getElementById('DeleteProfile').addEventListener("click", deleteprofile, true);
            document.getElementById('DeleteProfile').classList.remove("OptionsButtonsDisabled");//modifie le CSS pour supprimer CSS OptionsButton
            document.getElementById('DeleteProfile').classList.add("OptionsButtons");
            document.getElementById('Label' + ProfileSelected).innerHTML = ProfileName;
        }

        function validateren()
        {
            var NewName = document.getElementById('TextProfile').value; //Récupère le nouveau nom dans le champ texte
            document.getElementById('Label' + ProfileSelected).innerHTML = NewName; //Inscrit le nom et efface bouton etc
            this.removeEventListener("click", validateren, true); //removes eventlistener pour retirer le bouton valider
            document.getElementById('ModifyName').removeEventListener("click", cancelmodification, true);
            document.getElementById('ModifyName').addEventListener("click", modifyprofile, true); //recrée le bouton modifier original
            if (CreateButtonUsed === false) {
                //Restore Add new profile button only if it hasn't been clicked before
                document.getElementById('CreateNewProfile').addEventListener("click", addnewprofile, true); //recrée le bouton créer profil original
                document.getElementById('CreateNewProfile').classList.remove("OptionsButtonsDisabled");//modifie le CSS pour supprimer CSS OptionsButton
                document.getElementById('CreateNewProfile').classList.add("OptionsButtons");
            }
            //Restore deletebutton
            document.getElementById('DeleteProfile').addEventListener("click", deleteprofile, true);
            document.getElementById('DeleteProfile').classList.remove("OptionsButtonsDisabled");//modifie le CSS pour supprimer CSS OptionsButton
            document.getElementById('DeleteProfile').classList.add("OptionsButtons");
            document.getElementById('ModifyName').innerHTML = Langue.OptionsProfilAC.split("|||")[LangueIndex];
        }
        ///------------------------------------------------------------END OF FUNCTION PART------------------------------------------------------
    }

    //BOUTON DELETE PROFILE
    document.getElementById('DeleteProfile').addEventListener("click", deleteprofile, true);
    function deleteprofile()
    {
        //1 : obtention du profil sélectionné
        var AllProfiles= document.querySelectorAll("input[name='ProfilesChoice'").length; //counts all inputs radio buttons
        var ProfileSelected = document.querySelector('input[name = "ProfilesChoice"]:checked').id.split('Radio')[1]; //cherche le bouton radio coché
        var NumProfileSelected = ProfileSelected.split('Profile')[1];
        //2 : suppression de l'affichage html
        if (AllProfiles > 1) //Avoid to delete last profile
        {
            //alert(document.getElementById('RadioProfile' + NumProfileSelected).id.split('Radio')[1] + 'name:' + MetaLocal.Universe);
            //alert('Profile' + NumProfileSelected + 'name:' + MetaLocal.Universe); //--> Les deux résultats sont identiques
            document.querySelector('input[name = "ProfilesChoice"]:checked').outerHTML = Empty; //retire le bouton radio
            try {
                document.getElementById('LabelRadio' + ProfileSelected).nextSibling.outerHTML = Empty; //retire le br suivant le label, try utile car si on supprimer le dernier profil, il n'y a pas de br à supprimer
            } catch(err) {
                document.getElementById('LabelRadioProfile' + (NumProfileSelected - 1)).nextSibling.outerHTML = Empty; //si c'est le dernier profil qui est supprimé, il faut retirer le br du profil d'avant pour éviter qu'il y ait 2 br quand un nouveau profil est créé
            }
            document.getElementById('LabelRadio' + ProfileSelected).outerHTML = Empty; //retire le label du bouton radio

            //3 : suppression des données stockées
            //alert(ProfileSelected);
            GM_deleteValue('Profile' + NumProfileSelected + ':name' + MetaLocal.Universe);
            GM_deleteValue('ProfileUsed:' + MetaLocal.Universe);
            for (var i = 0; i < NbCheckBox; i++) { //Boucle pour les checkbox //delete checkboxes
                GM_deleteValue(ProfileSelected + ':column' + i + MetaLocal.Universe);
            }
            for (var l = 0; l < NbColors; l++) { //Boucle pour la zone "Couleurs" //delete colors
                GM_deleteValue(ProfileSelected + ':color' + l + MetaLocal.Universe);
            }
            for (var n = 0; n < NbTexts; n++) { //Boucle pour les datas de type "texte" //delete text values
                GM_deleteValue(ProfileSelected + ':text' + n + MetaLocal.Universe);
            }
            for (var p = 0; p < NbDropDown; p++) { //Boucle pour les dropdown //delete dropdown
                GM_deleteValue(ProfileSelected + ':DropDown' + p + MetaLocal.Universe);
            }
            for (var q = 0; q < NbRadio; q++) { //Boucle pour les radio //delete radio buttons
                GM_deleteValue(ProfileSelected + ':radio' + q + MetaLocal.Universe);
            }

            //4 : cochage du premier profil de la liste et sauvegarde en tant que profil utilisé
            document.querySelectorAll("input[name='ProfilesChoice'")[0].checked = true;
            GetOptions(1);
            GM_setValue('ProfileUsed:' + MetaLocal.Universe, document.querySelector('input[name = "ProfilesChoice"]:checked').id.split('Radio')[1]);

        }
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//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 NewMsgBoard()
{
    var StartExec = new Date().getTime();
    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();
    //Récupérer tous les RE, split l'ensemble, convertir chaque RE, effectuer tous les calculs
    var BaseModified = false;

    var REBaseStr = NewGetStoredRE();
    var REBase = REBaseStr.split(":-|-:");
    var REBaseDone = new Array();
    var PlayerClass = document.getElementsByClassName('sprite characterclass')[0].classList[3];
    //Gestion durée de vie des REs
    var CommanderActive = DetectCommander();
    var DureeVieRE = 86400;
    if (CommanderActive === true) {
        DureeVieRE = 345600;
    }

    for (var i = 0; i < (REBase.length - 1); i++) { // La base se finit par un délimitateur, sans le -1, le script traite un message vide à la fin
        var MessageToDo = ConvertStringToObj(REBase[i]);
        //console.log(MessageToDo);
        MessageToDo = ComputeMessage(MessageToDo, PlayerClass);

        if (MessageToDo.AgeSec < DureeVieRE) {
            if (MessageToDo.LineColor == '<font color="red">') {
                MessageToDo.LineColor = 'title="' + Langue.VagueSec.split("|||")[LangueIndex] + '"><font color="red">';
            }
            REBaseDone.push(MessageToDo);
        } else { //If a SR older than 24 hours is found, it must be deleted from the base here
            REBaseStr = RmSpecificSR(MessageToDo.Id);
            BaseModified = true;
        }
    }
    if (BaseModified === true) { //If some SR older than 24 hours are found, the base has been modified and must be recorded again
        GM_setValue('BaseRE-' + MetaLocal.Universe, REBaseStr);
        console.log("[O-Table] : Some SR older than 24 hours has been found and removed from the base");
    }

    function RmSpecificSR(IdToDelete) { // Cette fonction permet de supprimer un RE de la base
        var BaseSplit = REBaseStr.split(":-|-:");
        for (var i = 0; i < (BaseSplit.length - 1); i++) { // La dernière entrée de la base est vide, il faut donc réduire de 1 le nombre
            var IdToCheck = BaseSplit[i].split(":--:")[0];
            if (IdToCheck == IdToDelete) {
                console.log("[O-Table] : This message will be deleted from the table : " + BaseSplit[i]);
                BaseSplit.splice(i, 1);
                var BaseReconstruite = BaseSplit.join(':-|-:')
                return BaseReconstruite;
            }
        }

    }

    var EndExec = new Date().getTime();
    var TimeExec = EndExec - StartExec;
    console.log('[O-Table] : Getting stored spy reports took' + TimeExec + ' ms for ' + i + 'items (New Method)');
    return REBaseDone;
}



function NewCollectAndStoreRE(){
    console.log("[O-Table] : Script is starting to get messages {CollectAndStoreRE}");
    var StartExec = new Date().getTime();
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    // 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, j, k, l;
    var IdToSave = 0;
    var Meta = MetaDatas();
    var Message = {};
    var VagueSecondaireYesorNo = GetData(ProfileUsed, 'column19', true) //Choix utilisateur vagues secondaires
    var MontantRentaVagueSecondaire = GetData(ProfileUsed, 'text17', 400000) //Choix utilisateur montant minimum vague secondaire
    //Récupération du *taux de commerce* défini par l'utilisateur
    var TxX = GetData(ProfileUsed, 'text8', 3) // Métal
    var TxY = GetData(ProfileUsed, 'text9', 2) // Cristal
    var TxZ = GetData(ProfileUsed, 'text10', 1) // Deut
    var SecondeVague_StdMSU = 'TotalRessClassique'; //Choix ressources standard par défaut pour le montant minimum des vagues secondaires
    if (GetData(ProfileUsed, 'radio18', true) === true) { //Standard resources
    } else {
        if (GetData(ProfileUsed, 'radio19', false) === true) { //MSU resources
            SecondeVague_StdMSU = 'TotalRessUSM';
        }
    }
    var BaseIna = BaseIna_Get();
    //console.log('BaseIna' + BaseIna);

    GM_addStyle("#CollecterMessages { color: #FFAA00;}");
    MessageIndex = GM_getValue('MessageIndex' + Meta.Universe, MessageIndex); //get amount of SR already stored in the script

    var BaseRE = NewGetStoredRE(); //Get current spy report database



    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);
            var IdPosition = BaseRE.indexOf(Message.Id + "0"); //Position du RE dans la base de RE
            if (IdPosition === -1) { //Si la valeur est supérieure à -1, le RE est déjà présent
                Message.Id = Message.Id + "0";
                //checks whole spy database of the script. Finds the first place to save a spy report
                RecordBase(Message);
                if (Message.PlayerColor === 0 || Message.PlayerColor === 1) {
                    BaseIna = BaseIna_Add(Message.CoordPlanete, BaseIna);
                } else {
                    BaseIna = BaseIna_Del(Message.CoordPlanete, BaseIna);
                }
                //console.log("[O-Table : value of MessageId : " + Message.Id);
                MessageIndex = MessageIndex + 1;
                //IdMessages = (IdMessages + ":--:" + Message.Id);
                //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...
                    VagueSecondaire.Id = VagueSecondaire.Id.slice(0, -1);
                    for (j = 0; j < 5; j++) {
                        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);
                        if ( VagueSecondaire[SecondeVague_StdMSU] > (MontantRentaVagueSecondaire)) {
                            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 = Message.Id + String(j + 1);
                                //console.log("[O-Table : value of VagueSecId : " + VagueSecondaire.Id);


                                RecordBase(VagueSecondaire);
                                MessageIndex = MessageIndex + 1;
                            } else {
                                j = 10;
                            }
                        } else {
                            j = 10;
                        }
                    }
                }
            } else {
             console.log("[O-Table] : SR with ID" + Message.Id + " has been already collected in the past.");
            }
        } else {
            console.log("[O-Table] : No message collected");
        }
        MessageToCollect = MessageToCollect + 1;
        Message = null;

        function RecordBase(Data) { //Data = Message ou VagueSecondaire
            var StringMessage = ConvertObjToString(Data);
            BaseRE = BaseRE + StringMessage + ':-|-:' ;
        }
    }

    BaseIna_Set(BaseIna)
    //console.log(BaseRE);
    GM_setValue('BaseRE-' + Meta.Universe, BaseRE);

    var EndExec = new Date().getTime();
    var TimeExec = EndExec - StartExec;
    console.log('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEW METHOD 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)

    GM_addStyle("#CollecterMessages { color: #" + GetData(ProfileUsed, 'color13', '00FF00') + ";}");

    setTimeout(function() { GM_addStyle("#CollecterMessages { color: inherit;}");}, 450);
}


//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 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.Id = AllMessages[MessageNumber].getAttribute('data-msg-id');
        Message.Metal = parseInt(ConvertRENumbers(Message[0].textContent.split(":")[1])); //Appel de la fonction de transformation des nombres
        Message.Cristal = parseInt(ConvertRENumbers(Message[1].textContent.split(":")[1]));
        Message.Deuterium = parseInt(ConvertRENumbers(Message[2].textContent.split(":")[1]));
        // 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.
        //Butin Possible, Activité, Nom du joueur, Flotte/Def
        Message.CTN = AllMessages[MessageNumber].querySelectorAll("span.ctn.ctn4");
        Message.Butin = Message.CTN[6].textContent;
        //Transformation de la flotte, try permet d'analyser si la flotte est visible ou non
        try {
            Message.Flotte = Message.CTN[7].textContent.split(":")[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 {
            Message.Defense = Message.CTN[8].textContent.split(":")[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, "") / 100;
        //Transformation de l'activité

        try { //Les RE sur planètes détruites n'ont pas de champ activité et cela génère des erreurs
            Message.Activite = Message.CTN[1].textContent.split(":")[1].split(" ")[1];
        } catch(err) {
            Message.Activite = ">60";
        }

        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;
                /*Création de la liste d'inactifs :
                Elle sera composée de longs textes contenant les coordonnées des inactifs.
                Il y en aura une par centaine de SS (pour de meilleures performances)
                Pour trouver une coordonnées, il faudra pas utiliser un split (une sorte de find est à créer)
                Il faudra une fonction pour retirer les coordonnées de cette liste si le joueur a changé de statut
                */
                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.SondeAttacked = 0;
        Message.EclaireurAttacked = 0;
        Message.Atk = 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,PlayerClass) {
    //alert(PlayerClass);
    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
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    //Récupération du choix qu'a mis l'utilisateur dans "envoyer plus de flotte que nécessaire"
    var ShipMore = GetData(ProfileUsed, 'DropDown0', 20) //DisplayLeftLine
    var ShipMorePerHour = GetData(ProfileUsed, 'column54', false)
    //Récupération des techs de l'utilisateur
    var Combu = GetData(ProfileUsed, 'text14', 0) // Réacteur à combu
    var Impu = GetData(ProfileUsed, 'text15', 0) // Réacteur à impu
    var Prop = GetData(ProfileUsed, 'text16', 0) // Réacteur à Prop
    var Weapons = GetData(ProfileUsed, 'text22', 0) // Armes
    var Shield = GetData(ProfileUsed, 'text23', 0) // Bouclier
    var Armour = GetData(ProfileUsed, 'text24', 0) // Protection
    var Hyperespace = GetData(ProfileUsed, 'text36', 0) // Technologie hyperespace
    //Récupération du *taux de commerce* défini par l'utilisateur
    var TxX = GetData(ProfileUsed, 'text8', 3) // Métal
    var TxY = GetData(ProfileUsed, 'text9', 2) // Cristal
    var TxZ = GetData(ProfileUsed, 'text10', 1) // Deut

    var NbSS = parseInt(GetData(ProfileUsed, 'text25', 499)) ////Get user defined amount of solar systems per galaxies
    var NbG = parseInt(GetData(ProfileUsed, 'text26', 9)) //Get user defined amount of galaxies in the universe

    /////////////////////////////////////////////////////This part is to colorize values in spy reports line when a value reaches a defined critieria
    var LootColor = GetData(ProfileUsed, 'color5', '00FF00') //Color for profits standard (Loot)
    var MinProfitsToColorize = GetData(ProfileUsed, 'text0', 1000000) //Minimum amount of profits in Loot to colorize in #color5#
    var LootUSMColor = GetData(ProfileUsed, 'color10', '00FF00') //Color for profits USM (LootUSM)
    var MinProfitsUSMToColorize = GetData(ProfileUsed, 'text19', 1000000) //Minimum amount of profits in Loot to colorize in #color10#
    var AgeColor = GetData(ProfileUsed, 'color8', 'FF0000') //Minimum age to colorize (COLOR)
    var MinAgeToColorize = GetData(ProfileUsed, 'text3', 2) //Minimum age to colorize
    var MinFleetToColorize = GetData(ProfileUsed, 'text1', 1000000) //Minimum fleet to colorize (Fleet)
    var MinDefToColorize = GetData(ProfileUsed, 'text2', 1000000) //Minimum def to colorize (Def)
    var TripTimeMinutes = GetData(ProfileUsed, 'text40', 999) //Minimum trip time to colorize
    var TripTimeColor = GetData(ProfileUsed, 'color24', 'FF0000') //Color for trip time

    //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 (GetData(ProfileUsed, 'radio16', false) === true) { //Standard resources
    } else {
        if (GetData(ProfileUsed, 'radio17', true) === true) { //MSU resources
            MIP_Profits_StdMSU = 1; //1 = MSU resources
        }
    }

    var MinProfitsHourToColorize = GetData(ProfileUsed, 'text27', 1000000) //Minimum profits/hour to colorize (Profits/Hour)
    var ProfitsHourColor = GetData(ProfileUsed, 'color11', '00FF00') //profits/hour to colorize (COLOR)

    //Used to know if user wants to use "display players that are profitables after sending missiles" feature
    var ComputeMIPProfits = GetData(ProfileUsed, 'column32', false) //DisplayMissiles

    //To know if user wants shorter age or complete age
    var SmallerAge = GetData(ProfileUsed, 'column34', false)


    //Used to know what is the minimum amount of distance in GALAXIES used to colorize coordinates
    var MinGtoColorize = GetData(ProfileUsed, 'text34', 1)

    //Used to know what is the minimum amount of distance in SOLAR SYSTEMS used to colorize coordinates
    var MinSStoColorize = GetData(ProfileUsed, 'text35', 50)

    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 (GetData(ProfileUsed, 'radio0', true) === true) {
        TravelTimeType = 1;
    } else {
        if (GetData(ProfileUsed, 'radio1', false) === true) {
            TravelTimeType = 2;
        }
    }
    //Récupération du % cdr flotte et def //Get Debris freet + defense field ratio
    var TxCDRFleet = GetData(ProfileUsed, 'text20', 30);
    var TxCDRDef = GetData(ProfileUsed, 'text21', 0);

    var ClassCargo = 1;
    var ClassSpeed = 0;
    switch (PlayerClass)
    {
        case 'miner':
            ClassCargo = 1.25;
            ClassSpeed = 1;
            //alert('Entrée au switch');
            break;
        default:
    }

    //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.AgeSecCalc = Message.AgeSec * -1; //Used to reverse sorting (ascending age instead of descending)
    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
    }


    //Gestion des ressources
    //alert(Message.DefenseFinal);
    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 * (TxCDRFleet / 100));
    Message.CDRFlotteDisplayed = ThousandSeparator(Message.CDRFlotte);
    Message.CDRFlotteRC = parseInt(Message.CDRFlotte / (20000 + (1000 * Hyperespace)));
    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 * (TxCDRDef / 100));
    Message.CDRDefRC = parseInt(Message.CDRDefense / (20000 + (1000 * Hyperespace)));
    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) + 1); //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));
    Message.RawCoordCalc = Message.RawCoord * -1; //Used to reverse sorting for coords (ascending instead of descending)



    //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 et sondes



    var FretSonde = parseInt(GetData(ProfileUsed, 'text37', 5));
    FretSonde = Math.round(FretSonde + ((FretSonde / 20) * Hyperespace));
    if (ShipMorePerHour === true) {
        var AgeHeure = Message.AgeSec / 3600 + 1;
        console.log(AgeHeure);
        ShipMore = ShipMore * AgeHeure;
    }

    Message.NbPT = parseInt((Message.Loot / ((5000  * ClassCargo) + (250 * Hyperespace)) * (1 + ShipMore / 100) + 1));
    Message.NbPTDisplayed = ThousandSeparator(Message.NbPT);
    Message.NbGT = parseInt((Message.Loot / ((25000 * ClassCargo) + (1250 * Hyperespace)) * (1 + ShipMore / 100) + 1));
    Message.NbGTDisplayed = ThousandSeparator(Message.NbGT);
    Message.NbSonde = parseInt(Message.Loot / FretSonde * (1 + ShipMore / 100) + 1);
    Message.NbSondeDisplayed = ThousandSeparator(Message.NbSonde);
    Message.NbEclaireur = parseInt((Message.Loot / (10000 + (500 * Hyperespace)) * (1 + ShipMore / 100) + 1));
    Message.NbEclaireurDisplayed = ThousandSeparator(Message.NbEclaireur);

    var base64Res = btoa('{"0":[{"research":{"109":{"level":' + Weapons + '},"110":{"level":' + Shield + '},"111":{"level":' + Armour + '},"114":{"level":' + Hyperespace + '},"115":{"level":' + Combu + '},"117":{"level":' + Impu + '},"118":{"level":' + Prop + '}}} ]}');

    //Création des liens PT et GT et galaxie
    Message.LienAtk = ('https://' + Meta.Universe + '/game/index.php?page=ingame&component=fleetdispatch&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=' + Message.Moon + '&routine=3&mission=1');
    Message.LienPT = ('https://' + Meta.Universe + '/game/index.php?page=ingame&component=fleetdispatch&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=' + Message.Moon + '&routine=3&mission=1&am202=' + Message.NbPT);
    Message.LienGT = ('https://' + Meta.Universe + '/game/index.php?page=ingame&component=fleetdispatch&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=' + Message.Moon + '&routine=3&mission=1&am203=' + Message.NbGT);
    Message.LienSonde = ('https://' + Meta.Universe + '/game/index.php?page=ingame&component=fleetdispatch&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=' + Message.Moon + '&mission=1&am210=' + Message.NbSonde);
    Message.LienEclaireur = ('https://' + Meta.Universe + '/game/index.php?page=ingame&component=fleetdispatch&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=' + Message.Moon + '&mission=1&am219=' + Message.NbEclaireur);
    Message.LienRC = ('https://' + Meta.Universe + '/game/index.php?page=ingame&component=fleetdispatch&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos + '&type=2&routine=3&mission=8&am209=' + Message.TotalRC);
    Message.LienGalaxie = ('https://' + Meta.Universe + '/game/index.php?page=ingame&component=galaxy&galaxy=' + Message.CoordGalaxie + '&system=' + Message.CoordSS + '&position=' + Message.CoordPos);
    Message.IdIg = Message.Id.slice(0, -1);
    Message.LienDetails = ('https://' + Meta.Universe + '/game/index.php?page=messages&messageId=' + Message.IdIg + '&tabid=20&ajax=1');
    Message.Simulation = ('https://trashsim.universeview.be/en?SR_KEY=' + Message.API + '&utm_campaign=simulate#prefill=' + base64Res);


    //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)) + (10000 * ClassSpeed);
    } else {
        var PTSpeed = (5000 * (1 + Combu / 10)) + (5000 * ClassSpeed);
    }

    //Gestion vitesse GT
    var GTSpeed = (7500 * (1 + Combu / 10)) + (7500 * ClassSpeed);

    //Gestion vitesse Sonde
    var SondeSpeed = 100000000 * (1 + Combu / 10);

    //Gestion vitesse Eclaireur
    var EclaireurSpeed = 12000 * (1 + 3 * Prop / 10);
    Message.TempsTrajetPT = 0;

    //alert(ClassSpeed);
    //alert ('Vitesse PT' + PTSpeed + ' Vitesse GT' + GTSpeed);


    //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

    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 (Message.Gtraversees >= MinGtoColorize) {
            Message.CoordPlanete_Colored = 'Table_GCoords_Colored'; //specific class to colorize coordinates in user specified color (depends of color22/text34 in options)
        }
        //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;
        Message.TempsTrajetSonde = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / SondeSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
        Message.TempsTrajetSonde_A = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / SondeSpeed)))) / FleetSpeed);
        Message.TempsTrajetSonde_AR = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / SondeSpeed)))) / FleetSpeed) * 2;
        Message.TempsTrajetEclaireur = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / EclaireurSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
        Message.TempsTrajetEclaireur_A = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / EclaireurSpeed)))) / FleetSpeed);
        Message.TempsTrajetEclaireur_AR = Math.round(Math.round((10 + (35000 / 100 * Math.sqrt((Message.Gtraversees * 20000) * 1000 / EclaireurSpeed)))) / 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;
                        }
                    }
                }
            }
            if (Message.SStraverses >= MinSStoColorize) {
                Message.CoordPlanete_Colored = 'Table_SSCoords_Colored'; //specific class to colorize coordinates in user specified color (depends of color23/text35 in options)
            }
            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;
            Message.TempsTrajetSonde = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(SondeSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
            Message.TempsTrajetSonde_A = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(SondeSpeed)))) / FleetSpeed);
            Message.TempsTrajetSonde_AR = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(SondeSpeed)))) / FleetSpeed) * 2;
            Message.TempsTrajetEclaireur = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(EclaireurSpeed)))) / FleetSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
            Message.TempsTrajetEclaireur_A = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(EclaireurSpeed)))) / FleetSpeed);
            Message.TempsTrajetEclaireur_AR = Math.round(Math.round(10 + (35000 / 100 * Math.sqrt((2700 + 95 * Number(Message.SStraverses)) * 1000 / Number(EclaireurSpeed)))) / 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;
                Message.TempsTrajetSonde = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / SondeSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
                Message.TempsTrajetSonde_A = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / SondeSpeed);
                Message.TempsTrajetSonde_AR = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / SondeSpeed) * 2;
                Message.TempsTrajetEclaireur = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / EclaireurSpeed) * TravelTimeType; //Travel time for small cargo //TravelTimeType is configured by user : you can select a travel or a travel+back time
                Message.TempsTrajetEclaireur_A = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / EclaireurSpeed);
                Message.TempsTrajetEclaireur_AR = Math.round(Math.round(10 + ((35000 / 100) * Math.sqrt((1000000 + Message.Postraversees * 5000) / PTSpeed))) / EclaireurSpeed) * 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);
    Message.TempsTrajetSonde_ADisplayed = secondsToHms(Message.TempsTrajetSonde_A);
    Message.TempsTrajetSonde_ARDisplayed = secondsToHms(Message.TempsTrajetSonde_AR);
    Message.TempsTrajetEclaireur_ADisplayed = secondsToHms(Message.TempsTrajetEclaireur_A);
    Message.TempsTrajetEclaireur_ARDisplayed = secondsToHms(Message.TempsTrajetEclaireur_AR);

    //checks if the user has selected small or large cargo or probes
    if (GetData(ProfileUsed, 'radio2', true) === true) { //small cargo selected
        //Title = Html title for the column where is displayed item
        Message.TempsTrajetDisplayed = secondsToHms(Message.TempsTrajetPT);
        Message.TempsTrajetSec = Message.TempsTrajetPT;
    } else if (GetData(ProfileUsed, 'radio24', false) === true) {//probes selected
        Message.TempsTrajetDisplayed = secondsToHms(Message.TempsTrajetSonde);
        Message.TempsTrajetSec = Message.TempsTrajetSonde;
    } else if (GetData(ProfileUsed, 'radio30', false) === true) {//Pathfinder selected
        Message.TempsTrajetDisplayed = secondsToHms(Message.TempsTrajetEclaireur);
        Message.TempsTrajetSec = Message.TempsTrajetEclaireur;
    } else {
        Message.TempsTrajetDisplayed = secondsToHms(Message.TempsTrajetGT);
        Message.TempsTrajetSec = Message.TempsTrajetGT;
    }
    Message.TempsTrajetSecCalc = Message.TempsTrajetSec * -1; //*-1 used to reverse sorting

    //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.HeureArriveeSondeRaw = Message.TempsTrajetSonde_A + Meta.Timestamp;
    Message.HeureArriveeEclaireurRaw = Message.TempsTrajetEclaireur_A + Meta.Timestamp;
    Message.HeureArriveeGTDisplayed = timeConverter(Message.HeureArriveeGTRaw); //Used in infoboxes
    Message.HeureArriveePTDisplayed = timeConverter(Message.HeureArriveePTRaw); //Used in infoboxes
    Message.HeureArriveeSondeDisplayed = timeConverter(Message.HeureArriveeSondeRaw); //Used in infoboxes
    Message.HeureArriveeEclaireurDisplayed = timeConverter(Message.HeureArriveeEclaireurRaw); //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 (GetData(ProfileUsed, 'radio4', true) === true) { //small cargo selected
        Message.HeureArriveeDisplayed = timeConverter(Message.HeureArriveePTRaw);
        //Title = Html title for the column where is displayed item
    } else if (GetData(ProfileUsed, 'radio25', false) === true) { //probes selected
        Message.HeureArriveeDisplayed = timeConverter(Message.HeureArriveeSondeRaw);
    } else if (GetData(ProfileUsed, 'radio31', false) === true) { //PathFinder selected
        Message.HeureArriveeDisplayed = timeConverter(Message.HeureArriveeEclaireurRaw);
    } else {
        Message.HeureArriveeDisplayed = timeConverter(Message.HeureArriveeGTRaw);
    }

    Message.HeureArriveeDisplayedClock = Message.HeureArriveeDisplayed.split(" ")[1];


    //Comput the clocks when your ships comes back
    Message.HeureRetourGTRaw = Message.TempsTrajetGT_AR + Meta.Timestamp;
    Message.HeureRetourPTRaw = Message.TempsTrajetPT_AR + Meta.Timestamp;
    Message.HeureRetourSondeRaw = Message.TempsTrajetSonde_AR + Meta.Timestamp;
    Message.HeureRetourEclaireurRaw = Message.TempsTrajetEclaireur_AR + Meta.Timestamp;
    Message.HeureRetourGTDisplayed = timeConverter(Message.HeureRetourGTRaw); //Used in infoboxes
    Message.HeureRetourPTDisplayed = timeConverter(Message.HeureRetourPTRaw); //Used in infoboxes
    Message.HeureRetourSondeDisplayed = timeConverter(Message.HeureRetourSondeRaw); //Used in infoboxes
    Message.HeureRetourEclaireurDisplayed = timeConverter(Message.HeureRetourEclaireurRaw); //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 (GetData(ProfileUsed, 'radio6', true) === true) { //small cargo selected
        Message.HeureRetourDisplayed = timeConverter(Message.HeureRetourPTRaw);
        //Title = Html title for the column where is displayed item
    } else if (GetData(ProfileUsed, 'radio26', false) === true) { //probe selected
        Message.HeureRetourDisplayed = timeConverter(Message.HeureRetourSondeRaw);
    } else if (GetData(ProfileUsed, 'radio32', false) === true) { //Eclaireur selected
        Message.HeureRetourDisplayed = timeConverter(Message.HeureRetourEclaireurRaw);
    } else {
        Message.HeureRetourDisplayed = timeConverter(Message.HeureRetourGTRaw);
    }
    Message.HeureRetourDisplayedClock = Message.HeureRetourDisplayed.split(" ")[1];



    //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.ProfitsPerHour_Sonde = parseInt(Message.Loot / (Message.TempsTrajetSonde_AR / 3600));
    Message.ProfitsPerHour_Eclaireur = parseInt(Message.Loot / (Message.TempsTrajetEclaireur_AR / 3600));
    Message.ProfitsPerHourUSM = parseInt(Message.USMPille / (Message.TempsTrajetPT_AR / 3600));
    Message.ProfitsPerHourUSM_GT = parseInt(Message.USMPille / (Message.TempsTrajetGT_AR / 3600));
    Message.ProfitsPerHourUSM_Sonde = parseInt(Message.USMPille / (Message.TempsTrajetSonde_AR / 3600));
    Message.ProfitsPerHourUSM_Eclaireur = parseInt(Message.USMPille / (Message.TempsTrajetEclaireur_AR / 3600));
    //Per resource :
    Message.MetalPerHour = parseInt(Message.MetalPille / (Message.TempsTrajetPT_AR / 3600));
    Message.MetalPerHour_GT = parseInt(Message.MetalPille / (Message.TempsTrajetGT_AR / 3600));
    Message.MetalPerHour_Sonde = parseInt(Message.MetalPille / (Message.TempsTrajetSonde_AR / 3600));
    Message.MetalPerHour_Eclaireur = parseInt(Message.MetalPille / (Message.TempsTrajetEclaireur_AR / 3600));
    Message.CristalPerHour = parseInt(Message.CristalPille / (Message.TempsTrajetPT_AR / 3600));
    Message.CristalPerHour_GT = parseInt(Message.CristalPille / (Message.TempsTrajetGT_AR / 3600));
    Message.CristalPerHour_Sonde = parseInt(Message.CristalPille / (Message.TempsTrajetSonde_AR / 3600));
    Message.CristalPerHour_Eclaireur = parseInt(Message.CristalPille / (Message.TempsTrajetEclaireur_AR / 3600));
    Message.DeuteriumPerHour = parseInt(Message.DeuteriumPille / (Message.TempsTrajetPT_AR / 3600));
    Message.DeuteriumPerHour_GT = parseInt(Message.DeuteriumPille / (Message.TempsTrajetGT_AR / 3600));
    Message.DeuteriumPerHour_Sonde = parseInt(Message.DeuteriumPille / (Message.TempsTrajetSonde_AR / 3600));
    Message.DeuteriumPerHour_Eclaireur = parseInt(Message.DeuteriumPille / (Message.TempsTrajetEclaireur_AR / 3600));
    //checks if the user has selected small or large cargo, and after, checks if the user has selected MSU or not
    if (GetData(ProfileUsed, 'radio8', true) === true) { //small cargo selected
        //SMALL CARGO
        if (GetData(ProfileUsed, 'radio10', true) === true) { //standard values
            Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHour);
            Message.ProfitsPerHourUsed = Message.ProfitsPerHour;
        } else {
            if (GetData(ProfileUsed, 'radio11', false) === true) { //msu values
                Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHourUSM);
                Message.ProfitsPerHourUsed = Message.ProfitsPerHourUSM;
            }
        }
        //Metal,Crystal and deut per hour (not depending of std/msu choice)
        Message.MetalPerHourDisplayed = ThousandSeparator(Message.MetalPerHour);
        Message.MetalPerHourUsed = Message.MetalPerHour;
        Message.CristalPerHourDisplayed = ThousandSeparator(Message.CristalPerHour);
        Message.CristalPerHourUsed = Message.CristalPerHour;
        Message.DeutPerHourDisplayed = ThousandSeparator(Message.DeuteriumPerHour);
        Message.DeutPerHourUsed = Message.DeuteriumPerHour;
        //Title = Html title for the column where is displayed item
    } else if (GetData(ProfileUsed, 'radio27', false) === true) { //probe selected
        //PROBE
        if (GetData(ProfileUsed, 'radio10', true) === true) { //standard values
            Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHour_Sonde);
            Message.ProfitsPerHourUsed = Message.ProfitsPerHour_Sonde;
        } else {
            if (GetData(ProfileUsed, 'radio11', false) === true) { //msu values
                Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHourUSM_Sonde);
                Message.ProfitsPerHourUsed = Message.ProfitsPerHourUSM_Sonde;
            }
        }
        //Metal,Crystal and deut per hour (not depending of std/msu choice)
        Message.MetalPerHourDisplayed = ThousandSeparator(Message.MetalPerHour_Sonde);
        Message.MetalPerHourUsed = Message.MetalPerHour_Sonde;
        Message.CristalPerHourDisplayed = ThousandSeparator(Message.CristalPerHour_Sonde);
        Message.CristalPerHourUsed = Message.CristalPerHour_Sonde;
        Message.DeutPerHourDisplayed = ThousandSeparator(Message.DeuteriumPerHour_Sonde);
        Message.DeutPerHourUsed = Message.DeuteriumPerHour_Sonde;

    } else if (GetData(ProfileUsed, 'radio9', false) === true) {
        //LARGE CARGO
        if (GetData(ProfileUsed, 'radio10', true) === true) { //standard values
            Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHour_GT);
            Message.ProfitsPerHourUsed = Message.ProfitsPerHour_GT;
        } else {
            if (GetData(ProfileUsed, 'radio11', false) === true) { //msu values
                Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHourUSM_GT);
                Message.ProfitsPerHourUsed = Message.ProfitsPerHourUSM_GT;
            }
        }
        //Metal,Crystal and deut per hour (not depending of std/msu choice)
        Message.MetalPerHourDisplayed = ThousandSeparator(Message.MetalPerHour_GT);
        Message.MetalPerHourUsed = Message.MetalPerHour_GT;
        Message.CristalPerHourDisplayed = ThousandSeparator(Message.CristalPerHour_GT);
        Message.CristalPerHourUsed = Message.CristalPerHour_GT;
        Message.DeutPerHourDisplayed = ThousandSeparator(Message.DeuteriumPerHour_GT);
        Message.DeutPerHourUsed = Message.DeuteriumPerHour_GT;

    } else if (GetData(ProfileUsed, 'radio33', false) === true) {
        //PATHFINDER
        if (GetData(ProfileUsed, 'radio10', true) === true) { //standard values
            Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHour_GT);
            Message.ProfitsPerHourUsed = Message.ProfitsPerHour_GT;
        } else {
            if (GetData(ProfileUsed, 'radio11', false) === true) { //msu values
                Message.ProfitsPerHourDisplayed = ThousandSeparator(Message.ProfitsPerHourUSM_GT);
                Message.ProfitsPerHourUsed = Message.ProfitsPerHourUSM_GT;
            }
        }
        //Metal,Crystal and deut per hour (not depending of std/msu choice)
        Message.MetalPerHourDisplayed = ThousandSeparator(Message.MetalPerHour_Eclaireur);
        Message.MetalPerHourUsed = Message.MetalPerHour_Eclaireur;
        Message.CristalPerHourDisplayed = ThousandSeparator(Message.CristalPerHour_Eclaireur);
        Message.CristalPerHourUsed = Message.CristalPerHour_Eclaireur;
        Message.DeutPerHourDisplayed = ThousandSeparator(Message.DeuteriumPerHour_Eclaireur);
        Message.DeutPerHourUsed = Message.DeuteriumPerHour_Eclaireur;
    }
    //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>';
    }
    //Part to colorize trip time and arrival time columns
    Message.TempsARMinutes = Message.TempsTrajetSec * 2 / 60;
    if (Message.TempsARMinutes > TripTimeMinutes) {
        Message.HeureArriveeDisplayedClock = '<font color="' + TripTimeColor  + '">' + Message.HeureArriveeDisplayedClock + '</font>';
        Message.HeureRetourDisplayedClock = '<font color="' + TripTimeColor  + '">' + Message.HeureRetourDisplayedClock + '</font>';
        Message.TempsTrajetDisplayed = '<font color="' + TripTimeColor  + '">' + Message.TempsTrajetDisplayed + '</font>';
    } else {
        Message.HeureArriveeDisplayedClock = '<font>' + Message.HeureArriveeDisplayedClock + '</font>';
        Message.HeureRetourDisplayedClock = '<font>' + Message.HeureRetourDisplayedClock + '</font>';
        Message.TempsTrajetDisplayed = '<font>' + Message.TempsTrajetDisplayed + '</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 />' +
                        '(<FONT color=#BB00BB>' + Langue.SondeLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_A.split("|||")[LangueIndex] + ' : <FONT color=#BB00BB>' + Message.TempsTrajetSonde_ADisplayed + '</FONT><br />(<FONT color=#BB00BB>' + Langue.SondeLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_AR.split("|||")[LangueIndex] + ' : <FONT color=#BB00BB>' + Message.TempsTrajetSonde_ARDisplayed + '</FONT><br />(<FONT color=#BB00BB>' + Langue.SondeLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureArrivee.split("|||")[LangueIndex] + ' : <FONT color=#BB00BB>' + Message.HeureArriveeSondeDisplayed.split(" ")[1] + '</FONT><br />(<FONT color=#BB00BB>' + Langue.SondeLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureRetour.split("|||")[LangueIndex] + ' : <FONT color=#BB00BB>' + Message.HeureRetourSondeDisplayed.split(" ")[1] + '</FONT><br />' +
                        '(<FONT color=#55FFCC>' + Langue.EclaireurLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_A.split("|||")[LangueIndex] + ' : <FONT color=#55FFCC>' + Message.TempsTrajetEclaireur_ADisplayed + '</FONT><br />(<FONT color=#55FFCC>' + Langue.EclaireurLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.TempsTrajet_AR.split("|||")[LangueIndex] + ' : <FONT color=#55FFCC>' + Message.TempsTrajetEclaireur_ARDisplayed + '</FONT><br />(<FONT color=#55FFCC>' + Langue.EclaireurLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureArrivee.split("|||")[LangueIndex] + ' : <FONT color=#55FFCC>' + Message.HeureArriveeEclaireurDisplayed.split(" ")[1] + '</FONT><br />(<FONT color=#55FFCC>' + Langue.EclaireurLong.split("|||")[LangueIndex] + '</FONT>) ' + Langue.HeureRetour.split("|||")[LangueIndex] + ' : <FONT color=#55FFCC>' + Message.HeureRetourEclaireurDisplayed.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.API + ":--:" + obj.RCRecycled + ":--:" + obj.VagueSecondaire + ":--:" + obj.SondeAttacked + ":--:" + obj.EclaireurAttacked+ ":--:" + obj.Atk);
    /////////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////////////////////////////////////27/////////////////////////////28//////////////
    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.API =  SplitStrMessage[23];
    Message.RCRecycled = SplitStrMessage[24];
    Message.VagueSecondaire = SplitStrMessage[25];
    Message.SondeAttacked = SplitStrMessage[26];
    Message.EclaireurAttacked = SplitStrMessage[27];
    Message.Atk = SplitStrMessage[28];
    return Message;
}
//mission : enregistrer un SondeAttacked

//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);
}





//New Optimization part



function NewGetStoredRE() {
    var MetaLocal = MetaDatas();
    var BaseRE = GM_getValue('BaseRE-' + MetaLocal.Universe);
    if (BaseRE) {
        return BaseRE;
    }
    else {
        return '';
    }
}

function ModifyRE(Id, ValueToModify, Value) {
    var MetaLocal = MetaDatas();
    var BaseRe = NewGetStoredRE();
    var BaseSplit = BaseRe.split(":-|-:");
    for (var i = 0; i < (BaseSplit.length - 1); i++) { // La dernière entrée de la base est vide, il faut donc réduire de 1 le nombre
        var IdToCheck = BaseSplit[i].split(":--:")[0];
        if (IdToCheck == Id) {
            var MessageObj = {};
            MessageObj = ConvertStringToObj(BaseSplit[i]);
            //console.log(MessageObj[ValueToModify]);
            MessageObj[ValueToModify] = Value;
            var MessageStr = ConvertObjToString(MessageObj);
            BaseSplit.splice(i, 1, MessageStr);
            var BaseReconstruite = BaseSplit.join(':-|-:')
            GM_setValue('BaseRE-' + MetaLocal.Universe, BaseReconstruite)
        }
    }

}

//End Of Opti part

function DetectCommander() {
    var Commander = false;
    if (document.querySelector('.on.commander')) {
        Commander = true;
    }
    return Commander;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////CR AREA ------------------------- ZONE RAPPORTS DE COMBATS////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CSS dédié aux RC

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

//Cadre des boutons
GM_addStyle(".OTableRCInit {width: 100%; text-align:center; margin-top: 15px; margin-bottom: 15px} "); //bord du cadre des boutons

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

//Lignes dans le tableau
GM_addStyle(".CaseRC {text-align: center; border-left: 1px solid #333; height: 21px; }");

//Bouton supprimer
GM_addStyle("#DeleteRC {display: block; width: 15px; height:16px; background-image: url(" + Picture.Delete + "); background-color: #FFFFFF;}");


//Lignes en état de modification
GM_addStyle(".OrangeBorderTop { border-style: solid;  border-width: 2px; border-color: orange; border-bottom-style:none;}");
GM_addStyle(".OrangeBorderBottom { border-style: solid;  border-width: 2px; border-color: orange; border-top-style: none; line-height:25px ;background-color: #111112;}");

//Lignes en erreur
GM_addStyle(".RedBorder { border-style: solid;  border-width: 2px; border-color: red;}");

//Logo crayon
GM_addStyle("#ModifyRC {display: block; width: 16px; height:16px; background-image: url(" + Picture.Crayon + "); background-color: #ffffff;}");

//Bouton sauvegarder modifications
GM_addStyle(".SaveModif {border: 1px dashed #444; padding: 5px 3px 5px 2px ; text-align: center;");
GM_addStyle(".SaveModif:hover {border: 1px solid #666; text-align: center;");
GM_addStyle(".SaveModifTable {border-spacing: 5px; width: 100%;");

//Couleurs de textes
GM_addStyle(".RedText {color: #FF0000;");
GM_addStyle(".OrangeText {color: #FFA500;");
GM_addStyle(".GreenText {color: #00ff00;");


//////////////
//Fonction de création et d'affichage des boutons du tableau
/////////////
function RCButton()
{

    var IDsToDisplay = Determine_UiId(Detect_Market());
    RemoveInfobulles();
    //HTML PART
    var LangueIndex = GetLangue();
    var MetaLocal = MetaDatas();
    var ActivateManageCRMain_Val = GetData('General', 'RCManageFullRecapTable', "Enabled");
    var ActivateManageCRMain_Col = 'OrangeLink';
    if (ActivateManageCRMain_Val === 'Enabled') {
        ActivateManageCRMain_Col = 'GreenLink';
    }
    var ActivateManageCRList_Val = GetData('General', 'RCManageRCList', "Enabled");
    var ActivateManageCRList_Col = 'OrangeLink';
    if (ActivateManageCRList_Val === 'Enabled') {
        ActivateManageCRList_Col = 'GreenLink';
    }
    var ActivateManageCRCoord_Val = GetData('General', 'RCManageCoord', "Disabled");
    var ActivateManageCRCoord_Col = 'OrangeLink';
    if (ActivateManageCRCoord_Val === 'Enabled') {
        ActivateManageCRCoord_Col = 'GreenLink';
    }
    var ActivateManageCRDaily_Val = GetData('General', 'RCManageDaily', "Enabled");
    var ActivateManageCRDaily_Col = 'OrangeLink';
    if (ActivateManageCRDaily_Val === 'Enabled') {
        ActivateManageCRDaily_Col = 'GreenLink';
    }
    var ActivateManageCRWeekly_Val = GetData('General', 'RCManageWeekly', "Disabled");
    var ActivateManageCRWeekly_Col = 'OrangeLink';
    if (ActivateManageCRWeekly_Val === 'Enabled') {
        ActivateManageCRWeekly_Col = 'GreenLink';
    }

    var TableauBoutons =      '<ul class ="RCLigneButtons">' +
        '<li class ="CaseTableButton tooltipTop tooltipClose" id="RCDisplayTable" title="<a id=RCManageFullRecapTable class=' + ActivateManageCRMain_Col + ' value=' + ActivateManageCRMain_Val + '>' + Langue.RCBG.split("|||")[LangueIndexGlb] + '</a><br/><a id=RCManageRCList class=' + ActivateManageCRList_Col + ' value=' + ActivateManageCRList_Val + '>' + Langue.RCBH.split("|||")[LangueIndexGlb] + '</a><br/><a id=RCManageCoord class=' + ActivateManageCRCoord_Col + ' value=' + ActivateManageCRCoord_Val + '>' + Langue.RCBI.split("|||")[LangueIndexGlb] + '</a><br/><a id=RCManageDaily class=' + ActivateManageCRDaily_Col + ' value=' + ActivateManageCRDaily_Val + '>' + Langue.RCBJ.split("|||")[LangueIndexGlb] + '</a><br/><a id=RCManageWeekly class=' + ActivateManageCRWeekly_Col + ' value=' + ActivateManageCRWeekly_Val + '>' + Langue.RCBK.split("|||")[LangueIndexGlb] + '</a>">&#8239{&#8239' + Langue.BoutonAfficherDonnées.split("|||")[LangueIndex] + '&#8239}</td>' + //
        '<li class ="CaseTableButton" id="RCCollectDatas" title="' + Langue.BoutonCollecterMessagesTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonCollecterMessages.split("|||")[LangueIndex] + '&#8239}</td>' +
                                   '<li class ="CaseTableButton" id="RCHideDatas" title="' + Langue.BoutonMasquerTableauTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonMasquerTableau.split("|||")[LangueIndex] + '&#8239}</td>' +
                                   '<li class ="CaseTableButton" id="RCOptions" title="' + Langue.BoutonOptionsTITLE.split("|||")[LangueIndex] + '">&#8239{&#8239' + Langue.BoutonOptions.split("|||")[LangueIndex] + '&#8239}</td>' +
                                   //'<li class ="CaseTableButton" id="TESTING">&#8239{&#8239 Debug &#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>';

    var DisplayButton = document.createElement("div"); //Création d'un élément div
    DisplayButton.classList.add('OTableRCInit');
    DisplayButton.innerHTML = TableauBoutons;

    document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").insertBefore(DisplayButton, document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").firstChild); //Affichage des boutons


    if (document.querySelector(".no_msg")) {
        document.querySelector(".no_msg").style.display='none';
    }


    //Assignation de fonctions au boutons
    //COLLECT BUTTON
    document.getElementById('RCCollectDatas').addEventListener("click", CollectAllRC, true);
    document.getElementById('RCDisplayTable').addEventListener("click", RCHTMLTable, true);
    document.getElementById('RCHideDatas').addEventListener("click", HideRCTable, true);
    document.getElementById('RCOptions').addEventListener("click", OptionsRC, true);
    //document.getElementById('TESTING').addEventListener("click", , true);

    var AlreadyDone = 0; //This variable avoids to add more  than once eventlisteners in the tooltip
    var OldLength = 0; //This variable checks if there is a new tooltip made (when user change of page)
    document.querySelector('#RCDisplayTable').addEventListener("mouseover", function(event)
                                                               {
        console.log("[O-Table] : Display button asked");

        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
            GM_addStyle(".GreenLink:hover, .OrangeLink:hover{ color : #FFFFFF !important;}");
            GM_addStyle(".GreenLink { color : #33BB33 !important;} "); //bord du tableau
            GM_addStyle(".OrangeLink { color : #FF8800 !important;} "); //bord du tableau
            var ActivateManageCRMain = document.querySelectorAll("#RCManageFullRecapTable");
            var ActivateManageCRList = document.querySelectorAll("#RCManageRCList");
            var ActivateManageCRCoord = document.querySelectorAll("#RCManageCoord");
            var ActivateManageCRDaily = document.querySelectorAll("#RCManageDaily");
            var ActivateManageCRWeekly = document.querySelectorAll("#RCManageWeekly");
            try {
                for (var i = 0; i < ActivateManageCRMain.length; i++) {
                    //The script need to check 2 things :
                    //1- At first, the script will not do another pass if an eventlistener has already been put (thanks to AlreadyDone variable)
                    //2- The script adds an eventlistener if the page changes (because the tooltip shown is a new tooltip).
                    //3 - Note : if user come back to a previous page, it's a new tooltip again.
                    if (AlreadyDone === 0 || OldLength !== ActivateManageCRMain.length) { //first check : avoids to put 2 eventlistener on one tooltip, second check is to put an eventlistener if user switched page
                        //Need to remove old events listener (when user displayed more than once the tooltip)
                        ActivateManageCRMain[i].addEventListener("click", ManageRCTables);
                        AlreadyDone = 1;
                    }
                }
                for (var i = 0; i < ActivateManageCRList.length; i++) {
                    if (AlreadyDone === 0 || OldLength !== ActivateManageCRMain.length) {
                        ActivateManageCRList[i].addEventListener("click", ManageRCTables);
                        AlreadyDone = 1;
                    }
                }
                for (var i = 0; i < ActivateManageCRCoord.length; i++) {
                    if (AlreadyDone === 0 || OldLength !== ActivateManageCRMain.length) {
                        ActivateManageCRCoord[i].addEventListener("click", ManageRCTables);
                        AlreadyDone = 1;
                    }
                }
                for (var i = 0; i < ActivateManageCRDaily.length; i++) {
                    if (AlreadyDone === 0 || OldLength !== ActivateManageCRMain.length) {
                        ActivateManageCRDaily[i].addEventListener("click", ManageRCTables);
                        AlreadyDone = 1;
                    }
                }
                for (var i = 0; i < ActivateManageCRWeekly.length; i++) {
                    if (AlreadyDone === 0 || OldLength !== ActivateManageCRMain.length) {
                        ActivateManageCRWeekly[i].addEventListener("click", ManageRCTables);
                        AlreadyDone = 1;
                    }
                }
                OldLength = ActivateManageCRMain.length; //Only changed once, not for every iterations of for
            } catch(err) {
            }
        }, 300); // end of settimeout*/
        function ManageRCTables() {
            if (this.getAttribute("value") === "Enabled") {
                this.setAttribute("value", "Disabled");
                this.classList.remove("GreenLink");
                this.classList.add("OrangeLink");

            } else if (this.getAttribute("value") === "Disabled") {
                this.setAttribute("value", "Enabled");
                this.classList.remove("OrangeLink");
                this.classList.add("GreenLink");

            }
            //alert(this.getAttribute("value"));
            console.log('[O-Table] : New value set to : ' + this.getAttribute("value"));
            GM_setValue('General:' + this.id +  MetaLocal.Universe, this.getAttribute("value"));
            RCHTMLTable();
        }
    }, true);



}

function RemoveInfobulles() //Cette fonction retire les classes "tooltipleft" et "tooltipright" des messages pour éviter que ogame supprime les infos dedans quand l'utilisateur les affiche (ce qui génère des NaN après collecte des RCs).
{
    var tooltipLeft = document.querySelectorAll(".tooltipLeft");
    for (var i = 0; i < tooltipLeft.length; i++) {
        tooltipLeft[i].classList.remove("tooltipLeft");
    }
    var tooltipRight = document.querySelectorAll(".tooltipRight");
    for (var j = 0; j < tooltipRight.length; j++) {
        tooltipRight[j].classList.remove("tooltipRight");
    }
}

//                    RCHTMLTable(Type, ColumnCurrentID, OrdreTri, true);
function RCHTMLTable(FunctionToCall, Data_ID, Data_Ordre, TriManuel) { //These parameters are used when sorting a table : it only calls back the table sorted
    var IDsToDisplay = Determine_UiId(Detect_Market());
    var StartExec = new Date().getTime();
    var FirstDate = GM_getValue(MetaGlobal.Universe + '_DateFirstRC'); //Used to check if there is data stored on the script
    if (FirstDate) {
        var Element = document.querySelector("#RCDisplayTable");
        Element.classList.add('OrangeText');

        var LangueIndex = GetLangue(); //Définit la langue et quelle langue appliquer en fonction de l'utilisateur ou de la langue de l'univers

        //Dans les tableaux par coord, quotidien : afficher les stats des actifs, inactifs, et le total. Par défaut tout est en true
        var AffAct = GetData('General', 'OptRC0', false)
        var AffIna = GetData('General', 'OptRC1', false)
        var AffTot = GetData('General', 'OptRC2', true)


        var MetaLocal = MetaDatas();

        //Vérification de la présence d'anciennes données (avant O-Table 2.5), et migration de ces données s'il y en existe
        if (GM_getValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Met') || GM_getValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Met')) {
            console.log('[O-Table] : Old datas detected, starting migration process');
            MigrateRCData();
        } else {
            console.log('[O-Table] : No Old Data');
        }

        console.log(FunctionToCall);


        switch (FunctionToCall) {
            case 'CRList':
                GenerateRCList(Data_ID, Data_Ordre, TriManuel);
                break;
            case 'Coords' :
                GenerateCoordList(Data_ID, Data_Ordre, TriManuel);
                break;
            case 'Daily':
                GenerateDailyList(Data_ID, Data_Ordre, TriManuel);
                break;
            case 'Weekly':
                GenerateWeeklyList(Data_ID, Data_Ordre, TriManuel);
                break;
            default:
                //Effacer les tableaux et options déjà présents :
                HideRCTable();

                //Affichage des tableaux

                GenerateRCList();
                GenerateCoordList();
                GenerateDailyList();
                GenerateWeeklyList();
                GenerateFullRecap();
                //Liste de RC
                //.................................................................................
        }

        function GenerateRCList(Data_ID, Data_Ordre, TriManuel) {

            var ActivateManageCRList_Val = GetData('General', 'RCManageRCList', "Enabled");
            if (ActivateManageCRList_Val === "Enabled") {
                var RCTable = GetAllRC();
                RCTable = SortRC(RCTable, Data_ID, Data_Ordre);
                if (! Data_ID) {
                    Data_ID = currentRCListSort;
                    Data_Ordre = 'Pair';
                    if (GM_getValue('RCListPairImpair' + MetaGlobal.Universe)) {
                        Data_Ordre = GM_getValue('RCListPairImpair' + MetaGlobal.Universe);
                    }
                    TriManuel = false;
                }


                var Row = '';
                var NumeroLigneDisplayed = 0;

                var HTMLTable = '<table class ="TableRC"  id="OTable_RCList">' +
                    '<th class="HeadRC" id="CoordRaw">' + Langue.RCAJ.split("|||")[LangueIndex] + '</th>' + //Coord
                    '<th class="HeadRC" id="DateStamp">' + Langue.RCAA.split("|||")[LangueIndex] + '</th>' + //Date
                    '<th class="HeadRC" id="AgeSec">' + Langue.RCAO.split("|||")[LangueIndex] + '</th>' + //Age
                    '<th class="HeadRC" id="Attacker">' + Langue.RCAP.split("|||")[LangueIndex] + '</th>' + //Attaquant
                    '<th class="HeadRC" id="Defenser">' + Langue.RCAQ.split("|||")[LangueIndex] + '</th>' + //Défenseur
                    '<th class="HeadRC" id="AttackerLoss">' + Langue.RCAR.split("|||")[LangueIndex] + '</th>' + //Pertes Atk
                    '<th class="HeadRC" id="DefenserLoss">' + Langue.RCAS.split("|||")[LangueIndex] + '</th>' + //Pertes Def
                    '<th class="HeadRC" id="RessourcesBrutes">' + Langue.RCAT.split("|||")[LangueIndex] + '</th>' + //Pillage
                    '<th class="HeadRC" id="RessourcesUSM">' + Langue.RCAU.split("|||")[LangueIndex] + '</th>' + //Pillage USM
                    '<th class="HeadRC" id="CDRAttaquant">' + Langue.RCAV.split("|||")[LangueIndex] + '</th>' + //CDR Atk
                    '<th class="HeadRC" id="AttackerProfit">' + Langue.RCBM.split("|||")[LangueIndex] + '</th>' + //Gains Atk
                    '<th class="HeadRC" id="DefenserProfit">' + Langue.RCAX.split("|||")[LangueIndex] + '</th>' + //Gains Def
                    '<th class="HeadRC"></th>' +
                    '<th class="HeadRC"></th>';
                for (var i = 0; i < RCTable.length; i++) {
                    if (RCTable[i].Type === "Normal") {
                        NumeroLigneDisplayed = NumeroLigneDisplayed + 1;
                        if (NumeroLigneDisplayed % 2 === 0) { //Ajout de la classe définissant si la ligne est paire ou impaire
                            Row = Row +'<tr class ="TableLine Pair ' + RCTable[i].RedBorder + '" id=ID' + RCTable[i].ID + '>';

                        } else {
                            Row = Row +'<tr class ="TableLine Impair ' + RCTable[i].RedBorder + '" id=ID' + RCTable[i].ID + '>';
                        }
                        Row = Row +
                            '<td class="CaseRC"><a class="CoordLink" href="' + RCTable[i].LienGalaxie + '">' + RCTable[i].Coords + '</a></td>' +
                            '<td class="CaseRC">' + RCTable[i].Date + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].AgeDisplayed + '</td>' +
                            '<td class="CaseRC" style="' + RCTable[i].AttackerColor + '">' + RCTable[i].Attacker + '</td>' +
                            '<td class="CaseRC" style="' + RCTable[i].DefenserColor + '">' + RCTable[i].Defenser + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].AttackerLossDisplayed + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].DefenserLossDisplayed + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].RessourcesBrutesDisplayed + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].RessourcesUSMDisplayed + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].CDRAttaquant + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].AttackerProfitDisplayed + '</td>' +
                            '<td class="CaseRC">' + RCTable[i].DefenserProfitDisplayed + '</td>' +
                            '<td class="CaseRC"><div id="DeleteRC"></div></td>' +
                            '<td class="CaseRC"><div id="ModifyRC"></div></td>' +
                            '</tr>';
                    }
                }

                HTMLTable = HTMLTable + Row + '</table>';
                var HTMLObj = document.createElement("div");
                HTMLObj.classList.add('RCTableBorder');
                HTMLObj.classList.add('RCListBorder');
                HTMLObj.innerHTML = HTMLTable;
                if (TriManuel === false) {
                    document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").insertBefore(HTMLObj, document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").firstChild.nextSibling); //Affichage des boutons
                    if (Data_Ordre === 'Pair') {
                        GM_addStyle("#" + currentRCListSort + " { color: #" + GetData('General', 'color14', '00FF00') + "!important; background-color: #151515 !important;} ");
                    } else {
                        GM_addStyle("#" + currentRCListSort + " { color: #" + GetData('General', 'color15', 'FF3010') + "!important; background-color: #151515 !important;} ");
                    }
                } else {
                    var item = document.querySelector(".RCListBorder");
                    item.replaceWith(HTMLObj);
                }
                SortTable('OTable_RCList', 'RCListPairImpair', OldcurrentRCListSort, 'CRList');


                //Gestion des boutons dans le tableau
                for (var j = 0 ; j < NumeroLigneDisplayed; j++){
                    try {
                        document.querySelectorAll('#DeleteRC')[j].addEventListener("click", function(event)                                                  {
                            var IdLine = this.parentNode.parentNode.id.split("ID")[1];
                            this.parentNode.parentNode.style.display='none'; //Suppression de l'affichage de la ligne
                            //Call function to remove this raid from stats :
                            var RC = GetRC(IdLine, GetCRBase('_RCList', ''));
                            var RC_Obj = ConvertRawRC(RC);
                            var Action = "Delete";
                            var AllBases = GetAllBases();
                            var FinalBase = ModifyCRDatas(Action, RC_Obj, AllBases);
                            //console.log(FinalBase);
                            SetAllBases(FinalBase);

                            //GM_deleteValue(MetaLocal.Universe + '_RC_' + IdLine);
                            console.log("[O-Table] : CR with id " + IdLine + " deleted successfully");
                        }, true);
                    } catch(err) {
                    }
                    try {
                        document.querySelectorAll('#ModifyRC')[j].addEventListener("click", function(event)                                                  {
                            //Suppression d'un onglet modification ouvert
                            if (document.querySelector(".OrangeBorderBottom")) {
                                var Table = document.querySelector(".OrangeBorderBottom");
                                if(Table.outerHTML) {
                                    Table.outerHTML = Empty;
                                    document.querySelector(".OrangeBorderTop").classList.remove("OrangeBorderTop");
                                }
                            }

                            var IdLine = this.parentNode.parentNode.id;
                            var LineLength = document.querySelector(IDsToDisplay[1]).querySelector("#" + IdLine).querySelectorAll("td").length;
                            var Rc_ID = IdLine.replace("ID","");
                            var RCRaw = GetRC(Rc_ID, GetCRBase('_RCList', ''));
                            var RC = ConvertRawRC(RCRaw);
                            var TotalCDR = RC.CDRAttaquant + RC.CDRDefenseur;
                            this.parentNode.parentNode.classList.add("OrangeBorderTop");
                            var Row = '<td class="CaseRC" colspan="' + LineLength + '">' + Langue.RCAY.split("|||")[LangueIndex] + '<input type="text" class="BigText" id="ModiField1" maxlength="13"><br/>' + //Perte attaquant
                                Langue.RCAZ.split("|||")[LangueIndex] + '<input type="text" class="BigText" id="ModiField2" maxlength="13"><br/>' + //
                                Langue.RCBA.split("|||")[LangueIndex] + '<input type="text" class="BigText" id="ModiField3" maxlength="13"><br/>' +
                                Langue.RCBB.split("|||")[LangueIndex] + '<input type="text" class="BigText" id="ModiField4" maxlength="13"><br/>' +
                                Langue.RCBC.split("|||")[LangueIndex] + '<select class="DropDownShipsMore" id="ModiField5" style="visibility:visible"></option><option value="A"> Attaquant </option><option value="D"> Défenseur </option></select><br/>' +
                                Langue.RCBD.split("|||")[LangueIndex] + '<input type="text" class="BigText" id="ModiField6" maxlength="13">' + Langue.RCAC.split("|||")[LangueIndex] + ' : <input type="text" class="BigText" id="ModiField7" maxlength="13">' + Langue.RCAD.split("|||")[LangueIndex] + ' : <input type="text" class="BigText" id="ModiField8" maxlength="13"><br/>' +
                                Langue.RCBE.split("|||")[LangueIndex] + '<select class="DropDownShipsMore" id="ModiField9" style="visibility:visible"></option><option value="0"> Actif </option><option value="1"> Inactif </option></select><br/>' +
                                '<table class="SaveModifTable" ><tr><td class ="SaveModif" id="ButtonSaveModif">' + Langue.RCBF.split("|||")[LangueIndex] + '</td></tr></table></td>';

                            var HTMLObj = document.createElement("tr");
                            HTMLObj.classList.add('TableLine');
                            // HTMLObj.classList.add('Impair');
                            HTMLObj.classList.add('OrangeBorderBottom');
                            HTMLObj.innerHTML = Row;



                            document.querySelector(IDsToDisplay[1]).querySelector("#" + IdLine).parentNode.insertBefore(HTMLObj, document.querySelector(IDsToDisplay[1]).querySelector("#" + IdLine).nextSibling); //Affichage des boutons
                            document.getElementById("ModiField1").value = RC.AttackerLoss;
                            document.getElementById("ModiField2").value = RC.DefenserLoss;
                            document.getElementById("ModiField3").value = RC.CDRAttaquant;
                            document.getElementById("ModiField4").value = RC.CDRDefenseur;
                            document.getElementById("ModiField5").value = RC.WhereIsPlayer;
                            document.getElementById("ModiField6").value = RC.Metal;
                            document.getElementById("ModiField7").value = RC.Cristal;
                            document.getElementById("ModiField8").value = RC.Deut;
                            document.getElementById("ModiField9").value = RC.IsIna;

                            //document.getElementById('RCCollectDatas').addEventListener("click", CollectAllRC, true);
                            //Mise à jour automatique des champs CDRs
                            document.getElementById('ModiField3').addEventListener("keyup", UpdateCDRFields, true);
                            document.getElementById('ModiField4').addEventListener("keyup", UpdateCDRFields, true);
                            function UpdateCDRFields() {
                                var tmp = TotalCDR;
                                if (this.id == 'ModiField3' && Number.isInteger(TotalCDR)) {
                                    document.getElementById("ModiField4").value = TotalCDR - this.value
                                } else if (this.id == 'ModiField4' && Number.isInteger(TotalCDR)) {
                                    document.getElementById("ModiField3").value = TotalCDR - this.value
                                }
                            }

                            document.querySelector('#ButtonSaveModif').addEventListener("click", function(event)  {


                                //2- Mise à jour des infos du RC
                                RC.AttackerLoss = parseInt(document.getElementById("ModiField1").value);
                                RC.DefenserLoss = parseInt(document.getElementById("ModiField2").value);
                                RC.CDRAttaquant = parseInt(document.getElementById("ModiField3").value);
                                RC.CDRDefenseur = parseInt(document.getElementById("ModiField4").value);
                                RC.WhereIsPlayer = document.getElementById("ModiField5").value;
                                RC.Metal = parseInt(document.getElementById("ModiField6").value);
                                RC.Cristal = parseInt(document.getElementById("ModiField7").value);
                                RC.Deut = parseInt(document.getElementById("ModiField8").value);
                                RC.IsIna = parseInt(document.getElementById("ModiField9").value);
                                //Enregistrement des modifications
                                var AllBases = GetAllBases();
                                var Action = 'Modify';
                                ModifyCRDatas(Action, RC, AllBases)
                                SetAllBases(AllBases);
                                console.log('[O-Table] : Updating Datas : Step 2 - Updating CR Object Done');

                                //5- Réaffichage du tableau
                                RCHTMLTable();
                            }, true);

                        }, true);
                    } catch(err) {
                    }
                }
            }
            //Gestion des en-têtes (tri par colonnes) :
        }

        //Statistiques full récap
        //.................................................................................

        function GenerateFullRecap() {
            var ActivateManageCRMain_Val = GetData('General', 'RCManageFullRecapTable', "Enabled");
            if (ActivateManageCRMain_Val === "Enabled") { ////M/////C/////D////////////////////////////M/////C//////D
                var SummaryStats = GetCRBase('_RentaTotale', '0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0').split(':-|-:');
                var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
                var TxX = GetData(ProfileUsed, 'RCtxt1', 3) // Métal
                var TxY = GetData(ProfileUsed, 'RCtxt2', 2) // Cristal
                var TxZ = GetData(ProfileUsed, 'RCtxt3', 1) // Deut

                //Compta actifs
                var AllTime_Act_Met = ThousandSeparator(parseInt(SummaryStats[0]));
                var AllTime_Act_Cri = ThousandSeparator(parseInt(SummaryStats[1]));
                var AllTime_Act_Deut = ThousandSeparator(parseInt(SummaryStats[2]));
                var AllTime_Act_Profits = ThousandSeparator(parseInt(SummaryStats[0]) + parseInt(SummaryStats[1]) + parseInt(SummaryStats[2]));
                var AllTime_Act_ProfitsUSM = ThousandSeparator(parseInt(parseInt(SummaryStats[0]) + (parseInt(SummaryStats[1]) * (TxX / TxY)) + (parseInt(SummaryStats[2] * (TxX / TxZ)))));
                var AllTime_Act_Degats = ThousandSeparator(parseInt(SummaryStats[3]));
                var AllTime_Act_Loss = ThousandSeparator(parseInt(SummaryStats[4]));
                var AllTime_Act_NbRC = ThousandSeparator(parseInt(SummaryStats[5]));
                var AllTime_Act_CDR = ThousandSeparator(parseInt(SummaryStats[6]));
                //Compta inactifs
                var AllTime_Ina_Met = ThousandSeparator(parseInt(SummaryStats[7]));
                var AllTime_Ina_Cri = ThousandSeparator(parseInt(SummaryStats[8]));
                var AllTime_Ina_Deut = ThousandSeparator(parseInt(SummaryStats[9]));
                var AllTime_Ina_Profits = ThousandSeparator(parseInt(SummaryStats[7]) + parseInt(SummaryStats[8]) + parseInt(SummaryStats[9]));
                var AllTime_Ina_ProfitsUSM = ThousandSeparator(parseInt(parseInt(SummaryStats[7]) + (parseInt(SummaryStats[8]) * (TxX / TxY)) + (parseInt(SummaryStats[9] * (TxX / TxZ)))));
                var AllTime_Ina_Degats = ThousandSeparator(parseInt(SummaryStats[10]));
                var AllTime_Ina_Loss = ThousandSeparator(parseInt(SummaryStats[11]));
                var AllTime_Ina_NbRC = ThousandSeparator(parseInt(SummaryStats[12]));
                var AllTime_Ina_CDR = ThousandSeparator(parseInt(SummaryStats[13]));

                var HTMLStats = '<table class ="TableRC">' +
                    '<th class="HeadRC">#</th>' +
                    '<th class="HeadRC">' + Langue.RCAL.split("|||")[LangueIndex] + '</th>' + //Renta actifs
                    '<th class="HeadRC">' + Langue.RCAM.split("|||")[LangueIndex] + '</th>'; //Renta inactifs
                var ContentStats = '<tr class ="TableLine Impair"><td class="CaseRC">' + Langue.RCAB.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_Met + '</td><td class="CaseRC">' + AllTime_Ina_Met + '</td></tr>' + //Metal
                    '<tr class ="TableLine Pair"><td class="CaseRC">' + Langue.RCAC.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_Cri + '</td><td class="CaseRC">' + AllTime_Ina_Cri + '</td></tr>' + //Cristal
                    '<tr class ="TableLine Impair"><td class="CaseRC">' + Langue.RCAD.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_Deut + '</td><td class="CaseRC">' + AllTime_Ina_Deut + '</td></tr>' + //Deut
                    '<tr class ="TableLine Pair"><td class="CaseRC">' + Langue.RCAT.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_Profits + '</td><td class="CaseRC">' + AllTime_Ina_Profits + '</td></tr>' + //Pillage
                    '<tr class ="TableLine Impair"><td class="CaseRC">' + Langue.RCAU.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_ProfitsUSM + '</td><td class="CaseRC">' + AllTime_Ina_ProfitsUSM + '</td></tr>' + //Pillage USM
                    '<tr class ="TableLine Pair"><td class="CaseRC">' + Langue.RCAK.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_NbRC + '</td><td class="CaseRC">' + AllTime_Ina_NbRC + '</td></tr>' + //Nb RC
                    '<tr class ="TableLine Impair"><td class="CaseRC">' + Langue.RCAG.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_Degats + '</td><td class="CaseRC">' + AllTime_Ina_Degats + '</td></tr>' + //Dégats
                    '<tr class ="TableLine Pair"><td class="CaseRC">' + Langue.RCAH.split("|||")[LangueIndex] + '</td><td class="CaseRC">' + AllTime_Act_Loss + '</td><td class="CaseRC">' + AllTime_Ina_Loss + '</td></tr>' + //Pertes
                    '<tr class ="TableLine Impair"><td class="CaseRC">' + Langue.RCAN.split("|||")[LangueIndex] + '</td><td class="CaseRC">' +AllTime_Act_CDR  + '</td><td class="CaseRC">' + AllTime_Ina_CDR + '</td></tr>'; //CDR collecté par vous
                HTMLStats = HTMLStats + ContentStats;
                var HTMLStatsObj = document.createElement("div");
                HTMLStatsObj.classList.add('RCTableBorder');
                HTMLStatsObj.innerHTML = HTMLStats;
                document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").insertBefore(HTMLStatsObj, document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").firstChild.nextSibling); //Affichage des boutons

            }
        }
        //.................................................................................
        //Coord
        function GenerateCoordList(Data_ID, Data_Ordre, TriManuel) {
            var ActivateManageCRCoord_Val = GetData('General', 'RCManageCoord', "Disabled");
            if (ActivateManageCRCoord_Val === "Enabled") {

                var CoordTable = GetCoordRecap();

                if (! Data_ID) {
                    Data_ID = currentCoordListSort;
                    Data_Ordre = 'Pair';
                    if (GM_getValue('CoordRCPairImpair' + MetaGlobal.Universe)) {
                        Data_Ordre = GM_getValue('CoordRCPairImpair' + MetaGlobal.Universe);
                    }
                    TriManuel = false;
                }
                CoordTable = SortRC(CoordTable, Data_ID, Data_Ordre);



                var Row = '';
                var NumeroLigneDisplayed = 0;
                var HTMLTable = '<table class ="TableRC" id="OTable_RCCoord">' +
                    '<th class="HeadRC" id="Coord_CoordCalc">' + Langue.RCAJ.split("|||")[LangueIndex] + '</th>' + //Coord
                    '<th class="HeadRC" id="Coord_Met">' + Langue.RCAB.split("|||")[LangueIndex] + '</th>' + //Métal
                    '<th class="HeadRC" id="Coord_Cri">' + Langue.RCAC.split("|||")[LangueIndex] + '</th>' + //Cristal
                    '<th class="HeadRC" id="Coord_Deut">' + Langue.RCAD.split("|||")[LangueIndex] + '</th>' + //Deut
                    '<th class="HeadRC" id="Coord_Profits">' + Langue.RCAE.split("|||")[LangueIndex] + '</th>' + //Renta
                    '<th class="HeadRC" id="Coord_ProfitsUSM">' + Langue.RCAF.split("|||")[LangueIndex] + '</th>' + //Renta usm
                    '<th class="HeadRC" id="Coord_NbRC">' + Langue.RCAK.split("|||")[LangueIndex] + '</th>' + //Nb RC
                    '<th class="HeadRC" id="Coord_Degats">' + Langue.RCAG.split("|||")[LangueIndex] + '</th>' + //Dégats
                    '<th class="HeadRC" id="Coord_Loss">' + Langue.RCAH.split("|||")[LangueIndex] + '</th>' + //Pertes DEF
                    '<th class="HeadRC" id="Coord_CDR" title="' + Langue.RCAN.split("|||")[LangueIndex] + '">' + Langue.RCAI.split("|||")[LangueIndex] + '</th>'; //CDR
                for (var i = 0; i < CoordTable.length; i++) {

                    NumeroLigneDisplayed = NumeroLigneDisplayed + 1;
                    if (NumeroLigneDisplayed % 2 === 0) { //Ajout de la classe définissant si la ligne est paire ou impaire
                        Row = Row +'<tr class ="TableLine Pair">';

                    } else {
                        Row = Row +'<tr class ="TableLine Impair">';
                    }
                    Row = Row +
                        '<td class="CaseRC"><a class="CoordLink" href="' + CoordTable[i].LienGalaxie + '">' + CoordTable[i].Coord_Coord + '</a></td>' +
                        '<td class="CaseRC">' + CoordTable[i].Met_Disp + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].Cri_Disp + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].Deut_Disp + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].Profits_Disp + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].ProfitsUSM_Disp + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].Coord_NbRC + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].Degats_Disp + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].Loss_Disp + '</td>' +
                        '<td class="CaseRC">' + CoordTable[i].CDR_Disp + '</td>' +
                        '</tr>';
                    //console.log(CoordTable[i].Met_Disp);
                }


                HTMLTable = HTMLTable + Row + '</table>';
                var HTMLObj = document.createElement("div");
                HTMLObj.classList.add('RCTableBorder');
                HTMLObj.classList.add('CoordListBorder');
                HTMLObj.innerHTML = HTMLTable;
                if (TriManuel === false) {
                    document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").insertBefore(HTMLObj, document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").firstChild.nextSibling); //Affichage des boutons
                    if (Data_Ordre === 'Pair') {
                        GM_addStyle("#" + currentCoordListSort + " { color: #" + GetData('General', 'color14', '00FF00') + "!important; background-color: #151515 !important;} ");
                    } else {
                        GM_addStyle("#" + currentCoordListSort + " { color: #" + GetData('General', 'color15', 'FF3010') + "!important; background-color: #151515 !important;} ");
                    }
                } else {
                    var item = document.querySelector(".CoordListBorder");
                    item.replaceWith(HTMLObj);
                }
                SortTable('OTable_RCCoord', 'CoordRCPairImpair', OldcurrentCoordListSort, 'Coords');
            }
        }
        //Quotidien
        //................................................................................
        function GenerateDailyList(Data_ID, Data_Ordre, TriManuel) {
            var ActivateManageCRDaily_Val = GetData('General', 'RCManageDaily', "Enabled");
            if (ActivateManageCRDaily_Val === "Enabled") {

                var DailyTableIna = GetDailyRecap('Ina');
                var DailyTableAct = GetDailyRecap('Act');

                if (! Data_ID) {
                    Data_ID = currentDailyListSort;
                    Data_Ordre = 'Pair';
                    if (GM_getValue('DailyRCPairImpair' + MetaGlobal.Universe)) {
                        Data_Ordre = GM_getValue('DailyRCPairImpair' + MetaGlobal.Universe);
                    }
                    TriManuel = false;
                }

                var CurrentDate = new Date();




                //alert(CurrentDate.getDay());//Renvoie le jour de la semaine
                //Compta de la semaine :
                //Récupérer les variables : Week_Act_Profits (par exemple)
                //Faire un if (getDay === 1) { reset Week_ActProfits }
                //Pour chaque RC collecté, faire un split et récupérer le jour, le mois et l'année
                //Vérifier le nombre de jours entre 2 dates
                //Vérifier que la date n'est pas avant le dernier lundi

                //Composition d'un objet comprenant la renta actif, inactif et totale
                var DailyTable = new Array();
                for (var i = 0; i < DailyTableIna.length; i++) {
                    DailyTable[i] = {};
                    DailyTable[i].Day_Date = DailyTableIna[i].Day_Date;
                    DailyTable[i].Day_DateRaw = DailyTableIna[i].Day_DateRaw;
                    DailyTable[i].Day_Act_Met = DailyTableAct[i].Day_Met;
                    DailyTable[i].Day_Act_Cri = DailyTableAct[i].Day_Cri;
                    DailyTable[i].Day_Act_Deut = DailyTableAct[i].Day_Deut;
                    DailyTable[i].Day_Act_Profits = DailyTableAct[i].Day_Profits;
                    DailyTable[i].Day_Act_ProfitsUSM = DailyTableAct[i].Day_ProfitsUSM;
                    DailyTable[i].Day_Act_NbRC = DailyTableAct[i].Day_NbRC;
                    DailyTable[i].Day_Act_Degats = DailyTableAct[i].Day_Degats;
                    DailyTable[i].Day_Act_Loss = DailyTableAct[i].Day_Loss;
                    DailyTable[i].Day_Act_CDR = DailyTableAct[i].Day_CDR;
                    DailyTable[i].Day_Act_Met_Disp = ThousandSeparator(DailyTableAct[i].Day_Met);
                    DailyTable[i].Day_Act_Cri_Disp = ThousandSeparator(DailyTableAct[i].Day_Cri);
                    DailyTable[i].Day_Act_Deut_Disp = ThousandSeparator(DailyTableAct[i].Day_Deut);
                    DailyTable[i].Day_Act_Profits_Disp = ThousandSeparator(DailyTableAct[i].Day_Profits);
                    DailyTable[i].Day_Act_ProfitsUSM_Disp = ThousandSeparator(DailyTableAct[i].Day_ProfitsUSM);
                    DailyTable[i].Day_Act_NbRC_Disp = ThousandSeparator(DailyTableAct[i].Day_NbRC);
                    DailyTable[i].Day_Act_Degats_Disp = ThousandSeparator(DailyTableAct[i].Day_Degats);
                    DailyTable[i].Day_Act_Loss_Disp = ThousandSeparator(DailyTableAct[i].Day_Loss);
                    DailyTable[i].Day_Act_CDR_Disp = ThousandSeparator(DailyTableAct[i].Day_CDR);
                    DailyTable[i].Day_Ina_Met = DailyTableIna[i].Day_Met;
                    DailyTable[i].Day_Ina_Cri = DailyTableIna[i].Day_Cri;
                    DailyTable[i].Day_Ina_Deut = DailyTableIna[i].Day_Deut;
                    DailyTable[i].Day_Ina_Profits = DailyTableIna[i].Day_Profits;
                    DailyTable[i].Day_Ina_ProfitsUSM = DailyTableIna[i].Day_ProfitsUSM;
                    DailyTable[i].Day_Ina_NbRC = DailyTableIna[i].Day_NbRC;
                    DailyTable[i].Day_Ina_Degats = DailyTableIna[i].Day_Degats;
                    DailyTable[i].Day_Ina_Loss = DailyTableIna[i].Day_Loss;
                    DailyTable[i].Day_Ina_CDR = DailyTableIna[i].Day_CDR;
                    DailyTable[i].Day_Ina_Met_Disp = ThousandSeparator(DailyTableIna[i].Day_Met);
                    DailyTable[i].Day_Ina_Cri_Disp = ThousandSeparator(DailyTableIna[i].Day_Cri);
                    DailyTable[i].Day_Ina_Deut_Disp = ThousandSeparator(DailyTableIna[i].Day_Deut);
                    DailyTable[i].Day_Ina_Profits_Disp = ThousandSeparator(DailyTableIna[i].Day_Profits);
                    DailyTable[i].Day_Ina_ProfitsUSM_Disp = ThousandSeparator(DailyTableIna[i].Day_ProfitsUSM);
                    DailyTable[i].Day_Ina_NbRC_Disp = ThousandSeparator(DailyTableIna[i].Day_NbRC);
                    DailyTable[i].Day_Ina_Degats_Disp = ThousandSeparator(DailyTableIna[i].Day_Degats);
                    DailyTable[i].Day_Ina_Loss_Disp = ThousandSeparator(DailyTableIna[i].Day_Loss);
                    DailyTable[i].Day_Ina_CDR_Disp = ThousandSeparator(DailyTableIna[i].Day_CDR);
                    DailyTable[i].Day_Total_Met = DailyTableIna[i].Day_Met + DailyTableAct[i].Day_Met;
                    DailyTable[i].Day_Total_Cri = DailyTableIna[i].Day_Cri + DailyTableAct[i].Day_Cri;
                    DailyTable[i].Day_Total_Deut = DailyTableIna[i].Day_Deut + DailyTableAct[i].Day_Deut;
                    DailyTable[i].Day_Total_Profits = DailyTableIna[i].Day_Profits + DailyTableAct[i].Day_Profits;
                    DailyTable[i].Day_Total_ProfitsUSM = DailyTableIna[i].Day_ProfitsUSM + DailyTableAct[i].Day_ProfitsUSM;
                    DailyTable[i].Day_Total_NbRC = DailyTableIna[i].Day_NbRC + DailyTableAct[i].Day_NbRC;
                    DailyTable[i].Day_Total_Degats = DailyTableIna[i].Day_Degats + DailyTableAct[i].Day_Degats;
                    DailyTable[i].Day_Total_Loss = DailyTableIna[i].Day_Loss + DailyTableAct[i].Day_Loss;
                    DailyTable[i].Day_Total_CDR = DailyTableIna[i].Day_CDR + DailyTableAct[i].Day_CDR;
                    DailyTable[i].Day_Total_Met_Disp = ThousandSeparator(DailyTable[i].Day_Total_Met);
                    DailyTable[i].Day_Total_Cri_Disp = ThousandSeparator(DailyTable[i].Day_Total_Cri);
                    DailyTable[i].Day_Total_Deut_Disp = ThousandSeparator(DailyTable[i].Day_Total_Deut);
                    DailyTable[i].Day_Total_Profits_Disp = ThousandSeparator(DailyTable[i].Day_Total_Profits);
                    DailyTable[i].Day_Total_ProfitsUSM_Disp = ThousandSeparator(DailyTable[i].Day_Total_ProfitsUSM);
                    DailyTable[i].Day_Total_NbRC_Disp = ThousandSeparator(DailyTable[i].Day_Total_NbRC);
                    DailyTable[i].Day_Total_Degats_Disp = ThousandSeparator(DailyTable[i].Day_Total_Degats);
                    DailyTable[i].Day_Total_Loss_Disp = ThousandSeparator(DailyTable[i].Day_Total_Loss);
                    DailyTable[i].Day_Total_CDR_Disp = ThousandSeparator(DailyTable[i].Day_Total_CDR);
                }

                //var currentDailyListSort = 'Day_Date';
                //var OldcurrentDailyListSort = currentDailyListSort;

                //Génération du nom de paramètre à utiliser pour le tri et tri des données
 
                
                if (Data_ID != 'Day_Date') {
                    Data_ID = Data_ID.split('Day_')[1];
                    if (AffTot === true) {
                        Data_ID = 'Day_Total_' + Data_ID;
                    } else {
                        if (AffAct === true && AffIna === true) {
                            Data_ID = 'Day_Total_' + Data_ID;
                        } else if (AffIna === true) {
                            Data_ID = 'Day_Ina_' + Data_ID;
                        } else if (AffAct === true) {
                            Data_ID = 'Day_Act_' + Data_ID;
                        }
                    }
                }
                DailyTable = SortRC(DailyTable, Data_ID, Data_Ordre);
                var Row = '';
                var NumeroLigneDisplayed = 0;
                var MetaLocal = MetaDatas();

                var HTMLTable = '<table class ="TableRC" id="OTable_RCDaily">' +
                    '<th class="HeadRC" id="Day_Date">' + Langue.RCAA.split("|||")[LangueIndex] + '</th>' + //Date
                    '<th class="HeadRC" id="Day_Met">' + Langue.RCAB.split("|||")[LangueIndex] + '</th>' + //Mét
                    '<th class="HeadRC" id="Day_Cri">' + Langue.RCAC.split("|||")[LangueIndex] + '</th>' + //Cri
                    '<th class="HeadRC" id="Day_Deut">' + Langue.RCAD.split("|||")[LangueIndex] + '</th>' + //Deut
                    '<th class="HeadRC" id="Day_Profits">' + Langue.RCAE.split("|||")[LangueIndex] + '</th>' + //Renta
                    '<th class="HeadRC" id="Day_ProfitsUSM">' + Langue.RCAF.split("|||")[LangueIndex] + '</th>' + //Renta USM
                    '<th class="HeadRC" id="Day_NbRC">' + Langue.RCAK.split("|||")[LangueIndex] + '</th>' + //Nb RC
                    '<th class="HeadRC" id="Day_Degats">' + Langue.RCAG.split("|||")[LangueIndex] + '</th>' + //Dégats
                    '<th class="HeadRC" id="Day_DefLoss">' + Langue.RCAH.split("|||")[LangueIndex] + '</th>' + //Pertes def
                    '<th class="HeadRC" id="Day_CDR" title="' + Langue.RCAN.split("|||")[LangueIndex] + '">' + Langue.RCAI.split("|||")[LangueIndex] + '</th>'; //CDR
                for (var i = 0; i < DailyTableIna.length; i++) {

                    NumeroLigneDisplayed = NumeroLigneDisplayed + 1;
                    if (NumeroLigneDisplayed % 2 === 0) { //Ajout de la classe définissant si la ligne est paire ou impaire
                        Row = Row +'<tr class ="TableLine Pair">';

                    } else {
                        Row = Row +'<tr class ="TableLine Impair">';
                    }
                    //console.log(DisplayRCDatas(DailyTableAct[i].Day_Met_Disp, AffAct) + DisplayRCDatas(DailyTableIna[i].Day_Met_Disp, AffIna) + DisplayRCDatas(DailyTableTot[i].Day_Met_Disp, AffTot));
                    Row = Row +
                        '<td class="CaseRC">' + DailyTable[i].Day_DateRaw + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_Met_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_Met_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_Met_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_Cri_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_Cri_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_Cri_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_Deut_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_Deut_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_Deut_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_Profits_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_Profits_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_Profits_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_ProfitsUSM_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_ProfitsUSM_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_ProfitsUSM_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_NbRC_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_NbRC_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_NbRC_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_Degats_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_Degats_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_Degats_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_Loss_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_Loss_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_Loss_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(DailyTable[i].Day_Act_CDR_Disp, AffAct) + DisplayRCDatas(DailyTable[i].Day_Ina_CDR_Disp, AffIna) + DisplayRCDatas(DailyTable[i].Day_Total_CDR_Disp, AffTot) + '</td>' +
                        '</tr>';

                }


                HTMLTable = HTMLTable + Row + '</table>';
                var HTMLObj = document.createElement("div");
                HTMLObj.classList.add('RCTableBorder');
                HTMLObj.classList.add('DailyListBorder');
                HTMLObj.innerHTML = HTMLTable;
                if (TriManuel === false) {
                    document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").insertBefore(HTMLObj, document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").firstChild.nextSibling); //Affichage des boutons
                    if (Data_Ordre === 'Pair') {
                        GM_addStyle("#" + currentDailyListSort + " { color: #" + GetData('General', 'color14', '00FF00') + "!important; background-color: #151515 !important;} ");
                    } else {
                        GM_addStyle("#" + currentDailyListSort + " { color: #" + GetData('General', 'color15', 'FF3010') + "!important; background-color: #151515 !important;} ");
                    }
                } else {
                    var item = document.querySelector(".DailyListBorder");
                    item.replaceWith(HTMLObj);
                }


                SortTable('OTable_RCDaily', 'DailyRCPairImpair', OldcurrentDailyListSort, 'Daily');

            }
        }
        //Hebdo
        //.................................................................................
        function GenerateWeeklyList(Data_ID, Data_Ordre, TriManuel) {
            var ActivateManageCRWeekly_Val = GetData('General', 'RCManageWeekly', "Disabled");
            if (ActivateManageCRWeekly_Val === "Enabled") {




                var WeeklyTableIna = GetWeeklyRecap('Ina');
                var WeeklyTableAct = GetWeeklyRecap('Act');

                if (! Data_ID) {
                    Data_ID = currentWeeklyListSort;
                    Data_Ordre = 'Pair';
                    if (GM_getValue('WeeklyRCPairImpair' + MetaGlobal.Universe)) {
                        Data_Ordre = GM_getValue('WeeklyRCPairImpair' + MetaGlobal.Universe);
                    }
                    TriManuel = false;
                }


                var CurrentDate = new Date();
                //alert(CurrentDate.getDay());//Renvoie le jour de la semaine
                //Compta de la semaine :
                //Récupérer les variables : Week_Act_Profits (par exemple)
                //Faire un if (getDay === 1) { reset Week_ActProfits }
                //Pour chaque RC collecté, faire un split et récupérer le jour, le mois et l'année
                //Vérifier le nombre de jours entre 2 dates
                //Vérifier que la date n'est pas avant le dernier lundi

                var Row = '';
                var NumeroLigneDisplayed = 0;
                var MetaLocal = MetaDatas();

                var WeeklyTable = new Array();
                for (var i = 0; i < WeeklyTableIna.length; i++) {
                    WeeklyTable[i] = {};
                    WeeklyTable[i].DatePlage = WeeklyTableIna[i].DatePlage
                    WeeklyTable[i].Week_Monday = WeeklyTableIna[i].Week_Monday
                    WeeklyTable[i].Week_Total_Met = WeeklyTableIna[i].Week_Met + WeeklyTableAct[i].Week_Met;
                    WeeklyTable[i].Week_Total_Cri = WeeklyTableIna[i].Week_Cri + WeeklyTableAct[i].Week_Cri;
                    WeeklyTable[i].Week_Total_Deut = WeeklyTableIna[i].Week_Deut + WeeklyTableAct[i].Week_Deut;
                    WeeklyTable[i].Week_Total_Profits = WeeklyTableIna[i].Week_Profits + WeeklyTableAct[i].Week_Profits;
                    WeeklyTable[i].Week_Total_USM = WeeklyTableIna[i].Week_USM + WeeklyTableAct[i].Week_USM;
                    WeeklyTable[i].Week_Total_NbRC = WeeklyTableIna[i].Week_NbRC + WeeklyTableAct[i].Week_NbRC;
                    WeeklyTable[i].Week_Total_Degats = WeeklyTableIna[i].Week_Degats + WeeklyTableAct[i].Week_Degats;
                    WeeklyTable[i].Week_Total_Loss = WeeklyTableIna[i].Week_Loss + WeeklyTableAct[i].Week_Loss;
                    WeeklyTable[i].Week_Total_CDR = WeeklyTableIna[i].Week_CDR + WeeklyTableAct[i].Week_CDR;
                    WeeklyTable[i].Week_Total_Met_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_Met);
                    WeeklyTable[i].Week_Total_Cri_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_Cri);
                    WeeklyTable[i].Week_Total_Deut_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_Deut);
                    WeeklyTable[i].Week_Total_Profits_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_Profits);
                    WeeklyTable[i].Week_Total_USM_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_USM);
                    WeeklyTable[i].Week_Total_NbRC_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_NbRC);
                    WeeklyTable[i].Week_Total_Degats_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_Degats);
                    WeeklyTable[i].Week_Total_Loss_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_Loss);
                    WeeklyTable[i].Week_Total_CDR_Disp = ThousandSeparator(WeeklyTable[i].Week_Total_CDR);
                    WeeklyTable[i].Week_Act_Met = WeeklyTableAct[i].Week_Met;
                    WeeklyTable[i].Week_Act_Cri = WeeklyTableAct[i].Week_Cri;
                    WeeklyTable[i].Week_Act_Deut = WeeklyTableAct[i].Week_Deut;
                    WeeklyTable[i].Week_Act_Profits = WeeklyTableAct[i].Week_Profits;
                    WeeklyTable[i].Week_Act_USM = WeeklyTableAct[i].Week_USM;
                    WeeklyTable[i].Week_Act_NbRC = WeeklyTableAct[i].Week_NbRC;
                    WeeklyTable[i].Week_Act_Degats = WeeklyTableAct[i].Week_Degats;
                    WeeklyTable[i].Week_Act_Loss = WeeklyTableAct[i].Week_Loss;
                    WeeklyTable[i].Week_Act_CDR = WeeklyTableAct[i].Week_CDR;
                    WeeklyTable[i].Week_Act_Met_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_Met);
                    WeeklyTable[i].Week_Act_Cri_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_Cri);
                    WeeklyTable[i].Week_Act_Deut_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_Deut);
                    WeeklyTable[i].Week_Act_Profits_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_Profits);
                    WeeklyTable[i].Week_Act_USM_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_USM);
                    WeeklyTable[i].Week_Act_NbRC_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_NbRC);
                    WeeklyTable[i].Week_Act_Degats_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_Degats);
                    WeeklyTable[i].Week_Act_Loss_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_Loss);
                    WeeklyTable[i].Week_Act_CDR_Disp = ThousandSeparator(WeeklyTable[i].Week_Act_CDR);
                    WeeklyTable[i].Week_Ina_Met = WeeklyTableIna[i].Week_Met;
                    WeeklyTable[i].Week_Ina_Cri = WeeklyTableIna[i].Week_Cri;
                    WeeklyTable[i].Week_Ina_Deut = WeeklyTableIna[i].Week_Deut;
                    WeeklyTable[i].Week_Ina_Profits = WeeklyTableIna[i].Week_Profits;
                    WeeklyTable[i].Week_Ina_USM = WeeklyTableIna[i].Week_USM;
                    WeeklyTable[i].Week_Ina_NbRC = WeeklyTableIna[i].Week_NbRC;
                    WeeklyTable[i].Week_Ina_Degats = WeeklyTableIna[i].Week_Degats;
                    WeeklyTable[i].Week_Ina_Loss = WeeklyTableIna[i].Week_Loss;
                    WeeklyTable[i].Week_Ina_CDR = WeeklyTableIna[i].Week_CDR;
                    WeeklyTable[i].Week_Ina_Met_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_Met);
                    WeeklyTable[i].Week_Ina_Cri_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_Cri);
                    WeeklyTable[i].Week_Ina_Deut_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_Deut);
                    WeeklyTable[i].Week_Ina_Profits_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_Profits);
                    WeeklyTable[i].Week_Ina_USM_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_USM);
                    WeeklyTable[i].Week_Ina_NbRC_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_NbRC);
                    WeeklyTable[i].Week_Ina_Degats_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_Degats);
                    WeeklyTable[i].Week_Ina_Loss_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_Loss);
                    WeeklyTable[i].Week_Ina_CDR_Disp = ThousandSeparator(WeeklyTable[i].Week_Ina_CDR);
                }
                if (Data_ID != 'Week_Monday') {
                    Data_ID = Data_ID.split('Week_')[1];
                    if (AffTot === true) {
                        Data_ID = 'Week_Total_' + Data_ID;
                    } else {
                        if (AffAct === true && AffIna === true) {
                            Data_ID = 'Week_Total_' + Data_ID;
                        } else if (AffIna === true) {
                            Data_ID = 'Week_Ina_' + Data_ID;
                        } else if (AffAct === true) {
                            Data_ID = 'Week_Act_' + Data_ID;
                        }
                    }
                }
                WeeklyTable = SortRC(WeeklyTable, Data_ID, Data_Ordre);


                var HTMLTable = '<table class ="TableRC" id="OTable_RCWeekly">' +
                    '<th class="HeadRC" id="Week_Monday">' + Langue.RCBL.split("|||")[LangueIndex] + '</th>' +
                    '<th class="HeadRC" id="Week_Met">' + Langue.RCAB.split("|||")[LangueIndex] + '</th>' + //Mét
                    '<th class="HeadRC" id="Week_Cri">' + Langue.RCAC.split("|||")[LangueIndex] + '</th>' + //Cri
                    '<th class="HeadRC" id="Week_Deut">' + Langue.RCAD.split("|||")[LangueIndex] + '</th>' + //Deut
                    '<th class="HeadRC" id="Week_Profits">' + Langue.RCAE.split("|||")[LangueIndex] + '</th>' + //Renta
                    '<th class="HeadRC" id="Week_USM">' + Langue.RCAF.split("|||")[LangueIndex] + '</th>' + //Renta USM
                    '<th class="HeadRC" id="Week_NbRC">' + Langue.RCAK.split("|||")[LangueIndex] + '</th>' + //Nb RC
                    '<th class="HeadRC" id="Week_Degats">' + Langue.RCAG.split("|||")[LangueIndex] + '</th>' + //Dégats
                    '<th class="HeadRC" id="Week_Loss">' + Langue.RCAH.split("|||")[LangueIndex] + '</th>' + //Pertes def
                    '<th class="HeadRC" id="Week_CDR" title="' + Langue.RCAN.split("|||")[LangueIndex] + '">' + Langue.RCAI.split("|||")[LangueIndex] + '</th>'; //CDR
                for (var i = 0; i < WeeklyTableIna.length; i++) {

                    NumeroLigneDisplayed = NumeroLigneDisplayed + 1;
                    if (NumeroLigneDisplayed % 2 === 0) { //Ajout de la classe définissant si la ligne est paire ou impaire
                        Row = Row +'<tr class ="TableLine Pair">';

                    } else {
                        Row = Row +'<tr class ="TableLine Impair">';
                    }
                    Row = Row +//Act-Ina-Total
                        '<td class="CaseRC">' + WeeklyTable[i].DatePlage + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_Met_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_Met_Disp, AffIna) + DisplayRCDatas(WeeklyTable[i].Week_Total_Met_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_Cri_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_Cri_Disp, AffIna) + DisplayRCDatas(WeeklyTable[i].Week_Total_Cri_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_Deut_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_Deut_Disp, AffIna) + DisplayRCDatas(WeeklyTable[i].Week_Total_Deut_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_Profits_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_Profits_Disp, AffIna) +  DisplayRCDatas(WeeklyTable[i].Week_Total_Profits_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_USM_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_USM_Disp, AffIna)  + DisplayRCDatas(WeeklyTable[i].Week_Total_USM_Disp, AffTot) +  '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_NbRC, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_NbRC, AffIna) + DisplayRCDatas(WeeklyTable[i].Week_Total_NbRC_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_Degats_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_Degats_Disp, AffIna)  + DisplayRCDatas(WeeklyTable[i].Week_Total_Degats_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_Loss_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_Loss_Disp, AffIna) + DisplayRCDatas(WeeklyTable[i].Week_Total_Loss_Disp, AffTot) + '</td>' +
                        '<td class="CaseRC">' + DisplayRCDatas(WeeklyTable[i].Week_Act_CDR_Disp, AffAct) + DisplayRCDatas(WeeklyTable[i].Week_Ina_CDR_Disp, AffIna) + DisplayRCDatas(WeeklyTable[i].Week_Total_CDR_Disp, AffTot) + '</td>' +
                        '</tr>';

                }



                HTMLTable = HTMLTable + Row + '</table>';
                var HTMLObj = document.createElement("div");
                HTMLObj.classList.add('RCTableBorder');
                HTMLObj.classList.add('WeeklyListBorder');
                HTMLObj.innerHTML = HTMLTable;
                if (TriManuel === false) {
                    document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").insertBefore(HTMLObj, document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").firstChild.nextSibling); //Affichage des boutons
                    if (Data_Ordre === 'Pair') {
                        GM_addStyle("#" + currentWeeklyListSort + " { color: #" + GetData('General', 'color14', '00FF00') + "!important; background-color: #151515 !important;} ");
                    } else {
                        GM_addStyle("#" + currentWeeklyListSort + " { color: #" + GetData('General', 'color15', 'FF3010') + "!important; background-color: #151515 !important;} ");
                    }
                } else {
                    var item = document.querySelector(".WeeklyListBorder");
                    item.replaceWith(HTMLObj);
                }
                SortTable('OTable_RCWeekly', 'WeeklyRCPairImpair', OldcurrentWeeklyListSort, 'Weekly');

            }

            //console.log(GM_listValues());


        }
    }
    Element.classList.remove('OrangeText');
    Element.classList.add('GreenText');
    var EndExec = new Date().getTime();
    var TimeExec = EndExec - StartExec;
    console.log('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXECUTION DISPLAY TIME : ' + TimeExec + 'ms    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');

    function DisplayRCDatas(ValToDisplay, YesNo) {
        if (YesNo === true) {
            return (ValToDisplay + '<br/>');
        } else {
            return ''
        }
    }


    function SortTable(TableID, StoredSortingName, OldSortingColumn, Type) {
        //TableId = HTML ID of the table you want to sort
        //StoredSortingName = Data Pair/Impair stored on tampermonkey for this table
        //OldSortingColumn = Initial column used by the script to sort the table, before sorting with the new column
        //Type = CRList, Coords, Daily, Weekly
        //Gestion des en-têtes (tri par colonnes) :

        var NbColumns = document.getElementById(TableID).querySelectorAll("th").length;


        for (var k=0; k < NbColumns; k++){
            try {
                document.getElementById(TableID).querySelectorAll("th")[k].addEventListener("click", function(event)                                                  {

                    var OrdreTri = 'Pair';
                    if (GM_getValue(StoredSortingName + MetaLocal.Universe)) {
                        var OrdreTri = GM_getValue(StoredSortingName + MetaLocal.Universe);
                        if (OrdreTri === 'Pair') {
                            OrdreTri = 'Impair';
                        } else {
                            OrdreTri = 'Pair';
                        }
                    }

                    var ColumnCurrentID = this.id;
                    GM_addStyle("#" + OldSortingColumn + ", #" + ColumnCurrentID + " {color: #848484 !important; background-color: #000000 !important;} "); //Reset old selected line to default color
                    //alert(ColumnCurrentID);
                    switch (Type) {
                        case 'CRList':
                            OldcurrentRCListSort = ColumnCurrentID;
                            break;
                        case 'Coords':
                            OldcurrentCoordListSort = ColumnCurrentID;
                            break;
                        case 'Daily':
                            OldcurrentDailyListSort = ColumnCurrentID;
                            break;
                        case 'Weekly':
                            OldcurrentWeeklyListSort = ColumnCurrentID;
                            break;
                        default:
                    }


                    //tri d'un sens ou d'un autre (en fonction de PairImpair) Le script teste d'abord si il y a changement de colonne, et dans ce cas, le trie se fait toujours de manière descendante et sinon, vérifie l'ordre de tri puis trie dans l'autre sens
                    if (OldSortingColumn == ColumnCurrentID) {
                        if (OrdreTri === 'Pair') {
                            GM_addStyle("#" + ColumnCurrentID + " { color: #" + GetData('General', 'color14', '00FF00') + "!important; background-color: #151515 !important;} ");
                            var OrdreToReturn = 'Pair';
                            OrdreTri = 'Pair';
                        } else {
                            GM_addStyle("#" + ColumnCurrentID + " { color: #" + GetData('General', 'color15', 'FF3010') + "!important; background-color: #151515 !important;} ");
                            var OrdreToReturn = 'Impair';
                            OrdreTri = 'Impair';
                        }
                    } else {
                        GM_addStyle("#" + ColumnCurrentID + " { color: #" + GetData('General', 'color14', '00FF00') + "!important; background-color: #151515 !important;} ");
                        var OrdreToReturn = 'Pair';
                        OrdreTri = 'Pair'
                    }
                    OldSortingColumn = ColumnCurrentID;
                    GM_setValue(StoredSortingName + MetaLocal.Universe, OrdreTri);
                    //console.log(NewTableau);

                    RCHTMLTable(Type, ColumnCurrentID, OrdreToReturn, true);


                }, true);
            } catch(err) {
            }
        }

    }
}

function SortRC(Tableau, DataID, Ordre) {
    if (Ordre === 'Pair') {
        Tableau.sort(function (a,b) {
            if (a[DataID] < b[DataID])
                return 1;
            if (a[DataID] > b[DataID])
                return -1;
            return 0;
        });
    } else {
        Tableau.sort(function (a,b) {
            if (a[DataID] > b[DataID])
                return 1;
            if (a[DataID] < b[DataID])
                return -1;
            return 0;
        });
    }
    return Tableau;
}


///////////////////////////
//Fonction des options
///////////////////////////

function OptionsRC() {
    //Effacer les tableaux et options déjà présents :
    HideRCTable();
    var IDsToDisplay = Determine_UiId(Detect_Market());


    var MetaLocal = MetaDatas();
    //Used for buttons inside options area
    GM_addStyle(".OptionsButtons {border: 1px dashed #444; padding: 5px 3px 5px 2px ; text-align: center; width: 50%");
    GM_addStyle(".OptionsButtons:hover {border: 1px solid #666; text-align: center;");
    GM_addStyle(".OptionsButtonsDisabled {border: 1px dashed #333; padding: 5px 3px 5px 2px ; text-align: center; width: 50%; color:#444");
    GM_addStyle(".OptionsTableButtons {border-spacing: 5px; width: 100%;");
    GM_addStyle(".SmallOptionsButtons {border: 1px dashed #444; padding: 3px 3px 3px 2px ; text-align: center; display: inline;");
    GM_addStyle("#EffacerAllDatas, #SauvegarderRCOptions {text-align: center; width: 100%; height: 30px; border-bottom: 1px solid #222} "); //Bouton sauvegarder en bas des options
    GM_addStyle("#EffacerAllDatas:hover, #SauvegarderRCOptions: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

    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" 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="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"> ' + 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio3" type="radio" name="PTGTTRAVTIME"> ' + Langue.SondeLong.split("|||")[LangueIndex] + '<input id="radio24" 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio5" type="radio" name="ARTIME"> ' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio25" 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio7" type="radio" name="BATIME"> ' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio26" 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"> ' + Langue.GT.split("|||")[LangueIndex] + ' <input id="radio9" type="radio" name="PTGTHOUR"> ' + Langue.SondeLong.split("|||")[LangueIndex] + ' <input id="radio27" type="radio" name="PTGTHOUR"></form>)<form style="display:inline;"> (' + Langue.Brut.split("|||")[LangueIndex] + ' <input id="radio10" type="radio" name="STDMSUHOUR"> ' + 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.RCBO.split("|||")[LangueIndex] +
                                  '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="OptRC0">' + Langue.RCBP.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="OptRC1">' + Langue.RCBQ.split("|||")[LangueIndex] + '</label>' +
                                  '<li class="OptionsColonnesContent OPT"><label><input type="checkbox" id="OptRC2">' + Langue.RCBR.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" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAB.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text15" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAC.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text16" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAF.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text22" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAG.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text23" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAH.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text24" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAL.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text36" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAD.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text20" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAE.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text21" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAJ.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text26" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAI.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text25" maxlength="3"></label>' +
                                  '<li class="OptionsTechsContent OPT">' + Langue.OptionsTechsAM.split("|||")[LangueIndex] + ' : <label><input type="text" class="SmallText" id="text37" maxlength="2"></label>' +
                                  '<li class="OptionsTechsContent OPT">' +
                             '</ul>' +
                        '</table></div>');
        var ZoneExport = ('<div id="OptionsProfils"><table id="TableauZoneProfils">' +
                             '<ul>' +
                          '<tr><td class="OptionsGlobalesContent OPT"><table class="OptionsTableButtons"><tr><td class ="OptionsButtons" id="ExportButton">' + Langue.RCBX.split("|||")[LangueIndex] + '</td>' +
                                                                       '<td class ="OptionsButtons" id="ImportButton">' + Langue.RCBW.split("|||")[LangueIndex] + '</td></tr></table></tr></td>' +
                                                      '<tr><td class="OptionsGlobalesContent OPT"><label><textarea class="MegaText" id="ExportZone"></textarea></label></tr></td>' +
                                  '<li class="OptionsTechsContent OPT">' +
                             '</ul>' +
                        '</table></div>');
    var TableauOptions = ('<div id="OptionsDiv"><table id="OptionsMainTable">' + //affichage des catégories des options (0)
                               '<tr>' +
                                    '<td id="SauvegarderRCOptions" style="color:green;" > --> ' + Langue.OptionsMainAB.split("|||")[LangueIndex] + ' <-- </td>' +
                               '</tr><tr>' +
                                    '<td class="OptionsMainLine">' + Langue.OptionsMainAD.split("|||")[LangueIndex] + ' </td>' +
                               '</tr></tr>' +
                                     '<td class="OptionsMainLine">' + ZoneGlobales + '</td>' +
                               '</tr><tr>' +
                                     '<td class="OptionsMainLine">' + Langue.RCBT.split("|||")[LangueIndex] + ' </td>' +
                               '</tr></tr>' +
                                     '<td class="OptionsMainLine">' + ZoneExport + '</td>' +
                               '</tr><tr>' +
                                     '<li>' +
                                     '<tr><td><table class="OptionsTableButtons"><tr><td class ="OptionsButtons" id="EffacerAllDatas" style="color:red;" > --> ' + Langue.RCBN.split("|||")[LangueIndex] + ' <-- </td></tr></table></tr></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(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").insertBefore(newElement, document.querySelector(IDsToDisplay[1]).querySelector("#fleetsgenericpage .tab_inner").firstChild.nextSibling); //Affichage des boutons

    //Chargement des options
    // Currently used : only global options

    var DefaultOptions = new Array(false, false, true);
    for (var i = 0; i < DefaultOptions.length; i++) {
        var Option = GetData('General', 'OptRC' + i, DefaultOptions[i])
        var Html = document.getElementById('OptRC' + i );
        switch (Html.type) {
            case 'checkbox':
                Html.checked = Option;
                break;
            case 'text':
                Html.value = Option;
                break;
            default:
        }

    }
    ///////////////
    //BOUTONS
    ////////////////
    //DELETE BUTTON
    document.getElementById('EffacerAllDatas').addEventListener("click", DelAllRC, true);
        // SAVE BUTTON
    //Mise en mémoire de toutes les options
    document.getElementById('SauvegarderRCOptions').addEventListener("click", function(event) //Création du bouton permettant la collecte et la sauvegarde des messages
    {
        for (var i = 0; i < DefaultOptions.length; i++) {
            var Html = document.getElementById('OptRC' + i );
            switch (Html.type) {
                case 'checkbox':
                    GM_setValue('General' + ':OptRC' + i +  MetaLocal.Universe, document.getElementById('OptRC' + i).checked);
                    break;
                case 'text':
                    GM_setValue('General' + ':OptRC' + i +  MetaLocal.Universe, document.getElementById('OptRC' + i).value);
                    break;
                default:
            }

        }
        //
        console.log("[O-Table Options] : Options successfully saved!");
        location.reload(); //Rechargement de la page
    }, true);
    ////////////////
    //IMPORT BUTTON
    document.getElementById('ImportButton').addEventListener("click", ImportRC, true);
    function ImportRC()
    {
        var DatasImported = document.getElementById('ExportZone').value;
        var DatasSplit = DatasImported.split('§-§');
        //console.log(DatasSplit.length);
        if (DatasSplit.length === 6) {
            //console.log('Good format')
            var RCList = DatasSplit[0];
            var RentaDaily = DatasSplit[1];
            var RentaCoord = DatasSplit[2];
            var RentaTotale = DatasSplit[3];
            var DateRCExport = DatasSplit[4];
            var BaseIna = DatasSplit[5];
            GM_setValue(MetaGlobal.Universe + '_RCList', RCList);
            GM_setValue(MetaGlobal.Universe + '_RentaTotale', RentaTotale);
            GM_setValue(MetaGlobal.Universe + '_RentaCoord', RentaCoord);
            GM_setValue(MetaGlobal.Universe + '_RentaDaily', RentaDaily);
            GM_setValue(MetaGlobal.Universe + '_DateFirstRC', DateRCExport);
            GM_setValue(MetaGlobal.Universe + '_BaseInaUni', BaseIna);
        } else {
            console.log('[O-Table] : Wrong data format, please fix it before importing. Datas should be composed of 5 parts containing RC list, Daily profits, Coord profits, Total profit and first CR date, and each separated by §-§');
            var Element = this; //This passed through a variable to be able to pass on setTimeout function
            Element.classList.add('RedText');
            setTimeout(function(){ Element.classList.remove('RedText'); }, 1000);
        }

    }
    ////////////////
    //EXPORT BUTTON
    document.getElementById('ExportButton').addEventListener("click", ExportRC, true);
    function ExportRC()
    {
        //console.log('ExportButton');
        var FirstDateRC = GM_getValue(MetaGlobal.Universe + '_DateFirstRC');
        if (FirstDateRC) {
            var AllBases = GetAllBases();
            if (AllBases) {
                var RCList = AllBases[0];
                var RentaDaily = '§-§' + AllBases[1];
                var RentaCoord = '§-§' + AllBases[2];
                var RentaTotale = '§-§' + AllBases[3];
                var DateRCExport = '§-§' + FirstDateRC;
                var BaseIna = '§-§' + BaseIna_Get();
                document.getElementById('ExportZone').value = RCList + RentaDaily + RentaCoord + RentaTotale + DateRCExport + BaseIna;
            }else { console.log('[O-Table] : Error, no data on CR DataBase');}
        } else { console.log('[O-Table] : Error, no data on FirstDateRC');}
    }


}

///////////////////////////
//Fonction de masquage des tableaux
///////////////////////////

function HideRCTable() {
    try {//Permet d'effacer le tableau s'il est déjà présent
        var Empty = '';
        var Element = document.querySelector("#RCDisplayTable");
        Element.classList.remove('GreenText');
    } catch(err) {}
    try{
        var Table = document.querySelector(".RCTableBorder");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
    } catch(err) {}
    try{
        var Table = document.querySelector(".RCTableBorder");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
    } catch(err) {}
    try{
        var Table = document.querySelector(".RCTableBorder");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
    } catch(err) {}
    try{
        var Table = document.querySelector(".RCTableBorder");
        if(Table.outerHTML) {
            Table.outerHTML = Empty;
        }
    } catch(err) {}
    try{
        var Table = document.querySelector(".RCTableBorder");
        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) {}

}


///////////////////////////
//Fonction de collecte des données des RCs
///////////////////////////



function CollectAllRC() {
    var IDsToDisplay = Determine_UiId(Detect_Market());
    var AllMessages = document.querySelector(IDsToDisplay[1]).querySelectorAll("li.msg");
    var NbMessages = AllMessages.length;
    var Element = this; //This passed through a variable to be able to pass on setTimeout function
    Element.classList.add('OrangeText');

    //Vérification de la présence d'anciennes données (avant O-Table 2.5), et migration de ces données s'il y en existe
    if (GM_getValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Met') || GM_getValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Met')) {
        console.log('[O-Table] : Old datas detected, starting migration process');
        MigrateRCData();
    } else {
        console.log('[O-Table] : No Old Data');
    }

    //Récupération des bases de RC (méthode optimisée O-table 2.5)
    var AllBases = GetAllBases();
    var Action = 'Add';

    var BaseIna = BaseIna_Get();
    //alert(NbMessages);
    //Définition de la date du jour


    var Aujourdhui = new Date()
    //console.log(AllBases);
    for (var j = 0; j < NbMessages; j++) {

        var CurrentID = '_' + AllMessages[j].getAttribute("data-msg-id") + '_';
        //Vérification de la présence du RC dans les NOUVELLES bases de stockage
        var IdPosition = AllBases[0].indexOf(CurrentID);

        if(IdPosition === -1) {


            var ObjRC = {} //L'objet est défini dans le for pour qu'il soit réécrasé en intégralité à chaque nouvelle itération (sinon, risque de problèmes quand un RC est un mip alors que les autres sont des RC normaux)
            ObjRC = CreateObjRC(AllMessages,j,BaseIna)

            var DateRC = new Date(ObjRC.Date.split(".")[2].split(' ')[0], (ObjRC.Date.split(".")[1] - 1), ObjRC.Date.split(".")[0]);

            var JoursDecart = ((Aujourdhui - DateRC) / 86400000).toFixed(0);
            //Vérifie si le RC a moins de 9 jours et est de type normal (pas de mip ou autre)
            if (JoursDecart < 9) {
                if (ObjRC.Type === 'Normal') {
                    //Appel de la fonction pour comptabiliser les RCs et enregistrement du RC
                    AllBases = ModifyCRDatas(Action, ObjRC, AllBases);


                    var DateFirstRC = GM_getValue(MetaGlobal.Universe + '_DateFirstRC')
                    //Gestion de la date du premier RC :
                    //Si une date existe il faut vérifier pour chaque RC que la date du RC est inférieure et là réécrire dans ce cas
                    //Si pas de date existante, alors enregistrer une date
                    //Note : la date est enregistré format ogamien (DD.MM.YYYY)
                    if (DateFirstRC) {
                        var DateFirstRC_Converted = new Date(DateFirstRC.split(".")[2], (DateFirstRC.split(".")[1] - 1), DateFirstRC.split(".")[0]);
                        if (DateRC < DateFirstRC_Converted) {
                            GM_setValue(MetaGlobal.Universe + '_DateFirstRC', ObjRC.Date.split(" ")[0]);
                            console.log('[O-Table] : New first CR date set to ' + ObjRC.Date.split(" ")[0]);
                        }
                    } else {
                        GM_setValue(MetaGlobal.Universe + '_DateFirstRC', ObjRC.Date.split(" ")[0]);
                        console.log('[O-Table] : New first CR date set to ' + ObjRC.Date.split(" ")[0]);
                    }
                }
            } else {
                console.log('[O-Table] : CR with ID ' + ObjRC.ID + ' is older than 8 days. It hasnt been collected and counted in the script.');
            }


        } else {
            console.log('[O-Table] : CR with ID ' + CurrentID + ' has been already collected in the past. It hasnt been counted again');
        }

    }
    //console.log(AllBases);
    SetAllBases(AllBases);
    Element.classList.remove('OrangeText');
    Element.classList.add('GreenText');
    setTimeout(function(){ Element.classList.remove('GreenText'); }, 1000);
}

function CreateObjRC(AllMessages, j, BaseIna) { //La création de l'objet est faite dans l'unique but de rendre le script plus lisible (pas d'autre utilité)
    var Message = {};
    //Obtention de la date du premier RC existant

/*
-Faire un SetValue avec la date du premier RC trouvé
-Par défaut, il n'existe pas

-Pour chaque RC, vérifier que cette date est bien supérieure, sinon la réinscrire


--> Durant la collecte : vérifier la date
--> Si cette date est nouvelle et qu'il n'y a pas encore de RC inscrit à la date du jour, alors vérifier également les dates précédentes
- Vérifier qu'un récap de RC existe pour les jours précédents. Si il existe pas, en créer un vierge, et répéter l'opération pour le jour d'avant, jusqu'à trouver un récap RC existant.
Attention : si la date générée est inférieure à la date du premier RC, s'arrêter de chercher
 */

    Message.ID = '_' + AllMessages[j].getAttribute("data-msg-id") + '_';
    Message.Date = AllMessages[j].querySelector(".msg_date").textContent;

    //
    //alert("Date = " + AllMessages[j].querySelector(".msg_date").textContent);
    //Détection du type de RC
    //RC Normal : .msg_ctn3 doit être présent
    //RC Mip : .missilesAttacked doit être présent
    //RC détruit en un tour : tous les autres types de RCs
    if (GM_getValue(MetaGlobal.Universe + '_RC_' + Message.ID)) {
        //do nothing
    } else {
        if (AllMessages[j].querySelectorAll(".msg_ctn3")[0]) {//////////////////////RC NORMAL
            //Note : pour les infobulles, il y a une gestion des erreurs (recherche de l'info à collecter ailleurs que dans le RC lorsqu'il y a une erreur


            Message.Coords = AllMessages[j].querySelector('a.txt_link').textContent.replace(/(\[|\])/g,"");

            var CoordPosition = BaseIna.indexOf(Message.Coords.toString());

            if(CoordPosition > -1) {
                Message.IsIna = 1;
            } else {
                Message.IsIna = 0;
            }
            Message.Counted = 0;
            var CombatLeftSide = AllMessages[j].querySelector(".combatLeftSide");
            var CombatRightSide = AllMessages[j].querySelector(".combatRightSide");
            //Gestion des données à gauche du RC
            Message.Attacker = CombatLeftSide.querySelector(".msg_ctn2").textContent.split("(")[1].split(")")[0];
            Message.AttackerLoss = parseInt(CombatLeftSide.querySelector(".msg_ctn2").getAttribute("title").replace(/\./g,""));
            try {
                Message.Metal = parseInt(CombatLeftSide.querySelector(".msg_ctn3").getAttribute("title").split("<br/>")[1].split(":")[1].replace(" ","").replace(/\./g,""));
                Message.Cristal = parseInt(CombatLeftSide.querySelector(".msg_ctn3").getAttribute("title").split("<br/>")[2].split(":")[1].replace(" ","").replace(/\./g,""));
                Message.Deut = parseInt(CombatLeftSide.querySelector(".msg_ctn3").getAttribute("title").split("<br/>")[3].split(":")[1].replace(" ","").replace(/\./g,""));
            } catch(err) {}

            //Données à droite du RC
            Message.TxButin = CombatLeftSide.querySelector(".msg_ctn3").textContent.split(", ")[1].replace(/[^0-9]/g,"");
            Message.CDR = parseInt(CombatLeftSide.querySelectorAll(".msg_ctn3")[1].getAttribute("title").replace(/\./g,""));
            Message.Defenser = CombatRightSide.querySelector(".msg_ctn2").textContent.split("(")[1].split(")")[0];
            Message.DefenserLoss = parseInt(CombatRightSide.querySelector(".msg_ctn2").getAttribute("title").replace(/\./g,""));
            Message.Repare = CombatRightSide.querySelector(".msg_ctn3").textContent.split(":")[1].replace(" ", "").replace(/\./g,"");


            /* Calcul automatique de l'obtention du CDR : celui qui est le plus rentable obtient le CDR (ce cas couvre la majorité des RCs automatiquement, sauf dans le cas où il y a vol de CDR)
            Renta Attaquant = Pillages + CDR - pertes attaquant
            Renta Défenseur = CDR - pertes défenseur
            Si Renta Attaquant > Renta Défenseur alors : Attaquant obtient le CDR.
            Sinon, Défenseur obtient le CDR
            */
            var RentaAttaquant = ((Message.Metal + Message.Cristal + Message.Deut) + Message.CDR) - Message.AttackerLoss
            var RentaDefenseur = Message.CDR - Message.DefenserLoss
            //console.log('Renta Attaquant = ' + RentaAttaquant + ', Renta Défendeur = ' + RentaDefenseur);
            if (RentaAttaquant > RentaDefenseur) {
                Message.CDRAttaquant = Message.CDR;
                Message.CDRDefenseur  = 0;
            } else {
                Message.CDRDefenseur = Message.CDR;
                Message.CDRAttaquant  = 0;
            }

            //Détection de où se situe le pseudo du joueur : attaquant, défenseur ou nulle part ? (nulle part dans le cas d'un changement de pseudo). L'info doit être enregistrée assez tôt à cause des changements de pseudo
            //alert("Attaquant : " + Message.Attacker + ", Défenseur : " + Message.Defenser);

            if (document.querySelector('#bar').querySelector('#playerName').querySelector('a').textContent == Message.Attacker) { //Joueur en attaque
                Message.WhereIsPlayer = 'A';

            } else if (document.querySelector('#bar').querySelector('#playerName').querySelector('a').textContent == Message.Defenser) { //Joueur en défense
                Message.WhereIsPlayer = 'D';
            } else { //Joueur non trouvé
                Message.WhereIsPlayer = 'NF';
                //alert('Player name not found in RC');
            }


            try {
                Message.Lune = AllMessages[j].querySelector(".msg_ct3").textContent.replace(/\D/g,"");
            } catch(err){
                Message.Lune = 0;
            }
            Message.Counted = 0;
            Message.Type = 'Normal';




        } else if (AllMessages[j].querySelector(".missilesAttacked")) { ////////////////////////MESSAGE MIP
            //alert('Message MIP');
            Message.AttackerCoords = AllMessages[j].querySelector(".missilesAttacked").querySelectorAll("a")[0].textContent.split("[")[1].replace(/(\[|\])/g,"");
            Message.DefenserCoords = AllMessages[j].querySelector(".missilesAttacked").querySelectorAll("a")[1].textContent.split("[")[1].replace(/(\[|\])/g,"");

            //Récupération des défenses et pertes par défense :
            Message.LM = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[0].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[0].querySelector(".lost")) {
                Message.LMLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[0].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.LMLoss = 0;
            }
            Message.LL = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[1].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[1].querySelector(".lost")) {
                Message.LLLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[1].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.LLLoss = 0;
            }
            Message.LLo = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[2].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[2].querySelector(".lost")) {
                Message.LLoLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[2].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.LLoLoss = 0;
            }
            Message.Gauss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[3].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[3].querySelector(".lost")) {
                Message.GaussLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[3].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.GaussLoss = 0;
            }
            Message.Ion = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[4].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[4].querySelector(".lost")) {
                Message.IonLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[4].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.IonLoss = 0;
            }
            Message.Plasma = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[5].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[5].querySelector(".lost")) {
                Message.PlasmaLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[5].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.PlasmaLoss = 0;
            }
            Message.Pb = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[6].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[6].querySelector(".lost")) {
                Message.PbLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[6].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.PbLoss = 0;
            }
            Message.Gb = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[7].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[7].querySelector(".lost")) {
                Message.GbLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[7].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.GbLoss = 0;
            }
            Message.Mi = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[8].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[8].querySelector(".lost")) {
                Message.MiLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[8].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.MiLoss = 0;
            }
            Message.Mip = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[9].textContent.split(" ")[0];
            if (AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[9].querySelector(".lost")) {
                Message.MipLoss = AllMessages[j].querySelector(".missileAttack").querySelectorAll(".tech")[9].querySelector(".lost").textContent.replace(/\(|\)|\-/g,"");
            } else {
                Message.MipLoss = 0;
            }
            Message.Type = 'Mip';
            Message.Counted = 1;
        } else {/////////////////////////////////DETRUIT
            //alert('Détruit en un tour');
            Message.Coords = AllMessages[j].querySelector(".blue_txt").querySelector("a").textContent.replace(/(\[|\])/g,"");
            Message.Type = 'Detruit';
            Message.Counted = 1;
        }
    }
    return Message;
}


///////////////////////////
//Fonction de comptabilisation des RCs : Rajout sur les stats quotidiennes, depuis le début et par coord
///////////////////////////


//Ancienne fonction toujours utilisée dans le processus de migration (ne pas supprimer)
function GetCountRc(name, defaultval) {
    if (GM_getValue(MetaGlobal.Universe + '_ComtaRC:' + name)) {
        return GM_getValue(MetaGlobal.Universe + '_ComtaRC:' + name);
    } else {
        return defaultval;
    }
}


///////////////////////////
//Fonction de migration des anciennes datas vers O-Table v2.5 et ulterieur
///////////////////////////

function MigrateRCData()
{
    //Cette fonction se base sur les anciennes fonctions de récupération de RC, sauf qu'à la place de générer des objets, elle génère de long chaines de caractères à sauvegarder telles quelles
    var MetaLocal = MetaDatas();
    ///////////////////////////////////////////LISTE DE RC
    //Migration de la liste des RCs

    var AllOptions = GM_listValues(); //List all values stored names (not datas inside) into a table
    var Reg = new RegExp(MetaLocal.Universe + '_RC_[0-9]{1,}'); //regular expression used to check if the name corresponds to a CR stored
    var RC = "";
    var RCList = "";
    var Today = new Date();
    for (var i = 0; i < AllOptions.length; i++) {
        var IsARC = Reg.test(AllOptions[i]);
        if (IsARC === true) {
            RC = GM_getValue(AllOptions[i]);
            var RC_Split = RC.split(':--:');
            var RC_ID = '_' + RC_Split[0] + '_';
            RC_Split.shift();
            RC_Split.unshift(RC_ID);
            RC = RC_Split.join(':--:');
            //console.log(RC);

            var DateRC = RC_Split[1].split(' ')[0];
            var DateRCConverted = new Date(DateRC.split(".")[2], (DateRC.split(".")[1] - 1), DateRC.split(".")[0]);
            var DateDiff = ((Today - DateRCConverted) / 86400000).toFixed(0);
            //Deletes a CR if it's older than 8 days.
            if (DateDiff > 8) {
                GM_deleteValue(AllOptions[i]);
                console.log('[O-Table] : RC with datas ' + RC + ' has been removed because it is older than 7 days. Difference of days : ' + DateDiff);
            } else {
                //if younger than 7 days :
                //Add this CR to the string list containing all CR
                if (RCList) {
                    RCList = RCList + ':-|-:' + RC;
                } else {
                    RCList = RC;
                }
            }
        }
    }
    //console.log(RCList);
    GM_setValue(MetaLocal.Universe + '_RCList', RCList);
    //Suppression de l'ancienne liste de RC

    ///////////////////////////////////////////RENTA TOTALE
    var RentaTotale = GetCountRc('AllTime_Act_Met', 0) + ':-|-:' +
        GetCountRc('AllTime_Act_Cri', 0) + ':-|-:' +
        GetCountRc('AllTime_Act_Deut', 0) + ':-|-:' +
        GetCountRc('AllTime_Act_Degats', 0) + ':-|-:' +
        GetCountRc('AllTime_Act_Loss', 0) + ':-|-:' +
        GetCountRc('AllTime_Act_NbRC', 0) + ':-|-:' +
        GetCountRc('AllTime_Act_CDR', 0) + ':-|-:' +
        GetCountRc('AllTime_Ina_Met', 0) + ':-|-:' +
        GetCountRc('AllTime_Ina_Cri', 0) + ':-|-:' +
        GetCountRc('AllTime_Ina_Deut', 0) + ':-|-:' +
        GetCountRc('AllTime_Ina_Degats', 0) + ':-|-:' +
        GetCountRc('AllTime_Ina_Loss', 0) + ':-|-:' +
        GetCountRc('AllTime_Ina_NbRC', 0) + ':-|-:' +
        GetCountRc('AllTime_Ina_CDR', 0);

    //console.log(RentaTotale);
    GM_setValue(MetaLocal.Universe + '_RentaTotale', RentaTotale);

    ///////////////////////////////////////////RENTA PAR COORD
    //Exemple de nom : s126-fr.ogame.gameforge.com_9:185:10_Ina_Recap
    var Reg = new RegExp(MetaLocal.Universe + '.{1,3}:.{1,3}:.{1,2}_[A-z]{3}_Recap'); //regular expression used to check if the name corresponds to a Coord stored
    var CoordTable = '';
    for (var i = 0; i < AllOptions.length; i++) {
        var IsCoord = Reg.test(AllOptions[i]);
        if (IsCoord === true) {
            var Coord = GM_getValue(AllOptions[i]);
            var ActIna = AllOptions[i].split("_")[2];
            var Coord_Updated = Coord.split(':--:')[1] + ':--:' + Coord.split(':--:')[2] + ':--:' + Coord.split(':--:')[3] + ':--:' + Coord.split(':--:')[5] + ':--:' + Coord.split(':--:')[6] + ':--:' + Coord.split(':--:')[7] + ':--:' + Coord.split(':--:')[8] + ':--:' + Coord.split(':--:')[9] + ':--:';
            //On ajoute l'indicateur Act/Ina dans les données (il se trouvait dans le nom de la ligne de stockage avant)
            if (CoordTable) {
                CoordTable = CoordTable + ':-|-:' + Coord_Updated + ActIna;
            } else {
                CoordTable = Coord_Updated + ActIna;
            }
        }
    }
    //console.log(CoordTable);
    GM_setValue(MetaLocal.Universe + '_RentaCoord', CoordTable);

    ///////////////////////////////////////////RENTA DAILY
    var FirstDate = GM_getValue(MetaGlobal.Universe + '_DateFirstRC')
    var FirstDateConverted = new Date(FirstDate.split(".")[2], (FirstDate.split(".")[1] - 1), FirstDate.split(".")[0]);
    var DateRecapToCheck = FirstDateConverted; //Initiation de la variable utilisée pour vérifier les noms au même niveau que la première date
    var DateRecap = FirstDate;//Initiation de la variable utilisée pour vérifier les noms au même niveau que la première date
    var Auj = new Date();
    var AllDayRecap = '';

    while (DateRecapToCheck <= Auj) {
        //Exemple de nom à récupérer : s126-fr.ogame.gameforge.com_05.04.2019_Act_Recap
        var Nom = (MetaGlobal.Universe + '_' + DateRecap + '_Act_Recap');
        var Act = GM_getValue(MetaGlobal.Universe + '_' + DateRecap + '_Act_Recap');
        if (Act) {
            var Act_Updated = Act.split(':--:')[1] + ':--:' + Act.split(':--:')[2] + ':--:' + Act.split(':--:')[3] + ':--:' + Act.split(':--:')[5] + ':--:' + Act.split(':--:')[6] + ':--:' + Act.split(':--:')[7] + ':--:' + Act.split(':--:')[8] + ':--:' + Act.split(':--:')[9] + ':--:';
            //On inscrit les données dans AllDayRecap et on ajoute un indicateur "Act"
            if (AllDayRecap) {
                AllDayRecap += ':-|-:' + Act_Updated + "Act";
            } else{
                AllDayRecap = Act_Updated + "Act";
            }
        }
        Nom = (MetaGlobal.Universe + '_' + DateRecap + '_Ina_Recap');
        var Ina = GM_getValue(MetaGlobal.Universe + '_' + DateRecap + '_Ina_Recap');
       if (Ina){
           var Ina_Updated = Ina.split(':--:')[1] + ':--:' + Ina.split(':--:')[2] + ':--:' + Ina.split(':--:')[3] + ':--:' + Ina.split(':--:')[5] + ':--:' + Ina.split(':--:')[6] + ':--:' + Ina.split(':--:')[7] + ':--:' + Ina.split(':--:')[8] + ':--:' + Ina.split(':--:')[9] + ':--:';
            //On inscrit les données dans AllDayRecap et on ajoute un indicateur "Ina"
            if (AllDayRecap) {
                AllDayRecap = AllDayRecap + ':-|-:' + Ina_Updated + "Ina";
            } else{
                AllDayRecap = Ina_Updated + "Ina";
            }
        }
        DateRecapToCheck.setDate(DateRecapToCheck.getDate() + 1);
        DateRecap = (addZero(DateRecapToCheck.getDate()) + "." + addZero(DateRecapToCheck.getMonth() + 1)  + "." + DateRecapToCheck.getFullYear());
    }
    GM_setValue(MetaLocal.Universe + '_RentaDaily', AllDayRecap);
    //console.log(AllDayRecap);
    //Migration de la base Ina
    var BaseIna = '';
    for (var i = 1; i < 16; i++) {
        for (var j = 0; j < 5; j++) {
            var Data = GM_getValue(MetaGlobal.Universe + '_BaseIna:' + i + ':' + j);
            //console.log(Data);
            //console.log(BaseIna);
            if (Data) {
                if (BaseIna) {
                    BaseIna = BaseIna + '-' + Data;
                } else {
                    BaseIna = Data;
                }
            }
            GM_deleteValue(MetaGlobal.Universe + '_BaseIna:' + i + ':' + j)
        }
    }
    //console.log(BaseIna);
    GM_setValue(MetaGlobal.Universe + '_BaseInaUni', BaseIna);
    DelAllRC(1);
}


///////////////////////////
//Fonction de récupération des RCs et autres récap
///////////////////////////
function GetAllRC() {
    var MetaLocal = MetaDatas();
    var RCTable = new Array();
    var Today = new Date(); //Utilisé pour déterminer la différence de jours entre le RC et la date d'aujourd'hui
    var NewDb = ''; //Utilisé pour re générer une nouvelle liste de RC en effaçant tous ceux plus vieux de 7 jours

    //1-Récupérer stockage
    var AllRC = GM_getValue(MetaLocal.Universe + '_RCList');
    if (AllRC) {

        //2-Séparer chaque RC
        var SplitRC = AllRC.split(':-|-:');

        for (var i = 0; i < SplitRC.length; i++) {

            //2.1-Vérifier l'age du RC
            var DateRC = SplitRC[i].split(':--:')[1].split(' ')[0];
            var DateRCConverted = new Date(DateRC.split(".")[2], (DateRC.split(".")[1] - 1), DateRC.split(".")[0]);
            var DateDiff = ((Today - DateRCConverted) / 86400000).toFixed(0);

            //2.2-Tenir compte du RC seulement si celui-ci a moins de 7 jours
            if (DateDiff > 8) {
                console.log('[O-Table] : RC with datas ' + SplitRC[i] + ' has been removed because it is older than 7 days. Difference of days : ' + DateDiff);
                //Note : a chaque affichage, le script décompose et recompose sa base. Il ne réinclut pas les RC plus vieux de 7 jours.
            } else {            //if younger than 7 days

                //2.3-Convertir le RC en objet et l'insérer dans le tableau
                RCTable.push(ComputeRC(ConvertRawRC(SplitRC[i])));//Mettre le computemessage à ce niveau là (Ici : Appel de la fonction ConvertRawRC pour créer un objet de RC, puis appel de la fonction ComputeMessage qui crée toutes les propriétés, puis inscription de l'objet dans le tableau)
                if (NewDb) {
                    NewDb = NewDb + ':-|-:' + SplitRC[i];
                } else {
                    NewDb = SplitRC[i];
                }
            }
        }

        //3-Sauvegarder la nouvelle base de données si celle-ci est différente
        if (AllRC == NewDb) {
            console.log('[O-Table] : New change detected on RC List');
        } else {
            GM_setValue(MetaLocal.Universe + '_RCList', NewDb);
        }
    } else {
        return '';
    }

    return RCTable;

    //4-Retourner RCTable
    return RCTable;
}


function GetDailyRecap(ActIna) { //ActIna = soit "Ina", soit "Act" -- Utilisé pour générer le nom
    var MetaLocal = MetaDatas();
    var StartExec = new Date().getTime();

    //1-Récupérer base renta quotidienne
    var DailyBase = GM_getValue(MetaLocal.Universe + '_RentaDaily');
    var DailyTable = new Array();

    //Profits USM
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    //Taux USM
    var TxX = GetData(ProfileUsed, 'RCtxt1', 3) // Métal
    var TxY = GetData(ProfileUsed, 'RCtxt2', 2) // Cristal
    var TxZ = GetData(ProfileUsed, 'RCtxt3', 1) // Deut


    if (DailyBase) {

        //2-Récupérer la première date stockée
        var FirstDate = GM_getValue(MetaGlobal.Universe + '_DateFirstRC')
        var FirstDateConverted = new Date(FirstDate.split(".")[2], (FirstDate.split(".")[1] - 1), FirstDate.split(".")[0]);
        var DateRecapToCheck = FirstDateConverted; //Initiation de la variable utilisée pour vérifier les noms au même niveau que la première date
        var DateRecap = FirstDate;//Initiation de la variable utilisée pour vérifier les noms au même niveau que la première date
        var Auj = new Date();

        //3-While pour vérifier les valeurs de la première date à aujourd'hui
        while (DateRecapToCheck <= Auj) {
            //4-Si des données sont trouvées (si le jour existe et qu'une valeur existe pour actif/inactif), alors on les convertit
            var ToCheck = DateRecap + ':--:' + ActIna;
            var ToCheckPosition = DailyBase.indexOf(ToCheck); //Position de la valeur à chercher dans la base
            var RecapObj = {}
            if (ToCheckPosition > -1) {
                var CurrentData = DailyBase.split(ToCheck)[0].split(':-|-:').pop();
                var Recap = CurrentData.split(":--:");
                RecapObj.Day_Met = parseInt(Recap[0]);
                //console.log('Dans la fonction GetDailyRecap : ' + CurrentData);
                RecapObj.Day_Cri = parseInt(Recap[1]);
                RecapObj.Day_Deut = parseInt(Recap[2]);
                RecapObj.Day_Profits = RecapObj.Day_Met + RecapObj.Day_Cri + RecapObj.Day_Deut;
                RecapObj.Day_ProfitsUSM = RecapObj.Day_Met + RecapObj.Day_Cri * (TxX / TxY) + RecapObj.Day_Deut * (TxX / TxZ);
                RecapObj.Day_Degats = parseInt(Recap[3]);
                RecapObj.Day_Loss = parseInt(Recap[4]);
                RecapObj.Day_NbRC = parseInt(Recap[5]);
                RecapObj.Day_CDR = parseInt(Recap[6]);
                RecapObj.Day_DateRaw = DateRecap;
                RecapObj.Day_Date = new Date(RecapObj.Day_DateRaw.split(".")[2], (RecapObj.Day_DateRaw.split(".")[1] - 1), RecapObj.Day_DateRaw.split(".")[0]);
            } else {
                RecapObj.Day_Met = 0;
                RecapObj.Day_Cri = 0;
                RecapObj.Day_Deut = 0;
                RecapObj.Day_Profits = 0;
                RecapObj.Day_ProfitsUSM = 0;
                RecapObj.Day_Degats = 0;
                RecapObj.Day_Loss = 0;
                RecapObj.Day_NbRC = 0;
                RecapObj.Day_CDR = 0;
                RecapObj.Day_DateRaw = DateRecap;//new Date(DateRecap.split(".")[2], (DateRecap.split(".")[1] - 1), DateRecap.split(".")[0]);
                RecapObj.Day_Date =  new Date(RecapObj.Day_DateRaw.split(".")[2], (RecapObj.Day_DateRaw.split(".")[1] - 1), RecapObj.Day_DateRaw.split(".")[0]);
            }
            RecapObj.Day_Profits_Disp = ThousandSeparator(RecapObj.Day_Profits);
            RecapObj.Day_Met_Disp = ThousandSeparator(RecapObj.Day_Met);
            RecapObj.Day_Cri_Disp = ThousandSeparator(RecapObj.Day_Cri);
            RecapObj.Day_Deut_Disp = ThousandSeparator(RecapObj.Day_Deut);
            RecapObj.Day_ProfitsUSM_Disp = ThousandSeparator(RecapObj.Day_ProfitsUSM);
            RecapObj.Day_Degats_Disp = ThousandSeparator(RecapObj.Day_Degats);
            RecapObj.Day_Loss_Disp = ThousandSeparator(RecapObj.Day_Loss);
            RecapObj.Day_CDR_Disp = ThousandSeparator(RecapObj.Day_CDR);

            //5-Ajout des ces données au tableau d'objet
            DailyTable.push(RecapObj);

            DateRecapToCheck.setDate(DateRecapToCheck.getDate() + 1);
            DateRecap = (addZero(DateRecapToCheck.getDate()) + "." + addZero(DateRecapToCheck.getMonth() + 1)  + "." + DateRecapToCheck.getFullYear());
        }

        //6-Tri des données par date
        DailyTable.sort(function (a,b) {
            if (a.Day_Date < b.Day_Date)
                return 1;
            if (a.Day_Date > b.Day_Date)
                return -1;
            return 0;
        });


        //7-On retourne le tableau d'objets
        var EndExec = new Date().getTime();
        var TimeExec = EndExec - StartExec;
        console.log('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXECUTION Daily Table TIME : ' + TimeExec + 'ms    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
        return DailyTable;


    } else {
        return '';
    }
}


function GetWeeklyRecap(ActIna) {
    var MetaLocal = MetaDatas();
    //Récupération de la base des renta quotidiennes
    var DailyBase = GM_getValue(MetaLocal.Universe + '_RentaDaily');

    //Profits USM
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    //Taux USM
    var TxX = GetData(ProfileUsed, 'RCtxt1', 3) // Métal
    var TxY = GetData(ProfileUsed, 'RCtxt2', 2) // Cristal
    var TxZ = GetData(ProfileUsed, 'RCtxt3', 1) // Deut

    if (DailyBase) {
        //Détermination de la date du lundi de la semaine du premier RC
        var FirstDate = GM_getValue(MetaGlobal.Universe + '_DateFirstRC')
        var FirstDateConverted = new Date(FirstDate.split(".")[2], (FirstDate.split(".")[1] - 1), FirstDate.split(".")[0]);

        if (FirstDateConverted.getDay() == 0) {
            var MondayFirstWeek = (FirstDateConverted.getDate() - FirstDateConverted.getDay()) + 1 - 7;
        } else {
            var MondayFirstWeek = (FirstDateConverted.getDate() - FirstDateConverted.getDay()) + 1;
        }
        var DateMondayFirstWeek = new Date(FirstDate.split(".")[2], (FirstDate.split(".")[1] - 1), MondayFirstWeek);
        //console.log('Le lundi de la première semaine est le : ' + DateMondayFirstWeek);

        //Comptage du nombre de jour existant entre ce lundi et aujourd'hui
        var Aujourdhui = new Date()

        var JoursDecart = ((Aujourdhui - DateMondayFirstWeek) / 86400000).toFixed(0);
        var SemDecart = Math.ceil(JoursDecart / 7);
        //console.log('Semaines decart ' + SemDecart);

        var CurrentMonday = new Date(DateMondayFirstWeek); //Il faut le new date sinon DateMonDayFirstWeek est modifié quand on modifie CurrentMonday
        var CurrentSunday = new Date(DateMondayFirstWeek);
        CurrentSunday.setDate(CurrentSunday.getDate() + 6);

        var WeeklyTable = new Array();

        for (var i = 0; i < SemDecart; i++) {
            //console.log('Lundi de cette semaine : ' + CurrentMonday + ', Dimanche de cette semaine' + CurrentSunday);

            //1 - Get first Day and last day of the week
            var CurrentMonday_Ogame = addZero(CurrentMonday.getDate()) + "." + addZero(CurrentMonday.getMonth() + 1)  + "." + CurrentMonday.getFullYear();
            var CurrentSunday_Ogame = addZero(CurrentSunday.getDate()) + "." + addZero(CurrentSunday.getMonth() + 1)  + "." + CurrentSunday.getFullYear();

            var WeekObj = {}
            WeekObj.DatePlage = CurrentMonday_Ogame + ' - ' + CurrentSunday_Ogame;
            WeekObj.Week_Profits = 0;
            WeekObj.Week_Met = 0;
            WeekObj.Week_Cri = 0;
            WeekObj.Week_Deut = 0;
            WeekObj.Week_USM = 0;
            WeekObj.Week_Degats = 0;
            WeekObj.Week_Loss = 0;
            WeekObj.Week_NbRC = 0;
            WeekObj.Week_CDR = 0;
            var JouraVerifier = new Date(CurrentMonday);
            var RecapObj = {}

            //2- Checks every days of the week by creating everydays date and check datas for these days
            for (var j = 0; j < 7; j++) {

                var JouraVerifier_Ogame = addZero(JouraVerifier.getDate()) + "." + addZero(JouraVerifier.getMonth() + 1)  + "." + JouraVerifier.getFullYear();
                //console.log('Jour à vérifier : ' + JouraVerifier);
                var Recap = ("0:--:0:--:0:--:0:--:0:--:0:--:0");
                var ToCheck = JouraVerifier_Ogame + ':--:' + ActIna;
                var ToCheckPosition = DailyBase.indexOf(ToCheck); //Position de la valeur à chercher dans la base
                var RecapObj = {}
                if (ToCheckPosition > -1) {
                    Recap = DailyBase.split(ToCheck)[0].split(':-|-:').pop();
                }
                /*Ancien
                if (GM_getValue(MetaGlobal.Universe + '_' + JouraVerifier_Ogame + '_' + ActIna + '_Recap')) {
                    Recap = GM_getValue(MetaGlobal.Universe + '_' + JouraVerifier_Ogame + '_' + ActIna + '_Recap');
                }*/
                Recap = Recap.split(":--:");
                RecapObj.Day_Met = parseInt(Recap[0]);
                RecapObj.Day_Cri = parseInt(Recap[1]);
                RecapObj.Day_Deut = parseInt(Recap[2]);
                RecapObj.Day_Profits = RecapObj.Day_Met + RecapObj.Day_Cri + RecapObj.Day_Deut;
                RecapObj.Day_ProfitsUSM = RecapObj.Day_Met + RecapObj.Day_Cri * (TxX / TxY) + RecapObj.Day_Deut * (TxX / TxZ);
                RecapObj.Day_Degats = parseInt(Recap[3]);
                RecapObj.Day_Loss = parseInt(Recap[4]);
                RecapObj.Day_NbRC = parseInt(Recap[5]);
                RecapObj.Day_CDR = parseInt(Recap[6]);

                WeekObj.Week_Profits = WeekObj.Week_Profits + RecapObj.Day_Profits;
                WeekObj.Week_Met = WeekObj.Week_Met + RecapObj.Day_Met;
                WeekObj.Week_Cri = WeekObj.Week_Cri + RecapObj.Day_Cri;
                WeekObj.Week_Deut = WeekObj.Week_Deut + RecapObj.Day_Deut;
                WeekObj.Week_USM = WeekObj.Week_USM + RecapObj.Day_ProfitsUSM;
                WeekObj.Week_Degats = WeekObj.Week_Degats + RecapObj.Day_Degats;
                WeekObj.Week_Loss = WeekObj.Week_Loss + RecapObj.Day_Loss;
                WeekObj.Week_NbRC = WeekObj.Week_NbRC + RecapObj.Day_NbRC;
                WeekObj.Week_CDR = WeekObj.Week_CDR + RecapObj.Day_CDR;
                //Inscrire ici la date vérifiée dans la base

                JouraVerifier.setDate(JouraVerifier.getDate() + 1);
            }
            //Converting Raw values to displayed values
            WeekObj.Profits_Disp = ThousandSeparator(WeekObj.Week_Profits);
            WeekObj.Met_Disp = ThousandSeparator(WeekObj.Week_Met);
            WeekObj.Cri_Disp = ThousandSeparator(WeekObj.Week_Cri);
            WeekObj.Deut_Disp = ThousandSeparator(WeekObj.Week_Deut);
            WeekObj.USM_Disp = ThousandSeparator(WeekObj.Week_USM);
            WeekObj.Degats_Disp = ThousandSeparator(WeekObj.Week_Degats);
            WeekObj.Loss_Disp = ThousandSeparator(WeekObj.Week_Loss);
            WeekObj.NbRC_Disp = ThousandSeparator(WeekObj.Week_NbRC);
            WeekObj.CDR_Disp = ThousandSeparator(WeekObj.Week_CDR);
            WeekObj.Week_Monday = new Date(CurrentMonday);
            WeeklyTable.push(WeekObj);
            //console.log(WeeklyTable[0].Profits_Disp);
            CurrentMonday.setDate(CurrentMonday.getDate() + 7);
            CurrentSunday.setDate(CurrentSunday.getDate() + 7);


        }
        return WeeklyTable;
    } else {
        return '';
    }

}

function GetCoordRecap() {
    var MetaLocal = MetaDatas();
    var AllCoords = GM_getValue(MetaLocal.Universe + '_RentaCoord');
    var CoordTable = new Array();
    //Profits USM
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    //Taux USM
    var TxX = GetData(ProfileUsed, 'RCtxt1', 3) // Métal
    var TxY = GetData(ProfileUsed, 'RCtxt2', 2) // Cristal
    var TxZ = GetData(ProfileUsed, 'RCtxt3', 1) // Deut

    if (AllCoords) {
        var CoordTableRaw = AllCoords.split(":-|-:");
        for (var i = 0; i < CoordTableRaw.length; i++) {
            //console.log(i+ AllOptions[i] + IsARC);
            var Coord = CoordTableRaw[i];
            //console.log(Coord);
            //Convert this RC into an object and push it into a table containing all RC
            var CSplit = Coord.split(":--:");
            var CoordObj = {}
            CoordObj.Coord_Met = parseInt(CSplit[0]);
            CoordObj.Coord_Cri = parseInt(CSplit[1]);
            CoordObj.Coord_Deut = parseInt(CSplit[2]);
            CoordObj.Coord_Profits = CoordObj.Coord_Met + CoordObj.Coord_Cri + CoordObj.Coord_Deut;
            CoordObj.Coord_ProfitsUSM = CoordObj.Coord_Met +CoordObj.Coord_Cri * (TxX / TxY) + CoordObj.Coord_Deut * (TxX / TxZ);
            CoordObj.Coord_Degats = parseInt(CSplit[3]);
            CoordObj.Coord_Loss = parseInt(CSplit[4]);
            CoordObj.Coord_NbRC = parseInt(CSplit[5]);
            CoordObj.Coord_CDR = parseInt(CSplit[6]);
            CoordObj.Coord_Coord = CSplit[7];
            CoordObj.Profits_Disp = ThousandSeparator(CoordObj.Coord_Profits);
            CoordObj.Met_Disp = ThousandSeparator(CoordObj.Coord_Met);
            CoordObj.Cri_Disp = ThousandSeparator(CoordObj.Coord_Cri);
            CoordObj.Deut_Disp = ThousandSeparator(CoordObj.Coord_Deut);
            CoordObj.ProfitsUSM_Disp = ThousandSeparator(CoordObj.Coord_ProfitsUSM);
            CoordObj.Degats_Disp = ThousandSeparator(CoordObj.Coord_Degats);
            CoordObj.Loss_Disp = ThousandSeparator(CoordObj.Coord_Loss);
            CoordObj.CDR_Disp = ThousandSeparator(CoordObj.Coord_CDR);
            CoordObj.Coord_CoordCalc = parseInt((CoordObj.Coord_Coord.split(":")[0] * 1000000) + (CoordObj.Coord_Coord.split(":")[1] * 1000) + parseInt((CoordObj.Coord_Coord.split(":")[2]))) * -1; //*-1 pour inverser l'ordre de tri des coords (que la G1 soit la coord la plus grande)
            CoordObj.LienGalaxie = 'https://' + MetaLocal.Universe + '/game/index.php?page=galaxy&galaxy=' + CoordObj.Coord_Coord.split(':')[0] + '&system=' + CoordObj.Coord_Coord.split(':')[1] + '&position=' + CoordObj.Coord_Coord.split(':')[2];
            CoordTable.push(CoordObj);

            //RCTable.push(ComputeRC(ConvertRawRC(RC)));//Mettre le computemessage à ce niveau là (Ici : Appel de la fonction ConvertRawRC pour créer un objet de RC, puis appel de la fonction ComputeMessage qui crée toutes les propriétés, puis inscription de l'objet dans le tableau)

        }
        return CoordTable;
    } else {
        return '';
    }

}



function ConvertRawRC(RawRC) {
    var ObjRC = {};
    RawRC = RawRC.split(":--:");
    //Vérification du type de RC en fonction de la longueur du tableau généré avec le split
    switch(RawRC.length) {
        case 18:
            //RC Normal
            ObjRC.ID = RawRC[0];
            ObjRC.Date = RawRC[1];
            ObjRC.Coords = RawRC[2];
            ObjRC.Attacker = RawRC[3];
            ObjRC.AttackerLoss = parseInt(RawRC[4]);
            ObjRC.Defenser = RawRC[5];
            ObjRC.DefenserLoss = parseInt(RawRC[6]);
            ObjRC.Metal = parseInt(RawRC[7]);
            ObjRC.Cristal = parseInt(RawRC[8]);
            ObjRC.Deut = parseInt(RawRC[9]);
            ObjRC.TxButin = RawRC[10];
            ObjRC.CDRAttaquant = parseInt(RawRC[11]);
            ObjRC.CDRDefenseur = parseInt(RawRC[17]);
            ObjRC.Repare = RawRC[12];
            ObjRC.Lune = RawRC[13];
            ObjRC.WhereIsPlayer = RawRC[14];
            ObjRC.IsIna = parseInt(RawRC[15]);
            ObjRC.Counted = parseInt(RawRC[16]);
            ObjRC.Type = 'Normal';
            break;
        case 24:
            //Rapport de Mip
            ObjRC.ID = RawRC[0];
            ObjRC.Date = RawRC[1];
            ObjRC.AttackerCoords = RawRC[2];
            ObjRC.DefenserCoords = RawRC[3];
            ObjRC.LM = parseInt(RawRC[4]);
            ObjRC.LMLoss = parseInt(RawRC[5]);
            ObjRC.LL = parseInt(RawRC[6]);
            ObjRC.LLLoss = parseInt(RawRC[7]);
            ObjRC.LLo = parseInt(RawRC[8]);
            ObjRC.LLoLoss = parseInt(RawRC[9]);
            ObjRC.Gauss = parseInt(RawRC[10]);
            ObjRC.GaussLoss = parseInt(RawRC[11]);
            ObjRC.Ion = parseInt(RawRC[12]);
            ObjRC.IonLoss = parseInt(RawRC[13]);
            ObjRC.Plasma = parseInt(RawRC[14]);
            ObjRC.PlasmaLoss = parseInt(RawRC[15]);
            ObjRC.Pb = parseInt(RawRC[16]);
            ObjRC.PbLoss = parseInt(RawRC[17]);
            ObjRC.Gb = parseInt(RawRC[18]);
            ObjRC.GbLoss = parseInt(RawRC[19]);
            ObjRC.Mi = parseInt(RawRC[20]);
            ObjRC.MiLoss = parseInt(RawRC[21]);
            ObjRC.Mip = parseInt(RawRC[22]);
            ObjRC.MipLoss = parseInt(RawRC[23]);
            ObjRC.Type = 'Mip';
            break;
        case 3:
            //RC détruit en un tour
            ObjRC.ID = RawRC[0];
            ObjRC.Date = RawRC[1];
            ObjRC.Coords = RawRC[2];
            ObjRC.Type = "Detruit";
            break;
    }
    return ObjRC;

}

function ComputeRC(Message) {
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"

    var MetaLocal = MetaDatas();
    var TxX = GetData(ProfileUsed, 'RCtxt1', 3) // Métal
    var TxY = GetData(ProfileUsed, 'RCtxt2', 2) // Cristal
    var TxZ = GetData(ProfileUsed, 'RCtxt3', 1) // Deut




    //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 = MetaLocal.Timestamp - Message.DateStamp;
    Message.AgeDisplayed = secondsToHms(Message.AgeSec);

    //Gestion de la couleur du pseudo (ina/ pas ina)
    Message.DefenserColor = 'color:#ffffff';
    if (Message.IsIna == 1) {
        Message.DefenserColor = 'color:#505050;';
    }
    Message.AttackerColor = 'color:#ffffff';
    Message.RedBorder = '';

    switch(Message.Type) {
        case "Normal":
            Message.RessourcesBrutes = (Message.Metal + Message.Cristal + Message.Deut);
            Message.RessourcesBrutesDisplayed = ThousandSeparator(Message.RessourcesBrutes);
            Message.RessourcesUSM = Math.round(parseInt((Message.Metal + Message.Cristal * (TxX / TxY) + Message.Deut * (TxX / TxZ))));
            Message.RessourcesUSMDisplayed = ThousandSeparator(Message.RessourcesUSM);
            Message.AttackerLossDisplayed = ThousandSeparator(Message.AttackerLoss);
            Message.DefenserLossDisplayed = ThousandSeparator(Message.DefenserLoss);
            Message.AttackerProfit = ((Message.RessourcesBrutes + Message.CDRAttaquant) - Message.AttackerLoss);
            Message.DefenserProfit = (((Message.RessourcesBrutes * -1) + Message.CDRDefenseur)  - Message.DefenserLoss);
            Message.AttackerProfitDisplayed = ThousandSeparator(Message.AttackerProfit);
            Message.DefenserProfitDisplayed = ThousandSeparator(Message.DefenserProfit);
            if (isNaN(Message.Metal) || isNaN(Message.AttackerLoss) || isNaN(Message.CDRAttaquant) || isNaN(Message.CDRDefenseur) || isNaN(Message.DefenserLoss)) {
                Message.RedBorder = 'RedBorder';
            }
            Message.G = Message.Coords.split(':')[0];
            Message.S = Message.Coords.split(':')[1];
            Message.P = Message.Coords.split(':')[2];
            Message.CoordRaw = parseInt(Message.G * 1000000) + parseInt(Message.S * 1000) + parseInt(Message.P);
            Message.LienGalaxie = 'https://' + MetaLocal.Universe + '/game/index.php?page=galaxy&galaxy=' + Message.G + '&system=' + Message.S + '&position=' + Message.P;



            break;
        case "Mip":
            break;

        case "Detruit":
            break;
    }

    return Message;

}


///////////////////////////
//Fonction de suppression des RCs
///////////////////////////

function DelAllRC(Method) {
    //Method = 1 : Suppression des anciennes données (utile lors de la migration)
    //Method = 2 : Suppression des anciennes + nouvelles données, et suppression de datefirstrc (= suppression de toutes les données)
    if (! Method) {
        Method = 2;
    }
    var MetaLocal = MetaDatas();
    if (Method === 1 || Method === 2) {
    var AllOptions = GM_listValues(); //List all values stored names (not datas inside) into a table
    var Reg = new RegExp(MetaLocal.Universe + '_RC_[0-9]{8,}'); //regular expression used to check if the name corresponds to a CR stored
    var RegRecap = new RegExp(MetaLocal.Universe + '_[0-9]{2}\.[0-9]{2}\.[0-9]{4}_[A-z]{3}_Recap'); //regular expression used to check if the name corresponds to a recap stored
    var RegCoord = new RegExp(MetaLocal.Universe + '.{1,2}:.{1,3}:.{1,2}_[A-z]{3}_Recap'); //regular expression used to check if the name corresponds to a Coord stored
    for (var i = 0; i < AllOptions.length; i++) {
        var IsARC = Reg.test(AllOptions[i]);
        if (IsARC === true) { //Delete the data stored if the name corresponds to a CR
            //console.log(i+ AllOptions[i] + IsARC);
            GM_deleteValue(AllOptions[i]);
        }


        var IsARecap = RegRecap.test(AllOptions[i]);
        if (IsARecap === true) {
            GM_deleteValue(AllOptions[i]);
        }
        var IsACoord = RegCoord.test(AllOptions[i]);
        if (IsACoord === true) {
            GM_deleteValue(AllOptions[i]);
        }
    }
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Profits');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Met');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Cri');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Deut');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_ProfitsUSM');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Degats');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_Loss');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_NbRC');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Act_CDR');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Profits');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Met');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Cri');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Deut');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_ProfitsUSM');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Degats');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_Loss');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_NbRC');
    GM_deleteValue(MetaGlobal.Universe + '_ComtaRC:AllTime_Ina_CDR');
    }
    if (Method === 2) {
        GM_deleteValue(MetaGlobal.Universe + '_DateFirstRC');
        GM_deleteValue(MetaGlobal.Universe + '_RCList');
        GM_deleteValue(MetaGlobal.Universe + '_RentaDaily');
        GM_deleteValue(MetaGlobal.Universe + '_RentaCoord');
        GM_deleteValue(MetaGlobal.Universe + '_RentaTotale');
    }


    location.reload(); //Rechargement de la page
}



/*Fonction utilisée pour :
-Ajouter un nouveau RC dans les bases
-Modifier les données des bases avec les nouvelles données inscrites par l'utilisateur
-Supprimer un RC des bases
*/
function ModifyCRDatas(Action, CR, AllBases) {
    //Attention : AllBases est un tableau 1D et est envoyé dans la fonction que lors de l'ajout de données. Le but étant de limiter les actions Get/Setvalue lors de collectes de plusieurs RCs.
    //Le CR doit déjà être converti en objet
    //ATTENTION : SI CETTE FONCTION ENTRE EN ERREUR ET NE RETOURNE RIEN, IL FAUT IMPERATIVEMENT NE PAS ENREGISTRER DE DONNEES

    var MetaLocal = MetaDatas();

    //Vérification de l'intégrité des données
    var Integrite = true;
    if (isNaN(CR.Metal) || isNaN(CR.Cristal) || isNaN(CR.Deut) || isNaN(CR.AttackerLoss) || isNaN(CR.CDRAttaquant) || isNaN(CR.CDRDefenseur) || isNaN(CR.DefenserLoss) || CR.Metal === '' || CR.Cristal === '' || CR.Deut === '' || CR.AttackerLoss === '' || CR.CDRAttaquant === '' || CR.CDRDefenseur === '' || CR.DefenserLoss === '') {
        Integrite = false;
        console.log('[O-Table] : Integrity is FALSE');
    }

    //Récupération de l'ensemble des bases si la fonction appelant ModifyCRDatas ne l'a pas fait
    if (! AllBases) {
        var AllBases = GetAllBases();
    }


    //Est-ce que le RC a déjà été compté ?
    var DejaCompte = false;
    if (CR.Counted === 1) {
        DejaCompte = true;
    }
    var RCPosition = AllBases[0].indexOf(CR.ID);

    switch (Action) {
        case "Add" :
            if (RCPosition === -1) { //Ce if permet d'éviter de lancer la boucle d'ajout lorsqu'un RC a déjà été collecté. Attention, un RC peut être déjà collecté sans que CR.Counted soit égal à 1, notamment en cas d'erreur d'intégrité des données
                //Le cas "Ajout" est utilisé lors de l'appui sur le bouton "Collecter"
                ModifyStat('Plus');
                AddRC();
                //console.log('Add done');
                //Ajout du RC dans la liste
            } else {
                console.log('[O-Table] Adding Case : CR with ID ' + CR.ID + ' is already stored on the script. No modification will be done to the base');
            }
            //console.log(AllBases);
            return AllBases;
            break;

        case "Modify":
            if (Integrite === true) {
                if (RCPosition > -1) { //Permet de ne pas lancer de boucle de modification si un RC n'est pas présent (ne devrait pas arriver)
                    //Le cas "Modifier" est utilisé lors de l'appui sur le bouton crayon d'un RC
                    //Suppression du RC dans la liste
                    //Dans ce cas, il faut récupérer les anciennes datas
                    var NewCR = CR;
                    var OldCR = ConvertRawRC(CR.ID + AllBases[0].split(CR.ID)[1].split(':-|-:')[0]);
                    CR = OldCR;
                    if (DejaCompte === true) {
                        ModifyStat('Moins');
                    } else {
                        console.log('[O-Table] Modification case : CR with ID ' + CR.ID + ' wasn`t counted yet. No deletion done to Daily, Coord and Summary table');
                    }
                    DelRC();
                    CleanBase();
                    //Ajout du RC dans la liste
                    CR = NewCR;
                    DejaCompte = false;
                    ModifyStat('Plus');
                    AddRC();
                } else {
                    console.log('[O-Table] Modification case : Error : Trying to modify a CR with a unknown ID. No modification will be done to the base.');
                }
            } else {
                console.log('[O-Table] : Data integrity error. No modification done to every base');
            }
            return AllBases;
            break;
        case "Delete":
            if (RCPosition > -1) { //Permet de ne pas supprimer d'entrée si le RC n'est pas présent (ne devrait pas arriver)
                //Suppression du RC dans la liste
                ModifyStat('Moins');
                DelRC();
                CleanBase();
            } else {
                console.log('[O-Table] Deletion case : Error : Trying to delete a CR with a unknown ID. No modification will be done to the base.');
            }
            return AllBases;
            break;
        default:
            return AllBases;
    }



    function ModifyStat(op) { //op doit être "Plus" ou "Moins"
        var operators = {
            'Plus': function(a, b) { return a + b },
            'Moins': function(a, b) { return a - b },
        };
        //Exemple d'usage : (https://stackoverflow.com/questions/5834318/are-variable-operators-possible)
        //var op = '+';
        //alert(operators[op](10, 20));
        //Plus bas :  AllBases[3].split(':-|-:')[0] + (CR.Metal * ActCoef * CoefRess)
        //Où AllBases = 10 et (CR.Metal * ActCoef * CoefRess) = 20, ce qui donne :
        //var AllTime_Act_Met = operators[op](AllBases[3].split(':-|-:')[0], (CR.Metal * ActCoef * CoefRess));
        var RCPosition = AllBases[0].indexOf(CR.ID);

        if (DejaCompte === false || op === "Moins") {
            if (Integrite === true) {
                //Inversion des ressources en négatif pour le calcul des renta lorsque l'utilisateur est en défense
                //Choix du type de propriété d'objet à utiliser pour le calcul des dégats, pertes et CDR.
                if (CR.WhereIsPlayer == "A") {
                    var CoefRess = 1;
                    var DegatsProperty = 'DefenserLoss';
                    var LossProperty = 'AttackerLoss';
                    var CDRProperty = 'CDRAttaquant';
                } else if (CR.WhereIsPlayer == "D") {
                    var CoefRess = -1;
                    var DegatsProperty = 'AttackerLoss';
                    var LossProperty = 'DefenserLoss';
                    var CDRProperty = 'CDRDefenseur';
                }
                if (CR.IsIna === 0) {
                    var InaCoef = 0;
                    var ActCoef = 1;
                    var ActIna = 'Act';
                } else {
                    var InaCoef = 1;
                    var ActCoef = 0;
                    var ActIna = 'Ina';
                }

                //Compta pour la base Renta totale
                //  Ex :                   1 000 000 000              + (1 000 000 *   1    *     -1  )  --> L'utilisateur est en défense et se fait piller 1M, alors qu'il était en renta de 1G
                //var AllTime_Act_Met = AllBases[3].split(':-|-:')[0] + (CR.Metal * ActCoef * CoefRess);
                var AllTime_Act_Met = operators[op](parseInt(AllBases[3].split(':-|-:')[0]), (CR.Metal * ActCoef * CoefRess));
                var AllTime_Act_Cri = operators[op](parseInt(AllBases[3].split(':-|-:')[1]), (CR.Cristal * ActCoef * CoefRess));
                var AllTime_Act_Deut = operators[op](parseInt(AllBases[3].split(':-|-:')[2]), (CR.Deut * ActCoef * CoefRess));
                var AllTime_Act_Degats = operators[op](parseInt(AllBases[3].split(':-|-:')[3]), (CR[DegatsProperty] * ActCoef));
                var AllTime_Act_Loss = operators[op](parseInt(AllBases[3].split(':-|-:')[4]), (CR[LossProperty] * ActCoef));
                var AllTime_Act_NbRC = operators[op](parseInt(AllBases[3].split(':-|-:')[5]), (1 * ActCoef));
                var AllTime_Act_CDR = operators[op](parseInt(AllBases[3].split(':-|-:')[6]), (CR[CDRProperty] * ActCoef));
                var AllTime_Ina_Met = operators[op](parseInt(AllBases[3].split(':-|-:')[7]), (CR.Metal * InaCoef * CoefRess));
                var AllTime_Ina_Cri = operators[op](parseInt(AllBases[3].split(':-|-:')[8]), (CR.Cristal * InaCoef * CoefRess));
                var AllTime_Ina_Deut = operators[op](parseInt(AllBases[3].split(':-|-:')[9]), (CR.Deut * InaCoef * CoefRess));
                var AllTime_Ina_Degats = operators[op](parseInt(AllBases[3].split(':-|-:')[10]), (CR[DegatsProperty] * InaCoef));
                var AllTime_Ina_Loss = operators[op](parseInt(AllBases[3].split(':-|-:')[11]), (CR[LossProperty] * InaCoef));
                var AllTime_Ina_NbRC = operators[op](parseInt(AllBases[3].split(':-|-:')[12]), (1 * InaCoef));
                var AllTime_Ina_CDR = operators[op](parseInt(AllBases[3].split(':-|-:')[13]), (CR[CDRProperty] * InaCoef));
                AllBases[3] = (AllTime_Act_Met + ':-|-:' + AllTime_Act_Cri + ':-|-:' + AllTime_Act_Deut + ':-|-:' + AllTime_Act_Degats + ':-|-:' + AllTime_Act_Loss + ':-|-:' + AllTime_Act_NbRC + ':-|-:' + AllTime_Act_CDR + ':-|-:' + AllTime_Ina_Met + ':-|-:' + AllTime_Ina_Cri + ':-|-:' + AllTime_Ina_Deut + ':-|-:' + AllTime_Ina_Degats + ':-|-:' + AllTime_Ina_Loss + ':-|-:' + AllTime_Ina_NbRC + ':-|-:' + AllTime_Ina_CDR);


                //Compta par coord
                //1 - Recherche d'une donnée pour cette coord et catégorie de cible (act/ina)
                //Exemple de donnée à rechercher : 1:100:13:--:Ina:-|-:
                var DataCherchee = CR.Coords + ':--:' + ActIna;
                var CoordPosition = AllBases[2].indexOf(DataCherchee);
                //console.log('CoordPosition' + CoordPosition);
                if (CoordPosition > -1) {
                    //console.log('Allbase2 : ' + AllBases[2]);
                    var ThisCoordData = AllBases[2].split(DataCherchee)[0].split(':-|-:').pop();
                    //console.log('ThisCoordData =  ' + ThisCoordData);
                    var ThisCoord_Met = operators[op](parseInt(ThisCoordData.split(':--:')[0]), (CR.Metal * CoefRess));
                    //console.log("Coord Met" + ThisCoord_Met);
                    var ThisCoord_Cri = operators[op](parseInt(ThisCoordData.split(':--:')[1]), (CR.Cristal * CoefRess));
                    var ThisCoord_Deut = operators[op](parseInt(ThisCoordData.split(':--:')[2]), (CR.Deut * CoefRess));
                    var ThisCoord_Degats = operators[op](parseInt(ThisCoordData.split(':--:')[3]), CR[DegatsProperty]);
                    var ThisCoord_Loss = operators[op](parseInt(ThisCoordData.split(':--:')[4]), CR[LossProperty]);
                    var ThisCoord_NbRC = operators[op](parseInt(ThisCoordData.split(':--:')[5]), 1);
                    var ThisCoord_CDR = operators[op](parseInt(ThisCoordData.split(':--:')[6]), CR[CDRProperty]);
                    //Création d'une nouvelle et ancienne chaîne de caractères, pour procéder à un replace
                    var OldCoordData = ThisCoordData.split(':--:')[0] + ':--:' + ThisCoordData.split(':--:')[1] + ':--:' + ThisCoordData.split(':--:')[2] + ':--:' + ThisCoordData.split(':--:')[3] + ':--:' + ThisCoordData.split(':--:')[4] + ':--:' + ThisCoordData.split(':--:')[5] + ':--:' + ThisCoordData.split(':--:')[6] + ':--:' + CR.Coords + ':--:' + ActIna;
                    //console.log(OldCoordData);
                    if (ThisCoord_NbRC > 0) {
                        var NewCoordData = ThisCoord_Met + ':--:' + ThisCoord_Cri + ':--:' + ThisCoord_Deut + ':--:' + ThisCoord_Degats + ':--:' + ThisCoord_Loss + ':--:' + ThisCoord_NbRC + ':--:' + ThisCoord_CDR + ':--:' + CR.Coords + ':--:' + ActIna;
                        //2- Mise à jour de la base
                        AllBases[2] = AllBases[2].replace(OldCoordData, NewCoordData);
                    } else {
                        //Effacement de la donnée si celle-ci correspond à 0RC (vide)
                        var NewCoordData = '';
                        //2- Mise à jour de la base
                        AllBases[2] = AllBases[2].replace(OldCoordData, NewCoordData);
                        console.log('[O-Table] : No more CR stored on this coordinate. Data deleted');
                    }
                } else { //Pas de données trouvées
                    //Note : en cas de modification alors qu'il n'y a aucune donnée, cela donne forcément lieu à un Ajout
                    var ThisCoord_Met = CR.Metal * CoefRess;
                    var ThisCoord_Cri = CR.Cristal * CoefRess;
                    var ThisCoord_Deut = CR.Deut * CoefRess;
                    var ThisCoord_Degats = CR[DegatsProperty];
                    var ThisCoord_Loss = CR[LossProperty];
                    var ThisCoord_NbRC = 1;
                    var ThisCoord_CDR = CR[CDRProperty];
                    var NewCoordData = ThisCoord_Met + ':--:' + ThisCoord_Cri + ':--:' + ThisCoord_Deut + ':--:' + ThisCoord_Degats + ':--:' + ThisCoord_Loss + ':--:' + ThisCoord_NbRC + ':--:' + ThisCoord_CDR + ':--:' + CR.Coords + ':--:' + ActIna;
                    //2- Mise à jour de la base
                    if (AllBases[2]) {
                        //2- Mise à jour de la base
                        AllBases[2] += ':-|-:' + NewCoordData;
                    } else {
                        AllBases[2] += NewCoordData;
                    }

                }
                //console.log("Coord : " + AllBases[2]);

                //Compta par date du jour
                //1 - Recherche d'une donnée pour cette date et catégorie de cible (act/ina)
                //Exemple de donnée à rechercher : 25.05.2019:--:Ina:-|-:
                var DataCherchee = CR.Date.split(" ")[0] + ':--:' + ActIna;
                //console.log(DataCherchee);
                var DatePosition = AllBases[1].indexOf(DataCherchee);
                if (DatePosition > -1) {
                    var ThisDateData = AllBases[1].split(DataCherchee)[0].split(':-|-:').pop();
                    var ThisDate_Met = operators[op](parseInt(ThisDateData.split(':--:')[0]), (CR.Metal * CoefRess));
                    var ThisDate_Cri = operators[op](parseInt(ThisDateData.split(':--:')[1]), (CR.Cristal * CoefRess));
                    var ThisDate_Deut = operators[op](parseInt(ThisDateData.split(':--:')[2]), (CR.Deut * CoefRess));
                    var ThisDate_Degats = operators[op](parseInt(ThisDateData.split(':--:')[3]), CR[DegatsProperty]);
                    var ThisDate_Loss = operators[op](parseInt(ThisDateData.split(':--:')[4]), CR[LossProperty]);
                    var ThisDate_NbRC = operators[op](parseInt(ThisDateData.split(':--:')[5]), 1);
                    var ThisDate_CDR = operators[op](parseInt(ThisDateData.split(':--:')[6]), CR[CDRProperty]);
                    //Création d'une nouvelle et ancienne chaîne de caractères, pour procéder à un replace
                    var OldDateData = ThisDateData.split(':--:')[0] + ':--:' + ThisDateData.split(':--:')[1] + ':--:' + ThisDateData.split(':--:')[2] + ':--:' + ThisDateData.split(':--:')[3] + ':--:' + ThisDateData.split(':--:')[4] + ':--:' + ThisDateData.split(':--:')[5] + ':--:' + ThisDateData.split(':--:')[6] + ':--:' + CR.Date.split(" ")[0] + ':--:' + ActIna;
                    if (ThisDate_NbRC > 0) {
                        var NewDateData = ThisDate_Met + ':--:' + ThisDate_Cri + ':--:' + ThisDate_Deut + ':--:' + ThisDate_Degats + ':--:' + ThisDate_Loss + ':--:' + ThisDate_NbRC + ':--:' + ThisDate_CDR + ':--:' + CR.Date.split(" ")[0] + ':--:' + ActIna;
                        //2- Mise à jour de la base
                        AllBases[1] = AllBases[1].replace(OldDateData, NewDateData);
                    } else {
                        var NewDateData = '';
                        console.log('[O-Table] : No more CR stored on this day. Data deleted');
                        //2- Mise à jour de la base
                        AllBases[1] = AllBases[1].replace(OldDateData, NewDateData);
                    }
                } else { //Pas de données trouvées
                    //Note : en cas de modification alors qu'il n'y a aucune donnée, cela donne forcément lieu à un Ajout
                    var ThisDate_Met = CR.Metal * CoefRess;
                    var ThisDate_Cri = CR.Cristal * CoefRess;
                    var ThisDate_Deut = CR.Deut * CoefRess;
                    var ThisDate_Degats = CR[DegatsProperty];
                    var ThisDate_Loss = CR[LossProperty];
                    var ThisDate_NbRC = 1;
                    var ThisDate_CDR = CR[CDRProperty];
                    var NewDateData = ThisDate_Met + ':--:' + ThisDate_Cri + ':--:' + ThisDate_Deut + ':--:' + ThisDate_Degats + ':--:' + ThisDate_Loss + ':--:' + ThisDate_NbRC + ':--:' + ThisDate_CDR + ':--:' + CR.Date.split(" ")[0] + ':--:' + ActIna;
                    if (AllBases[1]) {
                        //2- Mise à jour de la base
                        AllBases[1] += ':-|-:' + NewDateData;
                    } else {
                        AllBases[1] += NewDateData;
                    }
                }
                //console.log("Daily : " + AllBases[1]);
                if (op === "Plus") {
                    CR.Counted = 1;
                }
            } else {
                console.log('[O-Table] : Error with data integrity : No modification done to Coord, Daily and Summary Table')
            }
        }
        return AllBases;
    }

    function AddRC() {
        //Conversion du RC en texte
        var RC_Txt = (CR.ID + ":--:" + CR.Date + ":--:" + CR.Coords + ":--:" + CR.Attacker + ":--:" + CR.AttackerLoss + ":--:" + CR.Defenser + ":--:" + CR.DefenserLoss + ":--:" + CR.Metal + ":--:" + CR.Cristal + ":--:" + CR.Deut + ":--:" + CR.TxButin + ":--:" + CR.CDRAttaquant + ":--:" + CR.Repare + ":--:" + CR.Lune + ":--:" + CR.WhereIsPlayer + ":--:" + CR.IsIna + ":--:" + CR.Counted + ":--:" + CR.CDRDefenseur);

        if (DejaCompte === false) {
            if (Integrite === true || Action === "Add") {
                //Ajout du RC dans la liste de RCs :
                if (AllBases[0]) {
                    AllBases[0] += ':-|-:' + RC_Txt;
                } else {
                    AllBases[0] = RC_Txt;
                }
                //console.log('Base RC après Ajout_ ' + AllBases[0]);
            } else {
                console.log('[O-Table] : Error with CR ' + CR.ID + '. Wrong data modified. No modification done to CR base, please enter new datas with a good format');
                return AllBases;
            }
        }
        return AllBases;
    }

    function DelRC() {
        if (Integrite === true || CR.Counted === 0) {
            //console.log("AllBases0_" + AllBases[0]);
            var BaseRCSplit =  AllBases[0].split(CR.ID);
            //console.log("BaseRCSPLIT_" + BaseRCSplit);
            //Recomposition de la base sans les infos
            var DebutBase = BaseRCSplit[0];
            //console.log("DebutBase_" + DebutBase);
            var FinBase = BaseRCSplit[1].split(':-|-:')
            //console.log("FinBASE_" + FinBase);
            FinBase.shift(); //Remove first Element from Array
            var FinBase_Joined = FinBase.join(':-|-:');

            var NewRCBase = DebutBase + FinBase_Joined;
            //console.log('BaseRC  après suppression_ : ' + NewRCBase);

            AllBases[0] = NewRCBase;
        } else {
            console.log('[O-Table] : Data integrity error on a counted CR. Please modify and fix these Datas before deleting');
        }
        return AllBases;
    }

    //Fonction utilisée pour supprimer les doubles :-|-:, ou si la base commence ou termine par :-|-:
    function CleanBase() {

        for (var j = 0; j < 4; j++) {
            //console.log("Avant Clean " + AllBases[j]);
            var BaseSplit =AllBases[j].split(':-|-:');
            var CleanedBase = BaseSplit.filter( function( element ) {
                return element.length > 1;
            });
            BaseSplit = CleanedBase;


            var DebutBase = BaseSplit[0];
            var FinBase = BaseSplit.slice(-1);
            //console.log("CleanDebut" + DebutBase);
            //console.log("CleanFin" + FinBase);
            if (DebutBase == "") {
                BaseSplit.shift();
                console.log('[O-Table] : Information : shifting base')
            }
            if (FinBase == "") {
                BaseSplit.pop();
                console.log('[O-Table] : Information : popping base')
            }
            AllBases[j] = BaseSplit.join(':-|-:');
        }
        //console.log("Après Clean " + AllBases);
        return AllBases;

    }
}

function GetCRBase(BaseName, DefaultVal)
{
    var Database = GM_getValue(MetaGlobal.Universe + BaseName);
    if (Database) {
        return Database;
    } else {
        return DefaultVal;
    }
}

function GetRC(RC_ID, BaseRC)
{
    var RC = RC_ID + BaseRC.split(RC_ID)[1].split(':-|-:')[0];
    return RC
}

function GetAllBases()
{
    var AllBases = new Array(GetCRBase('_RCList', ''),
                             GetCRBase('_RentaDaily', ''),
                             GetCRBase('_RentaCoord', ''),
                             GetCRBase('_RentaTotale', '0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0:-|-:0'));
    return AllBases;
}

function SetAllBases(FinalBase)
{
    GM_setValue(MetaGlobal.Universe + '_RCList', FinalBase[0]);
    GM_setValue(MetaGlobal.Universe + '_RentaTotale', FinalBase[3]);
    GM_setValue(MetaGlobal.Universe + '_RentaCoord', FinalBase[2]);
    GM_setValue(MetaGlobal.Universe + '_RentaDaily', FinalBase[1]);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////ZONE GLOBALE ------------------------GLOBAL AREA//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//INACTIVE DATABASE//////////////////////////////////BASE INACTIFS////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Cette base liste l'ensemble des coordonnées des inactifs (elle se base sur la partie RE de O-Table). Elle sert à savoir quels sont les coords des inactifs dans les RC (vu qu'on a pas l'info sur le RC non détaillé).
//Les bases inas sont découpés par portions de 100ss : pour éviter que la recherche d'informations soit trop longue sur les unis contenant trop d'inactifs


function BaseIna_Add (Coord, Base)
{

    if (! Base) { //Get base if not sent to the script
        Base = GM_getValue(MetaGlobal.Universe + '_BaseInaUni');
    }

    if(Base) {
        var PresenceCoord = Base.indexOf(Coord);
    } else {
        PresenceCoord = -1;
    }
    if (PresenceCoord === -1) {
        if (! Base) {
            Base = Coord.toString();
        } else {
            Base = Base + '-' + Coord.toString();
        }
        console.log('[O-Table] : Coord ' + Coord + ' has been added to inactive database');
    }

    return Base;
}

function BaseIna_Set(Base)
{
    if (Base) {
        GM_setValue(MetaGlobal.Universe + '_BaseInaUni', Base);
    }
}

function BaseIna_Get ()
{
    var Base = GM_getValue(MetaGlobal.Universe + '_BaseInaUni');
    if (! Base) {
        return '';
    }
    return Base;
}

function BaseIna_Del (Coord, Base) //Cette fonction est appelée sur les coords actives pour vérifier et s'assurer que la coord ne se trouve pas dans une base ina
{
    Coord = Coord.toString();
    if (! Base) { //Get base if not sent to the script
        Base = GM_getValue(MetaGlobal.Universe + '_BaseInaUni');
    }
    if(Base) {
        var PresenceCoord = Base.indexOf(Coord);
    } else {
        PresenceCoord = -1;
    }
    var Modification = false;
    if (PresenceCoord > -1) {
        Base = Base.replace(Coord, '');
        console.log('[O-Table] : Coord ' + Coord + ' has been removed from inactive database');
        Modification = true;
    }
    //Cleaning base
    if (Modification === true) {
        Base.replace('--', '-');
        var BaseSplit =Base.split('-');
        var DebutBase = BaseSplit[0];
        var FinBase = BaseSplit.slice(-1);
        if (DebutBase == "") {
            BaseSplit.shift();
            console.log('[O-Table] : Information : shifting base')
        }
        if (FinBase == "") {
            BaseSplit.pop();
            console.log('[O-Table] : Information : popping base')
        }
        Base = BaseSplit.join('-');
    }
    return Base;
}


//DATA GET FUNCTION
function GetData(ProfileUsed, DataName, DefaultData) {

    //GM_setValue(ProfileUsed + ':column' + i +  MetaLocal.Universe, document.getElementById('cbox' + i).checked);
    //GM_setValue(document.getElementById('RadioProfile' + b).id.split('Radio')[1] + ':name' + MetaLocal.Universe, document.getElementById('LabelRadioProfile' + b).textContent);
    //alert(ProfileUsed+':'+DataName+MetaGlobal.Universe);
    var DataToSend;
    if (!(GM_getValue(ProfileUsed + ':' + DataName + MetaGlobal.Universe) === undefined)) {
        DataToSend = GM_getValue(ProfileUsed + ':' + DataName + MetaGlobal.Universe);
    } else {
        DataToSend = DefaultData //Default value
    }
    return DataToSend;


}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//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
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"

    //Récupération du choix utilisateur concernant les indicateurs millions/milliards
    var IndicateurMilliard = GetData(ProfileUsed, 'text11', Langue.Milliard.split("|||")[LangueIndex]);
    var IndicateurMillions = GetData(ProfileUsed, 'text12', Langue.Million.split("|||")[LangueIndex]);



    //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();
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    //Used to know if user wants to reduce number sizes
    var ReduceNumbers = GetData(ProfileUsed, 'column35', false);

    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
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    //Récupération du choix utilisateur concernant les indicateurs millions/milliards
    var IndicateurMilliard = GetData(ProfileUsed, 'text11', Langue.Milliard.split("|||")[LangueIndex]);
    var IndicateurMillions = GetData(ProfileUsed, 'text12', Langue.Million.split("|||")[LangueIndex]);
    var IndicateurMilliers = GetData(ProfileUsed, 'text13', Langue.Milliers.split("|||")[LangueIndex])
    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;
            }
        }
    }
    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) + 1); //getmonth is starts to 0 = january so we need to add +1 to get the correct 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 = {};
    Meta.RawTime = document.querySelector("li.OGameClock").textContent; //Classic case, get server clock
    CurrentTime.Annee = Meta.RawTime.split(".")[2].split(" ")[0];
    CurrentTime.Mois = Meta.RawTime.split(".")[1].split(" ")[0];
    CurrentTime.Jour = Meta.RawTime.split(".")[0].split(" ")[0];
    CurrentTime.Heure = Meta.RawTime.split(" ")[1].split(":")[0];
    CurrentTime.Minute = Meta.RawTime.split(" ")[1].split(":")[1];
    CurrentTime.Seconde = Meta.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-peaceful']").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;
    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


    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();
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    var LangueIndex = 1; //(EN) Default english
    //Récupération du choix qu'a mis l'utilisateur dans la langue
    if (GetData(ProfileUsed, 'DropDown1', '')) { //'' needed to go to the else if there is no data stored, this is the else which defines default value
        var LangueIndex = GetData(ProfileUsed, 'DropDown1', '');
    } else {
        if (MetaLocal.Langue == "fr") { //Config par défaut, lorsqu'aucune option n'est validée
            var LangueIndex = 0; //(FR)
        } else {
            if (MetaLocal.Langue == "es") {
                var LangueIndex = 2; //(ES)
            }
        }
    }
    return LangueIndex;
}




///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////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
//TEMPLATE : Langue.XXXXXXXX = 'FR' + '|||' + 'EN' + '|||' + 'ES' + '|||' + OTHER LANGUAGE
var Langue = {};
Langue.BoutonAfficherTableau = 'Afficher Tableau' + '|||' + 'Display Table' + '|||' + 'Mostrar Tabla';
Langue.BoutonAfficherTableauTITLE = 'Affiche le tableau lorsque des RE ont été collectés' + '|||' + 'Displays the board when you have collected some spy reports' + '|||' + 'Muestra la tabla cuando hay algún espionaje en el registro';
Langue.BoutonCollecterMessages = 'Collecter Messages' + '|||' + 'Get Messages' + '|||' + 'Leer Mensajes';
Langue.BoutonCollecterMessagesTITLE = 'Collecte les RE présents sur cette page' + '|||' + 'Collects spy reports from this page' + '|||' + 'Lee los reportes de espionaje de la página actual';
Langue.BoutonMasquerTableau = 'Masquer Tableau' + '|||' + 'Hide Table' + '|||' + 'Ocultar Tabla';
Langue.BoutonMasquerTableauTITLE = 'Cache le tableau lorsqu`il est affiché' + '|||' + 'Hide the board when the board is displayed' + '|||' + 'Oculta la tabla';
Langue.BoutonOptions = 'Options' + '|||' + 'Options' + '|||' + 'Opciones';
Langue.BoutonOptionsTITLE = 'Permet d`accéder aux options du script' + '|||' + 'Access to the script options' + '|||' + 'Accede a la opciones del script';
Langue.BoutonViderScript = 'Vider Tableau' + '|||' + 'Empty Table' + '|||' + 'Vaciar Tabla';
Langue.BoutonViderScriptTITLE = 'Vide le tableau de ses REs' + '|||' + 'Empty the spy reports table' + '|||' + 'Vacía la tabla de reportes de espionaje';
Langue.BoutonAfficherDonnées = 'Afficher Données' + '|||' + 'Display Datas' + '|||' + 'Mostrar Datos';


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

Langue.RELine = '#' + '|||' + '#' + '|||' + '#';
Langue.RELineSec = 'Numéro de ligne' + '|||' + 'Line number' + '|||' + 'Número de línea';
Langue.RECoords = 'Coords' + '|||' + 'Coords' + '|||' + 'Coords';
Langue.REPlayer = 'Joueur' + '|||' + 'Player' + '|||' + 'Jugador';
Langue.REAge = 'Age' + '|||' + 'Age' + '|||' + 'Antigüedad';
Langue.RETimeTravel = 'Voyage' + '|||' + 'Travel' + '|||' + 'Viaje';
Langue.RETimeTravelSec = 'Temps de voyage' + '|||' + 'Time travel' + '|||' + 'Tiempo de viaje';
Langue.RETimeTravelAR = 'Voyage A/R' + '|||' + 'Return trip' + '|||' + 'Ida y vuelta';
Langue.REMetal = 'Métal' + '|||' + 'Metal' + '|||' + 'Metal';
Langue.RECristal = 'Cristal' + '|||' + 'Crystal' + '|||' + 'Cristal';
Langue.REDeut = 'Deut' + '|||' + 'Deut' + '|||' + 'Deuterio';
Langue.RETotal = 'Total' + '|||' + 'Total' + '|||' + 'Total';
Langue.RELoot = 'Pillage' + '|||' + 'Profits' + '|||' + 'Beneficios';
Langue.RELootHour = 'Pillage/H' + '|||' + 'Profits/H' + '|||' + 'Beneficios/H';
Langue.RELootUSM = 'Pillage USM' + '|||' + 'Profits MSU' + '|||' + 'Beneficios uMe';
Langue.REButinRatio = 'Ratio' + '|||' + 'Ratio' + '|||' + 'Ratio';
Langue.REFlotte = 'Flotte' + '|||' + 'Fleet' + '|||' + 'Flota';
Langue.REDefense = 'Défense' + '|||' + 'Defense' + '|||' + 'Defensa';
Langue.RECDR = 'Champ de débris' + '|||' + 'Debris field' + '|||' + 'Escombros';
Langue.RatioCDRFlotte = 'Pourcentage CDR Flotte' + '|||' + 'Fleet Debris field ratio' + '|||' + 'Porcentaje de flota a escombros';
Langue.RatioCDRDefense = 'Pourcentage CDR Defense' + '|||' + 'Defense Debris field ratio' + '|||' + 'Porcentaje de defensa a escombros';
Langue.Recycleurs = 'Recycleurs nécessaires' + '|||' + 'Recyclers needed' + '|||' + 'Recicladores necesarios';
Langue.Simuler = 'Cliquer pour simuler' + '|||' + 'Click to simulate' + '|||' + 'Click para simular';
Langue.Sonder = 'Cliquer pour sonder' + '|||' + 'Click to spy' + '|||' + 'Click para espiar';
Langue.Recycler = 'Cliquer pour envoyer des recycleurs' + '|||' + 'Click to send recyclers' + '|||' + 'Click para enviar recicladores';
Langue.TempsTrajet_A = 'Trajet Aller' + '|||' + 'Travel time' + '|||' + 'Tiempo ida';
Langue.TempsTrajet_AR = 'Trajet Aller/Retour' + '|||' + 'Travel+Back time' + '|||' + 'Tiempo ida y vuelta';
Langue.HeureArrivee = 'Arrivée à' + '|||' + 'Arrives at' + '|||' + 'Hora de llegada';
Langue.HeureRetour = 'Retour à ' + '|||' + 'Back at' + '|||' + 'Hora de retorno';
Langue.Missiles = 'MIP' + '|||' + 'Missiles' + '|||' + 'Misiles';
Langue.Couts = 'Couts' + '|||' + 'Costs' + '|||' + 'Costes';
Langue.AfficherCorbeille = 'Afficher Corbeille' + '|||' + 'Display Trashbin' + '|||' + 'Mostrar Papelera';
Langue.AfficherUndelete = 'Annuler dernière suppression' + '|||' + 'Cancel last deletion' + '|||' + 'Cancelar último borrado';
Langue.SupprimerAtq = 'Supprimer toutes les cibles attaquées' + '|||' + 'Delete all attacked targets' + '|||' + 'Borrar objetivos atacados';
Langue.MetH = 'Mét/h' + '|||' + 'Met/h' + '|||' + 'Met/h';
Langue.CriH = 'Cri/h' + '|||' + 'Cry/h' + '|||' + 'Cri/h';
Langue.DeuH = 'Deut/h' + '|||' + 'Deut/h' + '|||' + 'Deut/h';
Langue.SupprimerVague_Debut = 'Supprimer les ' + '|||' + 'Delete the ' + '|||' + 'Borrar el ';
Langue.SupprimerVague_Fin = ' premières lignes' + '|||' + ' first lines' + '|||' + ' primeras líneas';


Langue.OptionsCouleurAA = 'Couleur lors du passage de la souris sur une ligne' + '|||' + 'Color when you put your mouse above spy reports lines' + '|||' + 'Color cuando pasas el raton sobre las líneas de espionaje';
Langue.OptionsCouleurAB = 'Couleur des boutons attaquer/recycler par défaut' + '|||' + 'Default attack/recycle buttons (not clicked)' + '|||' + 'Color por defecto (antes de clicar)';
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' + '|||' + 'Color de los botones de atacar/reciclar al pasar el ratónn por encima';
Langue.OptionsCouleurAD = 'Couleur des boutons attaquer/recycler lorsque l`on a cliqué dessus' + '|||' + 'Color of attack/recycle buttons when you clicked on it' + '|||' + 'Color de los botones de atacar/reciclar al clicarlos';
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' + '|||' + 'Color de los botones de atacar/reciclar al clicar y refrescar la página';
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' + '|||' + 'Color para cuando es rentable atacar con misiles';
Langue.OptionsCouleurAG = 'Couleur des boutons principaux lorsqu`ils sont exécutés' + '|||' + 'Main buttons color when executed' + '|||' + 'Color de los botones principales al ser ejecutados';
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' + '|||' + 'Color de los botones de cabecera cuando está ordenado de mayor a menor';
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' + '|||' + 'Color de los botones de cabecera cuando está ordenado de menor a mayor';
Langue.OptionsCouleurAJ = 'Couleur de fond 1' + '|||' + 'Background color 1' + '|||' + 'Color de fondo 1';
Langue.OptionsCouleurAK = 'Couleur de fond 2' + '|||' + 'Background color 2' + '|||' + 'Color de fondo 2';
Langue.OptionsCouleurAL = 'Lorsque la cible n`est pas dans la même galaxie que vous, colorier les coords en... ' + '|||' + 'When the target isn`t on the same galaxy than you, colorize coords in...' + '|||' + 'Color de las coordenadas cuando el objetivo está fuera de la galaxia';

Langue.OptionsColorierEn = 'colorier en' + '|||' + 'colorize in' + '|||' + 'colorear en';


Langue.OptionsTextesAA = 'Lorsque la renta dépasse' + '|||' + 'When profits are bigger than' + '|||' + 'Cuando los beneficios son superiores a';
Langue.OptionsTextesAB = 'Lorsque la renta USM dépasse' + '|||' + 'When profits MSU are bigger than' + '|||' + 'Cuando los beneficios uMe son superiores a';
Langue.OptionsTextesAC = 'Lorsque la flotte dépasse' + '|||' + 'When the fleet is bigger than' + '|||' + 'Cuando la flota es superior a';
Langue.OptionsTextesAD = 'Lorsque la défense dépasse' + '|||' + 'When the defense is bigger than' + '|||' + 'Cuando la defensa es superior a';
Langue.OptionsTextesAE = 'Lorsque l`âge du RE dépasse' + '|||' + 'When the spy report is older than' + '|||' + 'Cuando el reporte de espionaje es de hace más de';
Langue.OptionsTextesAF = 'Lorsque la renta d`une vague dépasse' + '|||' + 'When the wave profits are bigger than' + '|||' + 'Cuando los beneficios por oleada son superiores a';
Langue.OptionsTextesAG = 'Envoyer' + '|||' + 'Send' + '|||' + 'Envíar';
Langue.OptionsTextesAH = 'de flotte en plus que nécessaire. Incrémenter par heure : ' + '|||' + 'more ships than necessary. Increment each hour : ' + '|||' + 'más naves de las necesarias.  Incremento cada hora : ';
Langue.OptionsTextesAI = 'Ne pas afficher un RE si la flotte dépasse' + '|||' + 'Don`t display a spy report with a fleet bigger than' + '|||' + 'No mostrar reportes con flotas superiores a';
Langue.OptionsTextesAJ = 'Ne pas afficher un RE si la défense dépasse' + '|||' + 'Don`t display a spy report with a defense bigger than' + '|||' + 'No mostrar reportes con defensas superiores a';
Langue.OptionsTextesAK = 'Ne pas afficher un RE si son âge dépasse' + '|||' + 'Don`t display a spy report older than' + '|||' + 'No mostrar informes de hace más de';
Langue.OptionsTextesAL = 'heures' + '|||' + 'hours' + '|||' + 'horas';
Langue.OptionsTextesAM = 'Taux de commerce (Pour le taux USM)' + '|||' + 'Trade rates (for MSU)' + '|||' + 'Ratios de comercio (para uMe)';
Langue.OptionsTextesAP = 'Langue' + '|||' + 'Language' + '|||' + 'Idioma';
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)' + '|||' + 'Idioma (opciones manuales - se usarán cuando el lenguaje de tu juego no aparezca en la lista anterior)';
Langue.OptionsTextesAR = 'Indicateur milliards' + '|||' + 'Billions indicator' + '|||' + 'Indicador de millardos';
Langue.OptionsTextesAS = 'Indicateur millions' + '|||' + 'Millions indicator' + '|||' + 'Indicador de millones';
Langue.OptionsTextesAT = 'Indicateur milliers' + '|||' + 'Thousand indicator' + '|||' + 'Indicador de miles';
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)' + '|||' + 'Crear oleadas segundarias';
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' + '|||' + 'Crear oleadas secundarias cuando los geneficios sean superiores a';
Langue.OptionsTextesAW = 'Afficher le tableau récapitulatif des vagues' + '|||' + 'Display the information board' + '|||' + 'Muestra la tabla resumen';
Langue.OptionsTextesAX = 'Tableau récapitulatif : Nombre de slots par vague' + '|||' + 'Info Table : amount of slots per wave' + '|||' + 'Número de slots por oleada';
Langue.OptionsTextesAY = 'Afficher la ligne indiquant la Renta USM d`une vague' + '|||' + 'Info Table : display the line that shows MSU profits for each wave' + '|||' + 'Mostar beneficios uMe';
Langue.OptionsTextesAZ = 'Ouvrir les attaques et la vue galaxie dans un nouvel onglet' + '|||' + 'Open attacks and galaxy view in a new tab' + '|||' + 'Abrir los ataques y la vista de galaxias en una nueva pestaña';
Langue.OptionsTextesBA = 'Collecter automatiquement les Rapports d`espionnages' + '|||' + 'Automatically collect spy reports' + '|||' + 'Leer informes automáticamente';
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' + '|||' + 'Mostar la tabla automáticamente';
Langue.OptionsTextesBC = 'Affichage pour appareil mobile (en construction)' + '|||' + 'Mobile display style (under construction)' + '|||' + 'Interfaz para móviles (en construcción)';
Langue.OptionsTextesBD = 'de Métal valent' + '|||' + 'of Metal is equal to' + '|||' + 'de Metal es equivalente a';
Langue.OptionsTextesBE = 'de Cristal' + '|||' + 'of Crystal is equal to' + '|||' + 'de Cristal, que es equivalente a';
Langue.OptionsTextesBF = 'de Deut' + '|||' + 'of Deut' + '|||' + 'de Deuterio';
Langue.OptionsTextesBG = 'Taille du texte dans le tableau contenant les RE' + '|||' + 'Text size in spy reports board' + '|||' + 'Tamaño del texto en la tabla de reportes';
Langue.OptionsTextesBH = 'Lorsque la renta/heure dépasse' + '|||' + 'When profits/hour are bigger than' + '|||' + 'Cuando los beneficios/hora son superiores a';
Langue.OptionsTextesBI = 'Trier le tableau à partir de la colonne ' + '|||' + 'Sort the board by using column' + '|||' + 'Ordenar la tabla usando la columna';
Langue.OptionsTextesBJ = 'Cacher un RE si la renta est inférieure à ' + '|||' + 'Hide a spy report if profits are smaller than' + '|||' + 'Ocultar reportes con beneficios inferiores a';
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 ' + '|||' + 'Mostar reporte cuando es rentable envíar misiles (Beneficios ';
Langue.OptionsTextesBL = 'Secondes vagues : utiliser les ressources Standard' + '|||' + 'Secondary waves : use standard resources' + '|||' + 'Oleadas secundarias: usar recursos estándar';
Langue.OptionsTextesBM = 'Supprimer automatiquement la ligne après avoir cliqué sur attaquer' + '|||' + 'Automatically delete the line when attack button is clicked' + '|||' + 'Borrar línea automáticamente al clicar el botón de ataque';
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)' + '|||' + 'Reducir números (k, M, G)';
Langue.OptionsTextesBO = 'Afficher la ligne indiquant la Renta brute d`une vague' + '|||' + 'Display the line that shows profits for each wave' + '|||' + 'Mostar beneficios';
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' + '|||' + 'Mostrar naves necesarias';
Langue.OptionsTextesBQ = 'Afficher la ligne indiquant la renta moyenne par slot' + '|||' + 'Display the line that shows average profit per slot' + '|||' + 'Mostrar beneficios medios por slot';
Langue.OptionsTextesBR = 'Afficher la ligne indiquant la renta USM moyenne par slot' + '|||' + 'Display the line that shows average MSU profit per slot' + '|||' + 'Mostar beneficios uMe';
Langue.OptionsTextesBS = 'Afficher la ligne indiquant la renta par heure pour la vague' + '|||' + 'Display the line that shows profit per hour for the wave' + '|||' + 'Mostar beneficios por hora';
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' + '|||' + 'Mostar befenicios uMe por hora';
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' + '|||' + 'Mostar ratio beneficios uMe/beneficios brutos';
Langue.OptionsTextesBV = 'Lorsque la renta USM d`une vague dépasse' + '|||' + 'When the MSU wave profits are bigger than' + '|||' + 'Cuando los beneficios uMe son superiores a';
Langue.OptionsTextesBW = 'Lorsque la renta par heure d`une vague dépasse' + '|||' + 'When the wave profits per hour are bigger than' + '|||' + 'Cuando los beneficios son superiores a';
Langue.OptionsTextesBX = 'Lorsque la renta par heure USM d`une vague dépasse' + '|||' + 'When the MSU wave profits per hour are bigger than' + '|||' + 'Cuando los beneficios uMe por hora son superiores a';
Langue.OptionsTextesBY = 'Lorsque le ratio USM/Renta brut d`une vague dépasse' + '|||' + 'When the MSU vs Raw profits ratio is bigger than' + '|||' + 'Cuando el ratio beneficios uMe/beneficios brutos es superior a';
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' + '|||' + 'Mostar beneficios por hora y por slot';
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' + '|||' + 'Mostrar beneficios uMe por hora y slot';
Langue.OptionsTextesCB = 'Conserver uniquement les ' + '|||' + 'Display only the ' + '|||' + 'Mostar solo las';
Langue.OptionsTextesCC = ' premières lignes' + '|||' + ' first lines' + '|||' + 'primeras líneas';



Langue.OptionsCBoxAA = 'Afficher les n° de ligne à gauche' + '|||' + 'Display the left line number column' + '|||' + 'Mostar la columna de número de línea a la izquierda';
Langue.OptionsCBoxAB = 'Afficher les n° de ligne à droite' + '|||' + 'Display the right line number column' + '|||' + 'Mostar la columna de número de línea a la derecha';
Langue.OptionsCBoxAC = 'Afficher les coordonnées' + '|||' + 'Display the coordinates column' + '|||' + 'Mostrar columna de coordenadas';
Langue.OptionsCBoxAD = 'Afficher le métal à piller' + '|||' + 'Display the metal profits column' + '|||' + 'Mostrar columna de saqueo de metal';
Langue.OptionsCBoxAE = 'Afficher le cristal à piller' + '|||' + 'Display the crystal profits column' + '|||' + 'Mostrar columna de saqueo de cristal';
Langue.OptionsCBoxAF = 'Afficher le deutérium à piller' + '|||' + 'Display the deuterium profits column' + '|||' + 'Mostrar columna de saqueo de deuterio';
Langue.OptionsCBoxAG = 'Afficher le total des ressources présent sur le RE' + '|||' + 'Display the column containing the total amount of resources inside the RE' + '|||' + 'Mostrar columna de recursos totales';
Langue.OptionsCBoxAH = 'Afficher le ratio de butin' + '|||' + 'Display the profit ratio column' + '|||' + 'Mostrar columna de ratio de saqueo';
Langue.OptionsCBoxAI = 'Afficher la flotte' + '|||' + 'Display the fleet column' + '|||' + 'Mostrar columna de flota';
Langue.OptionsCBoxAJ = 'Afficher la défense' + '|||' + 'Display the defense column' + '|||' + 'Mostrar columna de defensas';
Langue.OptionsCBoxAK = 'Afficher la quantité de ressources à piller' + '|||' + 'Display the profit column' + '|||' + 'Mostrar columna de beneficios';
Langue.OptionsCBoxAL = 'Afficher la quantité de ressources à piller en USM' + '|||' + 'Display the MSU profit column' + '|||' + 'Mostrar columna de beneficios uMe';
Langue.OptionsCBoxAM = 'Afficher le pseudo des joueurs' + '|||' + 'Display the player name column' + '|||' + 'Mostrar columna de nombre de jugador';
Langue.OptionsCBoxAN = 'Afficher les boutons PT' + '|||' + 'Display the light cargo buttons' + '|||' + 'Mostrar columna de Naves Pequeñas de Carga (NPC)';
Langue.OptionsCBoxAO = 'Afficher les boutons GT' + '|||' + 'Display the heavy cargo buttons' + '|||' + 'Mostrar columna de Naves Grandes de Carga (NGC)';
Langue.OptionsCBoxAP = 'Afficher l`âge du RE (Affichage abrégé :' + '|||' + 'Display spy report Age column (Reduced informations : ' + '|||' + 'Mostrar columna de Antigüedad (Información reducida:';
Langue.OptionsCBoxAQ = 'Afficher le bouton supprimer' + '|||' + 'Display the delete buttons' + '|||' + 'Mostrar botones de borrado';
Langue.OptionsCBoxAR = 'Afficher le bouton plus de détails' + '|||' + 'Display the button "More details"' + '|||' + 'Mostrar botón de más detalles';
Langue.OptionsCBoxAS = 'Afficher le bouton Recycleurs' + '|||' + 'Display the Recycle button' + '|||' + 'Mostrar botón de reciclar';
Langue.OptionsCBoxAT = 'Afficher la colonne temps de trajet' + '|||' + 'Display travel time column' + '|||' + 'Mostrar columna de tiempo de vuelo';
Langue.OptionsCBoxAU = 'Afficher la colonne heure d`arrivée' + '|||' + 'Display the arrival time column' + '|||' + 'Mostrar columna de tiempo de llegada';
Langue.OptionsCBoxAV = 'Afficher la colonne heure de retour' + '|||' + 'Display the back time column' + '|||' + 'Mostrar columna de tiempo de regreso';
Langue.OptionsCBoxAW = 'Afficher la colonne Renta/Heure' + '|||' + 'Display the Profits/Hour column' + '|||' + 'Mostrar columna de Beneficios/Hora';
Langue.OptionsCBoxAX = 'Afficher la colonne Nombre de MIP' + '|||' + 'Display the amount of missiles column' + '|||' + 'Mostrar columna de cantidad de misiles';
//ES done with Deepl translator
Langue.OptionsCBoxAY = 'Afficher la ligne indiquant la renta de métal par heure (choisir PT/GT et Std/USM à la colonne renta/h)' + '|||' + 'Display metal per hour column (choose SC/LC, Std/MSU on the profit/h column)' + '|||' + 'Visualizar la línea que indica el alquiler de metal por hora (seleccione NPC/NGT y Estándar/uMe en la columna de alquiler/h).';
Langue.OptionsCBoxAZ = 'Afficher la ligne indiquant la renta de cristal par heure (choisir PT/GT et Std/USM à la colonne renta/h)' + '|||' + 'Display crystal per hour column (choose SC/LC, Std/MSU on the profit/h column)' + '|||' + 'Visualizar la línea que indica el alquiler de cristal por hora (seleccione NPC/NGT y Estándar/uMe en la columna de alquiler/h).';
Langue.OptionsCBoxBA = 'Afficher la ligne indiquant la renta de deut par heure (choisir PT/GT et Std/USM à la colonne renta/h)' + '|||' + 'Display deut per hour column (choose SC/LC, Std/MSU on the profit/h column)' + '|||' + 'Visualizar la línea que indica el alquiler de deuterio por hora (seleccione NPC/NGT y Estándar/uMe en la columna de alquiler/h).';
Langue.OptionsCBoxBB = 'Afficher les boutons pour piller à la sonde' + '|||' + 'Display the probe looting button' + '|||' + 'Mostrar los botones para el saqueo con la sonda';
Langue.OptionsCBoxBC = 'Afficher les boutons pour piller aux Eclaireurs' + '|||' + 'Display the Pathfinder looting button' + '|||' + 'Mostrar los botones para saquear el Explorador';
Langue.OptionsCBoxBD = 'Afficher les boutons pour attaquer sans flotte préselectionnée' + '|||' + 'Display the button to attack without any pre-selected fleet' + '|||' + 'Mostrar botones para atacar sin una flota preseleccionada';


Langue.OptionsTechsAA = 'Réacteur à combustion' + '|||' + 'Combustion drive' + '|||' + 'Motor de combustión';
Langue.OptionsTechsAB = 'Réacteur à impulsion' + '|||' + 'Impulse drive' + '|||' + 'Motor de impulso';
Langue.OptionsTechsAC = 'Propulsion hyperespace' + '|||' + 'Hyperespace drive' + '|||' + 'Propulsor hiperespacial';
Langue.OptionsTechsAD = 'Flotte : Pourcentage CDR de l`uni' + '|||' + 'Fleet : Debrits field percent' + '|||' + 'Flota: porcentaje de flota a escombros';
Langue.OptionsTechsAE = 'Defense : Pourcentage CDR de l`uni' + '|||' + 'Defense : Debrits field percent' + '|||' + 'Defensa: porcentaje de defensa a escombros';
Langue.OptionsTechsAF = 'Technologie Armes' + '|||' + 'Weapons Technology' + '|||' + 'Tecnología militar';
Langue.OptionsTechsAG = 'Technologie Bouclier' + '|||' + 'Shielding Technology' + '|||' + 'Tecnología de defensa';
Langue.OptionsTechsAH = 'Technologie Protection des vaisseaux spatiaux' + '|||' + 'Armour Technology' + '|||' + 'Tecnología de blindaje';
Langue.OptionsTechsAI = 'Nombre de systèmes solaires par galaxie' + '|||' + 'Amount of solar systems per galaxies' + '|||' + 'Sistemas solares por galaxia';
Langue.OptionsTechsAJ = 'Nombre de galaxies dans l`univers' + '|||' + 'Amount of galaxies in this universe' + '|||' + 'Galaxias en el universo';
Langue.OptionsTechsAK = 'Page Recherche : Collecter automatiquement les recherches' + '|||' + 'Research Page : Automatically collect researches' + '|||' + 'Leer tecnologías de la página de investigación automáticamente';
Langue.OptionsTechsAL = 'Technologie hyperespace' + '|||' + 'Hyperespace Technology' + '|||' + 'Tecnología hiperespacial';
Langue.OptionsTechsAM = 'Capacité de fret des sondes (sans technologie hyperespace)' + '|||' + 'Cargo capacity of probes (without hyperespace technology)' + '|||' + 'Capacidad de carga de la sonda (sin tecnología hiperespacial)';
Langue.OptionsTechsAN = 'Nombre de sondes pour l`espionnage' + '|||' + 'Amount of spy probes when spying' + '|||' + 'Cantidad de sondas de espionaje al espiar';

Langue.OptionsMainAA = 'Options de couleurs' + '|||' + 'Color options' + '|||' + 'Opciones de Color';
Langue.OptionsMainAB = 'Sauvegarder' + '|||' + 'Save' + '|||' + 'Guardar';
Langue.OptionsMainAC = 'Affichage des colonnes' + '|||' + 'Table columns' + '|||' + 'Columnas de la Tabla';
Langue.OptionsMainAD = 'Options globales' + '|||' + 'Global options' + '|||' + 'Opciones Globales';
Langue.OptionsMainAE = 'Technologies du compte & Paramètres de l`univers' + '|||' + 'Account Techs and Universe Settings' + '|||' + 'Tecnologías y Ajustes del Universo';
Langue.OptionsMainAF = 'Tableau récapitulatif' + '|||' + 'Summary table' + '|||' + 'Tabla Resumen';

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

Langue.Aller = 'aller' + '|||' + 'travel' + '|||' + 'Ida';
Langue.AllerRetour = 'aller/retour' + '|||' + 'travel and back' + '|||' + 'Ida y vuelta';
Langue.PT = 'PT' + '|||' + 'SC' + '|||' + 'NPC';
Langue.GT = 'GT' + '|||' + 'LC' + '|||' + 'NGC';
Langue.RC = 'RC' + '|||' + 'RC' + '|||' + 'Rec';
Langue.Sonde = 'S' + '|||' + 'P' + '|||' + 'S';
Langue.SondeLong = 'Sonde' + '|||' + 'Probe' + '|||' + 'Sonda';
Langue.Eclaireur = 'E' + '|||' + 'P' + '|||' + 'E';
Langue.EclaireurLong =  'Eclaireur' + '|||' + 'Pathfinder' + '|||' + 'Explorador';
Langue.Milliard = 'Md' + '|||' + 'Bn' + '|||' + 'G';
Langue.Million = 'M' + '|||' + 'M' + '|||' + 'M';
Langue.Milliers = 'K' + '|||' + 'K' + '|||' + 'k';
Langue.Brut = 'Standard' + '|||' + 'Standard' + '|||' + 'Estándar';
Langue.Ressource = 'Ress' + '|||' + 'Res' + '|||' + 'Recursos';
Langue.RessourceCDR = 'Ress+CDR' + '|||' + 'Res+DF' + '|||' + 'Recursos+Def';
Langue.USM = 'USM' + '|||' + 'MSU' + '|||' + 'uMe';
Langue.Version = 'O-Table Version' + '|||' + 'O-Table Version' + '|||' + 'Versión O-Table';

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)' + '|||' + 'El número de misiles se obtiene mediante una simulación que toma el valor de la defensa en lugar de los puntos estructurales (este valor no se muestra en el resúmen del informe). El número de misiles calculado de este modo es un 5% mayor de lo necesario (ha sido probado con 75 defensas distintas). Para resultados más precisos, se recomienda utilizar un simulador de misiles. Tecnologías utilizadas: 0/0/0 vs 0/0/0 (Las tecnologías no se muestran en los espionajes poco profundos)';
Langue.TableauCouleurExplainedAA = 'Colorie uniqment la renta brute et la renta par slot' + '|||' + 'Only colorizes raw profits and profits per slot' + '|||' + 'Colorear únicamente beneficios brutos y beneficios por slot';
Langue.TableauCouleurExplainedAB = 'Colorie uniqment la renta USM et la renta par slot USM' + '|||' + 'Only colorizes MSU profits and MSU profits per slot' + '|||' + 'Colorear únicamente beneficios uMe y beneficios uMe por 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' + '|||' + 'Colorear únicamente beneficios por hora y beneficios medios por hora y slot';
Langue.TableauCouleurExplainedAD = 'Colorie uniqment la renta par heure USM et la renta par heure moyenne USM par slot' + '|||' + 'Only colorizes MSU profits per hour and average MSU profits per hour per slot' + '|||' + 'Colorear únicamente beneficios uMe por hora y beneficios uMe por hora y slot';



//NEW PART -- translation ES done with Deepl translator
Langue.OptionsProfilAA = 'Profils' + '|||' + 'Profiles' + '|||' + 'Perfiles';
Langue.OptionsProfilAB = 'Créer nouveau profil' + '|||' + 'Create new profile' + '|||' + 'Crear un nuevo perfil';
Langue.OptionsProfilAC = 'Modifier nom' + '|||' + 'Modify name' + '|||' + 'Modificar nombre';
Langue.OptionsProfilAD = 'General' + '|||' + 'General' + '|||' + 'General';
Langue.OptionsProfilAE = 'Supprimer profil' + '|||' + 'Delete profile' + '|||' + 'Borrar perfil';
Langue.OptionsProfilAF = 'Nouveau profil' + '|||' + 'New profile' + '|||' + 'Nuevo perfil';
Langue.OptionsProfilAG = 'Annuler modification' + '|||' + 'Cancel modification' + '|||' + 'Cancelar modificación';
Langue.OptionsProfilAH = 'Valider' + '|||' + 'Valider' + '|||' + 'Validar';


Langue.OptionsTextesCD = 'Activer la protection contre les suppressions accidentelles' + '|||' + 'Enable inadvertent delete protection' + '|||' + 'Habilitar la protección contra el borrado accidental';
Langue.BoutonViderProtected = 'Réappuyer...' + '|||' + 'Press again...' + '|||' + 'Respaldo';
Langue.BoutonViderOK = 'Vidé !' + '|||' + 'Cleared !' + '|||' + 'Vacío!';
Langue.BoutonViderFailed = 'Echec' + '|||' + 'Failed' + '|||' + 'Fracaso';
Langue.OptionsCouleurAL = 'Lorsque la cible est située à au moins' + '|||' + 'When the target is located at least ' + '|||' + 'Cuando el objetivo está localizado al menos';
Langue.OptionsCouleurAM = 'galaxies, colorier les coords en... ' + '|||' + 'galaxies, colorize coords in...' + '|||' + 'galaxias, colorea las coordenadas en...';
Langue.OptionsCouleurAN = 'systèmes solaires, colorier les coords en... ' + '|||' + 'solar systems, colorize coords in...' + '|||' + 'sistemas solares, colorear las coord en...';
Langue.OptionsCouleurAO = 'Si le temps de vol aller retour dépasse' + '|||' + 'If the round voyage takes more than' + '|||' + 'Cuando el viaje de ida y vuelta toma más de';
Langue.OptionsCouleurAP = 'minutes, mettre le temps de trajet en cette couleur' + '|||' + 'minutes, put the trip time in this color' + '|||' + 'minutos, pon el tiempo de viaje en este color';


Langue.OptionsTextesCE = 'Bouton + : définir le nombre de lignes à supprimer en une seule fois' + '|||' + '+ Button : determine amount of lines to delete at once' + '|||' + 'Tecla +: definir el número de líneas a borrar a la vez'; //Deepl



Langue.QuickFilter = 'Filtres rapides' + '|||' + 'Quick Filter' + '|||' + 'Filtros rápidos';
Langue.QuickFilterAge = 'Masquer si âge >' + '|||' + 'Hide if age >' + '|||' + 'Ocultar si la edad >';
//'note : Langue.OptionsTextesAL is used for "hours" word '
Langue.QuickFilterDef = 'Défense max = ' + '|||' + 'Maximum defence =' + '|||' + 'Defensa máxima = ';
Langue.QuickFilterFlotte = 'Flotte max = ' + '|||' + 'Maximum fleet = ' + '|||' + 'Flota máxima = ';
Langue.QuickFilterRentaMin = 'Renta mini = ' + '|||' + 'Minimum profits =' + '|||' + 'Rendimiento mínimo = ';
Langue.QuickFilterStd = 'Standard' + '|||' + 'Standard' + '|||' + 'Estándar';
Langue.QuickFilterUSM = 'USM' + '|||' + 'MSU' + '|||' + 'uMe';
Langue.QuickFilterRes = 'Ressources ' + '|||' + 'Resources' + '|||' + 'Recursos';
Langue.QuickFilterResCDR = 'Ressources & CDR' + '|||' + 'Resources & DF' + '|||' + 'Recursos&Def';
Langue.QuickFilterQtéFlt = 'Qté de % de flotte suppl. =' + '|||' + '% of additional fleet Qty' + '|||' + 'Cantidad de % de flota adicional';
Langue.QuickFilterCurGala = 'Aff. galaxie courante seulement' + '|||' + 'Only show current galaxy' + '|||' + 'Sólo visualización de la galaxia actual';
Langue.QuickFilterGalaxies = 'Afficher galaxies : ' + '|||' + 'Display galaxies :' + '|||' + 'Mostrar galaxias: ';
Langue.QuickFilterAll = 'Toutes' + '|||' + 'All' + '|||' + 'Todos ellos';
Langue.QuickFilterTrashbin = 'Afficher les éléments de la corbeille et les indiquer en rouge' + '|||' + 'Display trashbin lines and indicate them in red' + '|||' + 'Mostrar los elementos de la papelera de reciclaje e indicarlos en rojo';
Langue.QuickFilterHidden = 'Afficher les éléments masqués automatiquement et les indiquer en blanc' + '|||' + 'Display automatically hidden lines and indicate them in white' + '|||' + 'Mostrar elementos ocultos automáticamente e indicarlos en blanco';
Langue.QuickFilterHiddenTITLE = 'ATTENTION : Les galaxies non cochées et le nombre de lignes affichées sont toujours prises en considération' + '|||' + 'ATTENTION : Not checked galaxies and max lines displayed are still taken in consideration' + '|||' + 'ATENCIÓN: Las galaxias no marcadas y el número de líneas mostradas siempre se tienen en cuenta.';
Langue.QuickFilterMaxLines = 'Nombre de lignes max' + '|||' + 'Max lines amount = ' + '|||' + 'Número máximo de líneas';
Langue.QuickFilterSave = 'Sauvegarder ces options en tant qu`options par défaut' + '|||' + 'Save these options as default settings' + '|||' + 'Guarde estas opciones como opciones predeterminadas';
Langue.QuickFilterProfile = 'Utiliser le profil suivant : ' + '|||' + 'Use profile : ' + '|||' + 'Utilice el siguiente perfil: ';
Langue.QuickFilterAdvanced = 'Afficher uniquement les lignes où ' + '|||' + 'Only show lines where ' + '|||' + 'Visualizar sólo las líneas en las que ';
Langue.QuickFilterIs = ' est ' + '|||' + ' is ' + '|||' + ' es ';
Langue.QuickFilterInferieur = ' inférieur à ' + '|||' + ' lower than ' + '|||' + ' menos de ';
Langue.QuickFilterInferieurEgal = ' inférieur ou égal à ' + '|||' + ' lower or equal than ' + '|||' + ' menor o igual que ';
Langue.QuickFilterSuperieur = ' supérieur à ' + '|||' + ' greather than ' + '|||' + ' mayor que ';
Langue.QuickFilterSuperieurEgal = ' supérieur ou égal à ' + '|||' + ' greather or equal than ' + '|||' + ' mayor que o igual a ';
Langue.QuickFilterEgal = ' égal à ' + '|||' + ' equal to ' + '|||' + ' igual a ';
Langue.QuickFilterDifferent = ' différent de ' + '|||' + ' different than ' + '|||' + ' diferente de ';
Langue.QuickFilterHelpTh = 'Aide pour le filtrage avancé' + '|||' + 'Advanced filter help' + '|||' + 'Ayuda para el filtrado avanzado';
Langue.QuickFilterHelpFormat = 'Format valable pour les colonnes ' + '|||' + 'Format used for columns ' + '|||' + 'Formato válido para columnas ';
Langue.QuickFilterHelpDecimale = 'Utiliser une valeur décimale, en s`inspirant de l`exemple suivant : 1984487' + '|||' + 'Use a decimal value, see this example : 1984487' + '|||' + 'Utilice un valor decimal, utilizando el siguiente ejemplo: 1984487';
Langue.QuickFilterHelpCoord = 'Format pour la colonne coordonnées ' + '|||' + "Format for coordinate column " + '|||' + 'Formato para la columna de coordenadas ';
Langue.QuickFilterHelpCoordFormat = 'Entrer une coordonnée, par exemple 9:300:12 ou 1:000:00.' + '|||' + "Use a coordinate, like 9:300:12 or 1:000:00." + '|||' + 'Introduzca una coordenada, por ejemplo 9:300:12 o 1:000:00.';
Langue.QuickFilterHelpPseudo = 'Format de la colonne des pseudos' + '|||' + 'Format used for nicknames column' + '|||' + 'Formato de la columna de apodos';
Langue.QuickFilterHelpPseudoFormat = 'Respecter la casse (ex : PsEuDo ou Joueur_1337)' + '|||' + 'Case sensitive (e. g. PsEuDo or Player_1337)' + '|||' + 'Respetar el caso (ej: PsEuDo o Player_1337)';
Langue.QuickFilterHelpDuree = 'Format des durée utilisé pour les colonnes ' + '|||' + 'Time format used for columns ' + '|||' + 'Formato de tiempo utilizado para las columnas ';
Langue.QuickFilterHelpDureeFormat = 'Respecter le format suivant (ex : 1h 53m 03s ou 40m 00s ou bien 1h 00m 00s (PAS 40m tout court)). Note : vous pouvez utiliser que des secondes si vous le voulez (ex : 3600s). N`oubliez pas de rajouter un espace entre chaque valeur (1h00m00s ne marchera pas)' + '|||' + "Respect the following format (ex: 1h 53m 03s or 40m 00s or 1h 00m 00s -- NOT only 40m). Note : you can use seconds if you want (ex : 3600s). Don`t forget spaces between values (1h00m00s doesn`t work)" + '|||' + 'Respete el siguiente formato (por ejemplo: 1h 53m 03s o 40m 00s o 1h 00m 00s (NO 40m)). Nota: sólo puede utilizar los segundos si lo desea (por ejemplo, 3600s). No olvide añadir un espacio entre cada valor (1h00m00s no funcionará)';
Langue.QuickFilterHelpHeure = 'Format des heures valable pour les colonnes ' + '|||' + 'Clock format used for columns ' + '|||' + 'Formato de hora válido para columnas ';
Langue.QuickFilterHelpHeureFormat = 'Respecter le format suivant (ex : 31.10.2018 21:34:43).' + '|||' + "Respect the following format (ex: 31.10.2018 21:34:43)." + '|||' + 'Tenga en cuenta el siguiente formato (por ejemplo, 31.10.2018 21:34:43).';
//Langue.QuickFilterHelpError = 'En cas d`erreur de format, le bouton "Afficher tableau" devient de couleur rouge.' + '|||' + "In case of format error, the Show table button becomes red";

Langue.LeftButtonAA = ' Activer la gestion des RE' + '|||' + 'Enable SR management' + '|||' + 'Habilitar la gestión de informes de espías';
Langue.LeftButtonAB = ' Activer la gestion des RC' + '|||' + 'Enable CR management' + '|||' + 'Habilitar la gestión de informes de combate';

//Es translation by Deepl translator
Langue.RCAA = 'Date' + '|||' + 'Date' + '|||' + 'Fecha';
Langue.RCAB = 'Metal' + '|||' + 'Metal' + '|||' + 'Metal';
Langue.RCAC = 'Cristal' + '|||' + 'Crystal' + '|||' + 'Cristal';
Langue.RCAD = 'Deut' + '|||' + 'Deut' + '|||' + 'Deut';
Langue.RCAE = 'Renta' + '|||' + 'Profits' + '|||' + 'Benef';
Langue.RCAF = 'Renta USM' + '|||' + 'MSU Profits' + '|||' + 'uMe Benef';
Langue.RCAG = 'Dégats' + '|||' + 'Damages' + '|||' + 'Daños';
Langue.RCAH = 'Pertes' + '|||' + 'Loss' + '|||' + 'Pérdidas';
Langue.RCAI = 'CDR' + '|||' + 'DF' + '|||' + 'Escombros';
Langue.RCAJ = 'Coord' + '|||' + 'Coord' + '|||' + 'Coord';
Langue.RCAK = 'Nb RC' + '|||' + 'RC Amnt' + '|||' + 'RC Amnt'; //Problème traduction
Langue.RCAL = 'Renta Actifs' + '|||' + 'Profits from act. players' + '|||' + 'Rentabilidad de los jugadores activos';//Problème traduction
Langue.RCAM = 'Renta Inactifs' + '|||' + 'Profits from inact. players' + '|||' + 'Retorno de los jugadores inactivos'; //Problème traduction
Langue.RCAN = 'CDR Collecté par vous' + '|||' + 'DF Collected by you' + '|||' + 'Escombros recogidos por usted'; //Traduction
Langue.RCAO = 'Age' + '|||' + 'Age' + '|||' + 'Antigüedad';
Langue.RCAP = 'Attaquant' + '|||' + 'Attacker' + '|||' + 'Adelante';
Langue.RCAQ = 'Défenseur' + '|||' + 'Defender' + '|||' + 'Defensor';
Langue.RCAR = 'Pertes Atk' + '|||' + 'Atk Loss' + '|||' + 'Ade Pérdidas';
Langue.RCAS = 'Pertes Def' + '|||' + 'Def Loss' + '|||' + 'Def Pérdidas';
Langue.RCAT = 'Pillage' + '|||' + 'Loot' + '|||' + 'Pillaje';
Langue.RCAU = 'Pillage USM' + '|||' + 'MSU Loot' + '|||' + 'uMe Pillaje';
Langue.RCAV = 'CDR Atk' + '|||' + 'Atk DF' + '|||' + 'Ade Escombros';
Langue.RCAW = 'CDR Def' + '|||' + 'Def DF' + '|||' + 'Def Escombros';
Langue.RCAX = 'Gains Def' + '|||' + 'Def Profits' + '|||' + 'Def Gan';
Langue.RCAY = 'Pertes Attaquant : ' + '|||' + 'Attacker Loss : ' + '|||' + 'Adlantee Pérdidas : ';
Langue.RCAZ = 'Pertes Défenseur : ' + '|||' + 'Defender Loss' + '|||' + 'Defensor Pérdidas';
Langue.RCBA = 'Valeur CDR obtenue par l`attaquant : ' + '|||' + 'DF Obtained by attacker : ' + '|||' + 'Valor de escombros obtenido por el atacante: ';
Langue.RCBB = 'Valeur CDR obtenue par le défenseur : ' + '|||' + 'DF Obtained by defender : ' + '|||' + 'Valor de escombros obtenido por el defensor: ';
Langue.RCBC = 'Votre position dans le RC : ' + '|||' + 'Your position in the CR : ' + '|||' + 'Su posición en el informe de combate: ';
Langue.RCBD = 'Ressources pillées, Métal : ' + '|||' + 'Looted resources, Metal : ' + '|||' + 'Recursos saqueados, Metal: ';
Langue.RCBE = 'Statut du joueur : ' + '|||' + 'Target Status' + '|||' + 'Estado del objetivo: ';
Langue.RCBF = 'Enregistrer Modifications' + '|||' + 'Save Datas' + '|||' + 'Guardar modificaciones';
Langue.RCBG = 'Afficher le récapitulatif total' + '|||' + 'Display total summary' + '|||' + 'Mostrar resumen total';
Langue.RCBH = 'Afficher la liste des RCs' + '|||' + 'Display CR list' + '|||' + 'Visualizar lista de informes de combate';
Langue.RCBI = 'Afficher la renta par coord' + '|||' + 'Display profits per coord' + '|||' + 'Visualizar los beneficios por coordenada';
Langue.RCBJ = 'Afficher le tableau récapitulatif journalier' + '|||' + 'Display daily summary table' + '|||' + 'Mostrar la tabla de resumen diario';
Langue.RCBK = 'Afficher le tableau récapitulatif hebdomadaire' + '|||' + 'Display weekly summary table' + '|||' + 'Visualizar la tabla de resumen semanal';
Langue.RCBL = 'Semaine' + '|||' + 'Week' + '|||' + 'Semana';
Langue.RCBM = 'Gains Atk' + '|||' + 'Atk Profits' + '|||' + 'Ade Gan';
Langue.RCBN = 'EFFACER DONNEES' + '|||' + 'ERASE DATAS' + '|||' + 'ELIMINAR DATOS';
Langue.RCBO = 'Sur les tableaux par date : ' + '|||' + 'On dates tables : ' + '|||' + 'En las mesas por fecha: ';
Langue.RCBP = 'Afficher les rentas sur actifs' + '|||' + 'Display profits on active targets' + '|||' + 'Visualizar los beneficios de los objetivos activos';
Langue.RCBQ = 'Afficher les rentas sur inactifs' + '|||' + 'Display profits on inactive targets' + '|||' + 'Visualizar los beneficios de los objetivos inactivos';
Langue.RCBR = 'Afficher les rentas totales' + '|||' + 'Display total profits' + '|||' + 'Visualizar los beneficios totales';
Langue.RCBS = 'Pillage' + '|||' + 'Loot' + '|||' + 'Pillaje';
Langue.RCBT = 'Import/Export' + '|||' + 'Import/Export' + '|||' + 'Importación/Exportación';
Langue.RCBU = 'Import' + '|||' + 'Import' + '|||' + 'Importación';
Langue.RCBV = 'Export' + '|||' + 'Export' + '|||' + 'Exportación';
Langue.RCBW = 'Importer données du champ texte' + '|||' + 'Import datas from text field' + '|||' + 'Importar datos del campo de texto';
Langue.RCBX = 'Exporter données dans le champ texte' + '|||' + 'Export datas into text field' + '|||' + 'Exportar datos al campo de texto';


//////////////////////////////////////////////////////////////////////////////////////////////////////
//AUTOCOLLECTS RESEARCH FROM RESEARCH PAGE////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
function research_page(){
    var MetaLocal = MetaDatas();
    var ProfileUsed = GetData('ProfileUsed','', 'Profile1'); //Default value is "Profile1"
    if (GetData(ProfileUsed, 'column30', true) === false) {
        console.log("[O-Table] : User selected to not auto collect researches")
    } else {

        var Combustion = parseInt(document.querySelector(".combustionDriveTechnology").querySelector(".level").textContent.replace(/[^0-9.]/g, "")); //Get level and removes everything except numbers
        var Impulsion = parseInt(document.querySelector(".impulseDriveTechnology").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Prop_Hyp = parseInt(document.querySelector(".hyperspaceDriveTechnology").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Weapons = parseInt(document.querySelector(".weaponsTechnology").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Shields = parseInt(document.querySelector(".shieldingTechnology").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Armour = parseInt(document.querySelector(".armorTechnology").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        var Tech_Hyp = parseInt(document.querySelector(".hyperspaceTechnology").querySelector(".level").textContent.replace(/[^0-9.]/g, ""));
        console.log("[O-Table] : Combustion :_" + Combustion + "_- Impulsion :_" + Impulsion + "_- Prop :_" + Prop_Hyp + '_- Tech Hyp :_' + Tech_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(ProfileUsed + ':text14' +  MetaLocal.Universe, Combustion);
        GM_setValue(ProfileUsed + ':text15' +  MetaLocal.Universe, Impulsion);
        GM_setValue(ProfileUsed + ':text16' +  MetaLocal.Universe, Prop_Hyp);
        GM_setValue(ProfileUsed + ':text22' +  MetaLocal.Universe, Weapons);
        GM_setValue(ProfileUsed + ':text23' +  MetaLocal.Universe, Shields);
        GM_setValue(ProfileUsed + ':text24' +  MetaLocal.Universe, Armour);
        GM_setValue(ProfileUsed + ':text36' +  MetaLocal.Universe, Tech_Hyp);

    }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
//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)
    try {
        if (GetData('General', 'OnOffOtable', "OTableEnabled") == "OTableEnabled") { //Checks if user wants to display O-Table
            //Spy reports part
            var IDsToDisplay = Determine_UiId(Detect_Market());
            if (document.querySelector(IDsToDisplay[0]).getAttribute("aria-hidden") == "false") {
                if (GetData('General', 'OtableManageSRBtn', "OTableEnabled") == "OTableEnabled") { //Checks if user wants to display SR Part of O-Table
                    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
                    } else {
                        try {
                            Display();
                        } catch(err){
                            console.log("[O-Table] : main buttons not displayed, retrying...");
                        }
                    }
                } else {
                    DisableSRPart();
                }
            }
            //Combat reports part
            if (document.querySelector(IDsToDisplay[1]).getAttribute("aria-hidden") == "false") {
                if (GetData('General', 'OtableManageCRBtn', "OTableEnabled") == "OTableEnabled") { //Checks if user wants to display SR Part of O-Table
                    if (document.getElementById("RCDisplayTable")) { //checks if AfficherTableau button is already displayed
                    } else {
                        try {
                            RCButton();
                        } catch(err){
                            console.log("[O-Table] : main buttons not displayed, retrying...");
                        }
                    }
                } else {
                    DisableCRPart();
                }
            }
        } else { //Removes the script if user clicks on the disable SR Button
            DisableSRPart();
            DisableCRPart();
        }
    } catch(err) {
    }
    function DisableSRPart() {
        var Buttons = document.querySelector(".OTableInit");
        if(Buttons.outerHTML) {
            Buttons.outerHTML = "";
        }

    }
    function DisableCRPart() {
        var Buttons = document.querySelector(".OTableRCInit");
        if(Buttons.outerHTML) {
            Buttons.outerHTML = "";
        }
    }
}

function Detect_Market()
{
    var MarketPresence = false;
    if (document.querySelector("#tabs-nfMarket")) {
        //alert(document.querySelector("#tabs-nfMarket"));
        MarketPresence = true;
    }
    return MarketPresence;
}

function Determine_UiId(MarketPresence)
{
    var UiIDs = new Array('#ui-id-16', '#ui-id-18')
    if (MarketPresence === false) {
        UiIDs[0] = '#ui-id-14';
        UiIDs[1] = '#ui-id-16';
    }
    return UiIDs;
}


//Fonction pour générer le bouton O-Table du menu de gauche
//Function used to generate O-Table Left Button
function CallLeftButton()
{
    //Getting options part
    var SRManageValue = GetData('General', 'OtableManageSRBtn', "OTableEnabled");
    var CRManageValue = GetData('General', 'OtableManageCRBtn', "OTableEnabled");
    var IsOtableEnabled = GetData('General', 'OnOffOtable', "OTableEnabled");
    //CSS Part
    //3 colors (SR, CR, Otable)
    GM_addStyle("span[value=OTableEnabled]:hover, span[value=OTableDisabled]:hover, a[value=OTableEnabled]:hover, a[value=OTableDisabled]:hover{ color : #FFFFFF !important;}"); //bord du tableau
    GM_addStyle("a[value=OTableEnabled], span[value=OTableEnabled] { color : #33BB33;  } "); //bord du tableau
    GM_addStyle("a[value=OTableDisabled], span[value=OTableDisabled] { color : #FF8800;  } "); //bord du tableau
    //Generating HTML Code
    var LeftButton = '<span class="menu_icon" id="OnOffOtable" value="' + IsOtableEnabled + '"><a class="OtableLeftLogo"></a></span>' +
        '<a id="affOptionsOTable" class="menubutton tooltipRight tooltipClose" href="index.php?page=messages" title="<a id=OtableManageSRBtn value=' + SRManageValue + '>' + Langue.LeftButtonAA.split("|||")[LangueIndexGlb] + '</a><br/><a id=OtableManageCRBtn value=' + CRManageValue + '>' + Langue.LeftButtonAB.split("|||")[LangueIndexGlb] + '</a>"><span id="OTableLeftButton" class="textlabel"  >O-Table</span></a>'
    var LeftButtonHTML = document.createElement("li");
    LeftButtonHTML.innerHTML = LeftButton;
    LeftButtonHTML.id = 'OptionsOTable';
    //Displaying HTML Code
    document.getElementById('menuTableTools').appendChild(LeftButtonHTML);//
    //Javascript
    document.querySelector('#OnOffOtable').addEventListener("click", ManageLeftOptions);
    document.querySelector('#affOptionsOTable').addEventListener("mouseover", function(event)
                                                                 {
        console.log("[O-Table] : Left Button has been asked");
        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 ActivateSRButton = document.querySelector("#OtableManageSRBtn");
            var ActivateCRButton = document.querySelector("#OtableManageCRBtn");
            try {
                ActivateSRButton.addEventListener("click", ManageLeftOptions);
                ActivateCRButton.addEventListener("click", ManageLeftOptions);
            } catch(err) {
            }
        }, 300); // end of settimeout*/
    }, true);
    function ManageLeftOptions() {
        var MetaLocal = MetaDatas();
        if (this.getAttribute("value") === "OTableEnabled") {
            this.setAttribute("value", "OTableDisabled");
        } else if (this.getAttribute("value") === "OTableDisabled") {
            this.setAttribute("value", "OTableEnabled");
        }
        //alert(this.getAttribute("value"));
        GM_setValue('General:' + this.id +  MetaLocal.Universe, this.getAttribute("value"));
    }
}

//Checks if current page is research and launch a function
if (CurrentURL.search("research") >= 0) {
    console.log("[O-Table] : Current Page is research");
    CallLeftButton();
    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");
    CallLeftButton();
    var Affiche_Script = setInterval(affiche_script, 100);
}



//Checks if current page is fleetdispatch and launch a function
if (CurrentURL.search("fleetdispatch") >= 0) {
    try {
    var ShipAmount = CurrentURL.split('&am')[1].split('=')[1];
    var ShipType = CurrentURL.split('&am')[1].split('=')[0];
    switch (ShipType) {
        case "202" :
            var ShipName = "transporterSmall";
            break;
        case "203" :
            var ShipName = "transporterLarge";
            break;
        case "210":
            var ShipName = "espionageProbe";
            break;
        case "209" :
            var ShipName = "recycler";
            break;
        case "219" :
            var ShipName = "explorer";
            break;
        default:

    }

        console.log("[O-Table] : Current Page is fleetdispatch");


        let element = document.querySelector("input[name='" + ShipName + "']");
        element.value = ShipAmount;
        element.focus();

    } catch(err) {
    }
}