major update to client/faster
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Grepolis Remote Control
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 3.1
|
||||
// @version 3.2
|
||||
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player)
|
||||
// @author Dimitrios
|
||||
// @match https://*.grepolis.com/game/*
|
||||
@@ -294,6 +294,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// AJAX Interceptor for Zero-Delay Push
|
||||
// ----------------------------------------------------------------
|
||||
let pushTimeout = null;
|
||||
function debouncedPushState() {
|
||||
if (paused) return;
|
||||
if (pushTimeout) clearTimeout(pushTimeout);
|
||||
pushTimeout = setTimeout(() => {
|
||||
log('⚡ State change detected (AJAX). Syncing to Remote...');
|
||||
pushState();
|
||||
}, 1200); // Wait 1.2s for memory models to update after AJAX finishes
|
||||
}
|
||||
|
||||
if (uw.$) {
|
||||
uw.$(document).ajaxComplete(function (e, xhr, opt) {
|
||||
if (!opt || !opt.url) return;
|
||||
|
||||
// Ignore requests to our own bot server or map data
|
||||
if (opt.url.includes(BASE_URL)) return;
|
||||
if (opt.url.includes('map_tiles')) return;
|
||||
|
||||
// Most game actions use "action=" parameter
|
||||
// Switching towns uses "switch_town"
|
||||
if (opt.url.includes('action=') || opt.url.includes('switch_town')) {
|
||||
debouncedPushState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Report command result back to relay
|
||||
// ----------------------------------------------------------------
|
||||
@@ -527,9 +556,10 @@
|
||||
// Start captcha watcher immediately
|
||||
detectCaptcha();
|
||||
|
||||
// Push state once after load, then every 45–90 seconds (randomized)
|
||||
// Push state once after load, then heartbeat every 1-2 minutes
|
||||
// The AJAX interceptor handles the real-time syncing!
|
||||
setTimeout(pushState, 5000);
|
||||
jitterLoop(pushState, 45000, 90000);
|
||||
jitterLoop(pushState, 60000, 120000);
|
||||
|
||||
// Poll for commands every 8–18 seconds (randomized jitter)
|
||||
jitterLoop(pollAndExecute, 8000, 18000);
|
||||
|
||||
Reference in New Issue
Block a user