This commit is contained in:
2026-04-26 13:55:25 +03:00
parent a8b3e9f5ea
commit 5bff9a287d
5 changed files with 42 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name Grepolis Remote Loader
// @namespace http://tampermonkey.net/
// @version 4.0.0
// @version 4.0.1
// @description Dynamically loads the Grepolis Remote Control bot from the server
// @author Dimitrios
// @match https://*.grepolis.com/game/*
@@ -15,37 +15,48 @@
(function() {
'use strict';
// Set to your VPS domain
const BASE_URL = 'https://grepo.haunter-pets.top';
const BASE_URL = 'https://grepo.haunter-pets.top';
const MAX_TRIES = 3;
const RETRY_BASE = 3000; // 3 s, then 6 s
function loadBot(attempt) {
attempt = attempt || 1;
console.log(`[Loader] Fetching bot code (attempt ${attempt}/${MAX_TRIES})...`);
function loadBot() {
console.log('[Loader] Fetching bot code from server...');
GM_xmlhttpRequest({
method: 'GET',
url: `${BASE_URL}/api/bot?t=${Date.now()}`,
onload: function(response) {
if (response.status === 200) {
console.log('[Loader] Bot code downloaded successfully! Executing...');
console.log('[Loader] Bot code downloaded. Executing...');
try {
eval(response.responseText);
} catch (e) {
console.error('[Loader] Error executing bot code:', e);
console.error('[Loader] Execution error:', e);
}
} else if (attempt < MAX_TRIES) {
const delay = RETRY_BASE * attempt;
console.warn(`[Loader] Server returned ${response.status}. Retrying in ${delay / 1000}s...`);
setTimeout(() => loadBot(attempt + 1), delay);
} else {
console.error('[Loader] Failed to download bot. Server returned:', response.status);
console.error(`[Loader] Failed after ${MAX_TRIES} attempts (status ${response.status}). Give up.`);
}
},
onerror: function(err) {
console.error('[Loader] Connection error while trying to reach the server.', err);
onerror: function() {
if (attempt < MAX_TRIES) {
const delay = RETRY_BASE * attempt;
console.warn(`[Loader] Connection error. Retrying in ${delay / 1000}s...`);
setTimeout(() => loadBot(attempt + 1), delay);
} else {
console.error(`[Loader] Failed after ${MAX_TRIES} attempts. Check your server.`);
}
}
});
}
// Wait for page to be ready before loading the heavy bot logic
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadBot);
document.addEventListener('DOMContentLoaded', () => loadBot(1));
} else {
loadBot();
loadBot(1);
}
})();