Raw Source
KreK93 / Lifeform Suggestions

// ==UserScript==
// @name         Lifeform Suggestions
// @namespace    none
// @version      2024-10-10
// @description  Give you red if missing minimum level, orange: continue to upgrade, green: not usefull to continue upgrade.
// @author       KreK00
// @match        https://*.ogame.gameforge.com/game/index.php*component=lfbuildings*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAADNVJREFUWEeFl3l0lOd1h5/vm2/20YyW0a5BOwhJICSBJMQaloDs+hhwIN4xNrZp7DiL28T1GgqO6/rYTnpiO/WC6ybUC4upjQ1eMEg2QgK0gSQktG+j0TIazT6a7eupepymTZPec+5f7x/3ue97znt+j8BfqIULV6YTVdcImrhqSWMqAmGBIBKv1JhUCrUehVqLQlQQlaNIGi1Eo0Hv7PQMCMMKUeyQA+76cDh4qu3Cb8f+3Bjh/zoozy+vlGXNo2FZuTMiSAhKNZI6hrAcRZ+QiVofC4ICUZJQajSo9DpEjQo5EmV2eprw3ByiLBPyOBGRicqhI9GQ98Wmb15v/N/z/gSgZFHlAWVU8aQgaIiKOgRJQlQokZRqVLpYVAYzSlMCalMsKqMBSaOab4VKIhIOEnB78cy4CM+FsPVdR6fRoBQh5JklEgwcbGx846k/hvgfAFnF1W9pg9F7NYIGpUKPQqFBOb+9FqXRjBSVQW0gLj0HrdmMyqRHZdShVkSR+6YIhCSEzDhkKYJ72jkP4puaYtY6gNfnxRRjQpaDh2rPvHjftxB/AEgt2Xog6pp6MlarRSMr0Yox6HUmtLpYfL4wqeZkQkqJiMZIRnYeCr0BQ5IJg0mLo3kAb1hDfvYC2sec5K9KxDExhWvKhdNqo7/5G1bnm1HFxPN1txW/e+xgQ8M78zcxDzA97ay8MDjZ8MTjz2JrbyHJFEeSMY3chcUM29zkpqexuWIZn9RdYUZSU1a4BIM5FoVRxZwYZPraBC6vAnNSPhEgzaJnenqcgNPG5JiV3o4uMkwhnIE5gpEIHp8dj1pVdeXs643zAFc+/fqD+I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UxWJ5jjMyYkEfD40ajXJyWbOnr2Iy+NnRXkBSeZYDv3+83kLCs55+ezUedLT0/Do4vD4Q+gk4eBQw19Qsz88R+Gtlcqw+9GgSrPT6ffhkkXSUxMIzgWRlWpMGhG3Zw4Z8Lq9CAhIaiUGvQ5BEIk1abnWNYjf68VsjiOo1B3xBaMv2jvf+//l9I/FMSFjQ7oANVFZUR0IBYuQhQWCUh1PeE4ViUTmAVQqFaIgEJVlBFEMCoIwIwkMK5VSR9AfqNfF6E6NXj/5Z/X8PwB9mJ71rH8+6wAAAABJRU5ErkJggg==
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_xmlhttpRequest
// @require      https://code.jquery.com/jquery-3.7.1.min.js
// @license      MIT
// @updateURL    https://openuserjs.org/meta/KreK93/Lifeform_Upgrade_Suggestions.meta.js
// @downloadURL  https://openuserjs.org/install/KreK93/Lifeform_Upgrade_Suggestions.user.js
// ==/UserScript==

/* ----------------------------------- [ DISCLAIMER ] -------------------------------------- */
/* THIS TOOL HAS NOT BEEN PUBLISHED ON OGAME ORIGIN YET, SO TECHNICALLY IT IS ILLEGAL TO USE */
/* ------------------------------- [ USE AT YOUR OWN RISK ] --------------------------------- */

/* [ Based on RiV work ] */

