enchance dropdown

This commit is contained in:
2026-04-20 19:02:04 +03:00
parent 9b5656fac5
commit 69d56f621b
2 changed files with 36 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Grepolis Remote Control // @name Grepolis Remote Control
// @namespace http://tampermonkey.net/ // @namespace http://tampermonkey.net/
// @version 1.8 // @version 1.9
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game // @description Polls grepo.haunter-pets.top for remote commands and executes them in-game
// @author Dimitrios // @author Dimitrios
// @match https://*.grepolis.com/game/* // @match https://*.grepolis.com/game/*
@@ -107,7 +107,10 @@
stone: buildDataRaw[k].resources_for?.stone || 0, stone: buildDataRaw[k].resources_for?.stone || 0,
iron: buildDataRaw[k].resources_for?.iron || 0, iron: buildDataRaw[k].resources_for?.iron || 0,
pop: buildDataRaw[k].population_for || 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) { } catch (e) {

View File

@@ -25,22 +25,44 @@ window.renderBuildingDropdown = function() {
let text = `${nameGr} [Επίπεδο ${level}]`; let text = `${nameGr} [Επίπεδο ${level}]`;
if (data && data.dependencies) { if (data) {
const w = window.fmt(data.wood || 0); const w = window.fmt(data.wood || 0);
const st = window.fmt(data.stone || 0); const st = window.fmt(data.stone || 0);
const i = window.fmt(data.iron || 0); const i = window.fmt(data.iron || 0);
const pop = data.pop || 0;
let t = data.build_time || ''; let t = data.build_time || '';
if (t.startsWith('00:')) t = t.substring(3); // make '00:06:00' cleaner as '06:00' if (t.startsWith('00:')) t = t.substring(3); // make '00:06:00' cleaner as '06:00'
// Only show costs if the prerequisites are fulfilled const popStr = pop > 0 ? ` 🧔:${pop} ` : ' ';
text += `Ξ:${w} Π:${st} Α:${i} · ⏱ ${t}`; const costStr = `Ξ:${w} Π:${st} Α:${i}${popStr}· ⏱ ${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)) { if (currentVal && Array.from(bSelect.options).some(o => o.value === currentVal)) {