From 69d56f621b1b1fa86035f029c41e0a73b5062ba9 Mon Sep 17 00:00:00 2001 From: haunter Date: Mon, 20 Apr 2026 19:02:04 +0300 Subject: [PATCH] enchance dropdown --- GrepolisRemoteControl.user.js | 7 +++-- static/js/components/commandForm.js | 40 ++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js index bb55f87..95da23b 100644 --- a/GrepolisRemoteControl.user.js +++ b/GrepolisRemoteControl.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Grepolis Remote Control // @namespace http://tampermonkey.net/ -// @version 1.8 +// @version 1.9 // @description Polls grepo.haunter-pets.top for remote commands and executes them in-game // @author Dimitrios // @match https://*.grepolis.com/game/* @@ -107,7 +107,10 @@ stone: buildDataRaw[k].resources_for?.stone || 0, iron: buildDataRaw[k].resources_for?.iron || 0, pop: buildDataRaw[k].population_for || 0, - build_time: buildDataRaw[k].building_time || '' + build_time: buildDataRaw[k].building_time || '', + can_upgrade: !!buildDataRaw[k].can_upgrade, + enough_resources: !!buildDataRaw[k].enough_resources, + missing_dependencies: buildDataRaw[k].missing_dependencies || [] }; } } catch (e) { diff --git a/static/js/components/commandForm.js b/static/js/components/commandForm.js index 8b659e1..3ba11ed 100644 --- a/static/js/components/commandForm.js +++ b/static/js/components/commandForm.js @@ -25,22 +25,44 @@ window.renderBuildingDropdown = function() { let text = `${nameGr} [Επίπεδο ${level}]`; - if (data && data.dependencies) { + if (data) { const w = window.fmt(data.wood || 0); const st = window.fmt(data.stone || 0); const i = window.fmt(data.iron || 0); + const pop = data.pop || 0; let t = data.build_time || ''; if (t.startsWith('00:')) t = t.substring(3); // make '00:06:00' cleaner as '06:00' + + const popStr = pop > 0 ? ` 🧔:${pop} ` : ' '; + const costStr = `Ξ:${w} Π:${st} Α:${i}${popStr}· ⏱ ${t}`; - // Only show costs if the prerequisites are fulfilled - text += ` — Ξ:${w} Π:${st} Α:${i} · ⏱ ${t}`; + // Figure out the state + const isLocked = (!data.dependencies) || (data.missing_dependencies && data.missing_dependencies.length > 0); + + const option = document.createElement('option'); + option.value = key; + + if (isLocked) { + option.textContent = `${text} — 🔒 Κλειδωμένο (Προϋποθέσεις)`; + option.style.color = '#777777'; + } else if (data.can_upgrade === true) { + option.textContent = `${text} — ✅ ${costStr}`; + } else if (data.enough_resources === false) { + option.textContent = `${text} — ❌ ${costStr} (Λείπουν Πόροι)`; + option.style.color = '#aa5555'; + } else { + // can_upgrade is false, but resources are fine = Population limit or Queue full + option.textContent = `${text} — ⚠️ ${costStr} (Πληθυσμός / Ουρά)`; + option.style.color = '#aa8855'; + } + + bSelect.appendChild(option); + } else { + const option = document.createElement('option'); + option.value = key; + option.textContent = text; + bSelect.appendChild(option); } - - const option = document.createElement('option'); - option.value = key; - option.textContent = text; - - bSelect.appendChild(option); } if (currentVal && Array.from(bSelect.options).some(o => o.value === currentVal)) {