From a5d57d55fc7baf85ef3cb426cce5bc93a21f87af Mon Sep 17 00:00:00 2001 From: haunter Date: Sun, 26 Apr 2026 13:01:58 +0300 Subject: [PATCH] MJ: fix 1 --- bot_modules/05_main.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bot_modules/05_main.js b/bot_modules/05_main.js index a2d3206..d5af506 100644 --- a/bot_modules/05_main.js +++ b/bot_modules/05_main.js @@ -124,14 +124,22 @@ async function pollAndExecute() { } // ---------------------------------------------------------------- -// Boot +// Boot — works whether page is already loaded or not. +// When eval()'d dynamically the 'load' event has already fired, +// so we check readyState and boot immediately in that case. // ---------------------------------------------------------------- -window.addEventListener('load', () => { +function boot() { log('Grepolis Remote Control v4.0.0 (remote) loaded'); - detectCaptcha(); - setTimeout(pushState, 5000); jitterLoop(pushState, 60000, 120000); jitterLoop(pollAndExecute, 8000, 18000); -}); +} + +if (document.readyState === 'complete') { + // Page already loaded (normal case when eval()'d dynamically) + boot(); +} else { + // Fallback: wait for load event (shouldn't happen but safe to keep) + window.addEventListener('load', boot); +}