diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js index 8f8a847..c3a088e 100644 --- a/GrepolisRemoteControl.user.js +++ b/GrepolisRemoteControl.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Grepolis Remote Control // @namespace http://tampermonkey.net/ -// @version 2.8 +// @version 2.9 // @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player) // @author Dimitrios // @match https://*.grepolis.com/game/* @@ -163,7 +163,7 @@ const marketLevel = buildings.market ?? 0; const gd = uw.GameData?.buildingData?.market; marketCapacity = gd?.capacity_per_level?.[marketLevel] || 0; - + // Add Trade Office bonus if present if (buildings.trade_office && buildings.trade_office > 0) { marketCapacity += (uw.GameData?.buildingData?.trade_office?.capacity_extra_per_level || 500) * marketLevel; @@ -193,13 +193,13 @@ let unitDataMap = {}; try { const gdUnits = uw.GameData?.units || {}; - + for (const u in gdUnits) { if (u === 'militia') continue; - + const reqBuildings = gdUnits[u].building_dependencies || {}; const reqResearch = gdUnits[u].research_dependencies || []; - + let missing_deps = {}; for (const reqB in reqBuildings) { if ((buildings[reqB] || 0) < reqBuildings[reqB]) { @@ -211,15 +211,15 @@ missing_deps[reqR] = { name: reqR, needed_level: 'Έρευνα' }; } } - + const cost = gdUnits[u].resources || {}; const w = cost.wood || 0; const s = cost.stone || 0; const i = cost.iron || 0; - + let enough = true; if (res.wood < w || res.stone < s || res.iron < i) enough = false; - + unitDataMap[u] = { wood: w, stone: s, @@ -316,7 +316,7 @@ setInterval(() => { const win = document.getElementById('hcaptcha_window'); let isVisible = false; - + if (win) { // Check if it's actually visible on screen (not display: none by the game) const style = window.getComputedStyle(win); @@ -324,14 +324,14 @@ isVisible = true; } } - + if (isVisible && !captchaActive) { captchaActive = true; paused = true; const label = document.getElementById('grc_label'); - const btn = document.getElementById('grc_btn'); + const btn = document.getElementById('grc_btn'); if (label) label.textContent = '⚠ CAPTCHA'; - if (btn) btn.style.filter = 'brightness(70%) sepia(100%) hue-rotate(300deg) saturate(1000%) contrast(0.8)'; + if (btn) btn.style.filter = 'brightness(70%) sepia(100%) hue-rotate(300deg) saturate(1000%) contrast(0.8)'; log('⚠ CAPTCHA detected — bot paused, alerting server'); reportCaptcha(true); } else if (!isVisible && captchaActive) { @@ -478,9 +478,9 @@ } // Build queue, Recruit queue and Market queue are independent - const buildCmd = cmdData.build; + const buildCmd = cmdData.build; const recruitCmd = cmdData.recruit; - const marketCmd = cmdData.market; + const marketCmd = cmdData.market; if (cmdData.sync_requested) { log('Sync requested by server — pushing state immediately'); @@ -492,7 +492,7 @@ log(`Executing command #${cmd.id} — type:${cmd.type} town:${cmd.town_id}`); let result; try { - if (cmd.type === 'build') result = await executeBuild(cmd); + if (cmd.type === 'build') result = await executeBuild(cmd); else if (cmd.type === 'recruit') result = await executeRecruit(cmd); else if (cmd.type === 'market_offer') result = await executeMarketOffer(cmd); else result = { ok: false, msg: `Unknown type: ${cmd.type}` };