From 6d545df2a8a336d8ef3983c983929dbe0f7d4246 Mon Sep 17 00:00:00 2001 From: haunter Date: Mon, 20 Apr 2026 15:59:41 +0300 Subject: [PATCH] time and cost add --- GrepolisRemoteControl.user.js | 5 ++-- static/js/components/commandForm.js | 39 ++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js index 0d52b8c..00a8e37 100644 --- a/GrepolisRemoteControl.user.js +++ b/GrepolisRemoteControl.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Grepolis Remote Control // @namespace http://tampermonkey.net/ -// @version 1.5 +// @version 1.6 // @description Polls grepo.haunter-pets.top for remote commands and executes them in-game // @author Dimitrios // @match https://*.grepolis.com/game/* @@ -106,7 +106,8 @@ wood: buildDataRaw[k].resources_for?.wood || 0, stone: buildDataRaw[k].resources_for?.stone || 0, iron: buildDataRaw[k].resources_for?.iron || 0, - pop: buildDataRaw[k].population_for || 0 + pop: buildDataRaw[k].population_for || 0, + build_time: buildDataRaw[k].build_time || 0 }; } } catch (e) { diff --git a/static/js/components/commandForm.js b/static/js/components/commandForm.js index 0a75765..9a660e1 100644 --- a/static/js/components/commandForm.js +++ b/static/js/components/commandForm.js @@ -14,15 +14,52 @@ window.renderBuildingDropdown = function() { if (!town) return; const bSelect = document.getElementById('building-select'); const bLevels = town.buildings || {}; + const bData = town.build_data || {}; const currentVal = bSelect.value; bSelect.innerHTML = ''; + + // Helper to format seconds -> "1h 30m" or "4m 15s" + const formatTime = (secs) => { + if (!secs) return ''; + const h = Math.floor(secs / 3600); + const m = Math.floor((secs % 3600) / 60); + const s = secs % 60; + if (h > 0) return `${h}h ${m}m`; + if (m > 0) return `${m}m ${s}s`; + return `${s}s`; + }; for (const [key, nameGr] of Object.entries(window.BUILDING_NAMES_GR)) { const level = bLevels[key] !== undefined ? bLevels[key] : "?"; + const data = bData[key]; + + let text = `${nameGr} [Επίπεδο ${level}]`; + let buildable = true; + + if (data) { + const w = window.fmt(data.wood || 0); + const st = window.fmt(data.stone || 0); + const i = window.fmt(data.iron || 0); + const t = formatTime(data.build_time); + buildable = data.buildable; + + // Only show costs if the prerequisites are fulfilled and it's not max level + if (data.dependencies) { + text += ` — Ξ:${w} Π:${st} Α:${i} · ⏱ ${t}`; + } else { + text += ` — (Μη διαθέσιμο)`; + } + } + const option = document.createElement('option'); option.value = key; - option.textContent = `${nameGr} [Επίπεδο ${level}]`; + option.textContent = (!buildable && data?.dependencies) ? `❌ ${text}` : text; + + if (!buildable) { + option.style.color = '#aa5555'; + } + bSelect.appendChild(option); }