(function () {
  'use strict';

  window.addEventListener('load', function () {
    var quarters = ""
    var farm = ""
    var school = ""
    var highschool = ""
    // SEARCH TYPE OF LIFEFORM
    const header = document.querySelector('header[data-anchor="technologyDetails"]');
    const backgroundStyle = header.style.background;
    const urlMatch = backgroundStyle.match(/url\(['"]?(.*?)['"]?\)/);
    if (urlMatch) {
      const imageUrl = urlMatch[1];
      const fileName = imageUrl.split('/').pop();
      const nameWithoutExtension = fileName.split('.')[0];

      // ROCKTAL
      if (nameWithoutExtension === "rocktal") {
        document.querySelector("div[id=technologies]").querySelector("h3").innerText += " - Rock`tal";

        if (document.querySelector(".icons")) {
          const iconItems = document.querySelector(".icons").getElementsByTagName("li");

          if (iconItems.length > 0) {
            const levels = {
              quarters: {
                element: iconItems[0].querySelector(".level"),
                max: 74
              },
              farm: {
                element: iconItems[1].querySelector(".level"),
                max: 78
              },
              school: {
                element: iconItems[3].querySelector(".level"),
                max: 16
              },
              highSchool: {
                element: iconItems[4].querySelector(".level"),
                max: 11
              },
              megalith: {
                element: iconItems[7].querySelector(".level"),
                max: 10
              },
              MRC: {
                element: iconItems[10].querySelector(".level"),
                max: 5
              }
            };

            // Funzione per impostare i valori massimi e aggiornare il display
            const updateLevelDisplay = (levelKey) => {
              const level = levels[levelKey];
              const currentLevel = parseInt(level.element.innerText);

              // Crea un nuovo elemento span per il massimo
              const maxSpan = document.createElement("span");
              maxSpan.style.color = "#9285df";
              maxSpan.style.fontWeight = "bold";

              // Aggiorna il display
              if (currentLevel >= level.max) {
                level.element.style.color = "green"; // Colore verde per livello massimo
                level.element.style.fontWeight = "bold";
                maxSpan.style.display = "none";
              }
              else {
                level.element.style.color = "#3486eb"; // Colore blu
                maxSpan.textContent = ` (${level.max})`; // Mostra livello massimo
              }

              // Append maxSpan all'elemento del livello
              level.element.appendChild(maxSpan);
            };

            // Aggiorna i livelli per tutte le strutture
            Object.keys(levels).forEach(updateLevelDisplay);
          }
        }
      }
      else if (nameWithoutExtension == "humans") {
        document.querySelector("div[id=technologies]").querySelector("h3").innerText += " - Humans"
        if (document.querySelector(".icons")) {
          const iconItems = document.querySelector(".icons").getElementsByTagName("li");
          if (iconItems.length > 0) {
            const levels = {
              quarters: {
                element: iconItems[0].querySelector(".level"),
                max: 74
              },
              farm: {
                element: iconItems[1].querySelector(".level"),
                max: 68
              },
              school: {
                element: iconItems[3].querySelector(".level"),
                max: 15
              },
              highSchool: {
                element: iconItems[4].querySelector(".level"),
                max: 10
              },
              food: {
                element: iconItems[6].querySelector(".level"),
                max: 42
              },
              skyscraper: {
                element: iconItems[8].querySelector(".level"),
                max: 28
              },
              biolab: {
                element: iconItems[9].querySelector(".level"),
                max: 27
              }
            };

            // Funzione per impostare i valori massimi e aggiornare il display
            const updateLevelDisplay = (levelKey) => {
              const level = levels[levelKey];
              const currentLevel = parseInt(level.element.innerText);

              // Crea un nuovo elemento span per il massimo
              const maxSpan = document.createElement("span");
              maxSpan.style.color = "#9285df";
              maxSpan.style.fontWeight = "bold";

              // Aggiorna il display
              if (currentLevel >= level.max) {
                level.element.style.color = "green"; // Colore verde per livello massimo
                level.element.style.fontWeight = "bold";
                maxSpan.style.display = "none";
              }
              else {
                level.element.style.color = "#3486eb"; // Colore blu
                maxSpan.textContent = ` (${level.max})`; // Mostra livello massimo
              }

              // Append maxSpan all'elemento del livello
              level.element.appendChild(maxSpan);
            };

            // Aggiorna i livelli per tutte le strutture
            Object.keys(levels).forEach(updateLevelDisplay);
          }
        }
      }
      else if (nameWithoutExtension == "mecha") {
        document.querySelector("div[id=technologies]").querySelector("h3").innerText += " - Mecha"
        if (document.querySelector(".icons")) {
          const iconItems = document.querySelector(".icons").getElementsByTagName("li");
          if (iconItems.length > 0) {
            const levels = {
              quarters: {
                element: iconItems[0].querySelector(".level"),
                max: 72
              },
              farm: {
                element: iconItems[1].querySelector(".level"),
                max: 83
              },
              school: {
                element: iconItems[3].querySelector(".level"),
                max: 14
              },
              highSchool: {
                element: iconItems[4].querySelector(".level"),
                max: 9
              },
              micro: {
                element: iconItems[7].querySelector(".level"),
                max: 30
              },
              PAH: {
                element: iconItems[8].querySelector(".level"),
                max: 22
              },
            };

            // Funzione per impostare i valori massimi e aggiornare il display
            const updateLevelDisplay = (levelKey) => {
              const level = levels[levelKey];
              const currentLevel = parseInt(level.element.innerText);

              // Crea un nuovo elemento span per il massimo
              const maxSpan = document.createElement("span");
              maxSpan.style.color = "#9285df";
              maxSpan.style.fontWeight = "bold";

              // Aggiorna il display
              if (currentLevel >= level.max) {
                level.element.style.color = "green"; // Colore verde per livello massimo
                level.element.style.fontWeight = "bold";
                maxSpan.style.display = "none";
              }
              else {
                level.element.style.color = "#3486eb"; // Colore blu
                maxSpan.textContent = ` (${level.max})`; // Mostra livello massimo
              }

              // Append maxSpan all'elemento del livello
              level.element.appendChild(maxSpan);
            };

            // Aggiorna i livelli per tutte le strutture
            Object.keys(levels).forEach(updateLevelDisplay);
          }
        }
      }
      else if (nameWithoutExtension == "kaelesh") {
        document.querySelector("div[id=technologies]").querySelector("h3").innerText += " - Kaelesh"
        if (document.querySelector(".icons")) {
          const iconItems = document.querySelector(".icons").getElementsByTagName("li");
          if (iconItems.length > 0) {
            const levels = {
              quarters: {
                element: iconItems[0].querySelector(".level"),
                max: 72
              },
              farm: {
                element: iconItems[1].querySelector(".level"),
                max: 74
              },
              school: {
                element: iconItems[3].querySelector(".level"),
                max: 13
              },
              highSchool: {
                element: iconItems[4].querySelector(".level"),
                max: 9
              },
              antimatter: {
                element: iconItems[5].querySelector(".level"),
                max: 22
              },
              Chrysalis: {
                element: iconItems[7].querySelector(".level"),
                max: 40
              },
              Psionic: {
                element: iconItems[9].querySelector(".level"),
                max: 11
              }
            };

            // Funzione per impostare i valori massimi e aggiornare il display
            const updateLevelDisplay = (levelKey) => {
              const level = levels[levelKey];
              const currentLevel = parseInt(level.element.innerText);

              // Crea un nuovo elemento span per il massimo
              const maxSpan = document.createElement("span");
              maxSpan.style.color = "#9285df";
              maxSpan.style.fontWeight = "bold";

              // Aggiorna il display
              if (currentLevel >= level.max) {
                level.element.style.color = "green"; // Colore verde per livello massimo
                level.element.style.fontWeight = "bold";
                maxSpan.style.display = "none";
              }
              else {
                level.element.style.color = "#3486eb"; // Colore blu
                maxSpan.textContent = ` (${level.max})`; // Mostra livello massimo
              }

              // Append maxSpan all'elemento del livello
              level.element.appendChild(maxSpan);
            };

            // Aggiorna i livelli per tutte le strutture
            Object.keys(levels).forEach(updateLevelDisplay);
          }
        }
      }
    }
    else {
      console.log("[LifeformStyle] unable to get LF data.");
    }
  }, false);
})();