fix of fix(version)

This commit is contained in:
2026-04-23 23:14:23 +03:00
parent 3652b361e7
commit e2e75876ac

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name Grepolis Remote Control
// @namespace http://tampermonkey.net/
// @version 3.5
// @version 3.5.5
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player)
// @author Dimitrios
// @match https://*.grepolis.com/game/*
@@ -90,10 +90,10 @@
const pm = uw.MM.getModels().Player[player_id];
if (pm && pm.attributes) alliance_name = pm.attributes.alliance_name;
console.log("GrepoRemote: Extracted alliance_name =", alliance_name);
} catch(e) {
} catch (e) {
console.log("GrepoRemote: Failed to extract alliance_name", e);
}
const total_points = uw.Game?.player_points ?? 0;
const world = uw.Game?.world_id || '';
@@ -245,7 +245,7 @@
let farms = [];
try {
const farmCollection = uw.MM.getOnlyCollectionByName('FarmTown');
const relCollection = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation');
const relCollection = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation');
if (farmCollection && relCollection) {
const ix = town.getIslandCoordinateX?.();
const iy = town.getIslandCoordinateY?.();
@@ -255,13 +255,13 @@
if (rel.attributes.farm_town_id === farm.attributes.id &&
rel.attributes.relation_status >= 0) {
farms.push({
farm_town_id: farm.attributes.id,
farm_name: farm.attributes.name || '',
relation_id: rel.id,
farm_town_id: farm.attributes.id,
farm_name: farm.attributes.name || '',
relation_id: rel.id,
relation_status: rel.attributes.relation_status,
expansion_stage: rel.attributes.expansion_stage || 0,
expansion_at: rel.attributes.expansion_at || 0,
lootable_at: rel.attributes.lootable_at || 0
expansion_at: rel.attributes.expansion_at || 0,
lootable_at: rel.attributes.lootable_at || 0
});
}
});
@@ -338,11 +338,11 @@
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')) {
@@ -424,7 +424,7 @@
let farmModels, relModels;
try {
farmModels = uw.MM.getOnlyCollectionByName('FarmTown')?.models;
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
} catch (e) {
return { ok: false, msg: `Cannot access farm collections: ${e.message}` };
}
@@ -450,8 +450,8 @@
let upgraded = 0;
let unlocked = 0;
let skipped = 0;
let errors = 0;
let skipped = 0;
let errors = 0;
for (const town_id of polisList) {
const town = uw.ITowns?.towns?.[town_id];
@@ -467,8 +467,8 @@
if (rel.attributes.farm_town_id !== farm.attributes.id) continue;
const status = rel.attributes.relation_status;
const level = rel.attributes.expansion_stage || 0;
const expAt = rel.attributes.expansion_at || 0;
const level = rel.attributes.expansion_stage || 0;
const expAt = rel.attributes.expansion_at || 0;
// Skip if upgrade already in progress
if (expAt > now) { skipped++; continue; }
@@ -488,9 +488,9 @@
log(`Farm ${action}: farm_id=${farm.attributes.id} level=${level} town=${town_id}`);
try {
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
model_url: `FarmTownPlayerRelation/${rel.id}`,
model_url: `FarmTownPlayerRelation/${rel.id}`,
action_name: action,
arguments: { farm_town_id: farm.attributes.id },
arguments: { farm_town_id: farm.attributes.id },
town_id
});
isLocked ? unlocked++ : upgraded++;
@@ -521,7 +521,7 @@
let farmModels, relModels;
try {
farmModels = uw.MM.getOnlyCollectionByName('FarmTown')?.models;
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
} catch (e) {
return { ok: false, msg: `Cannot access farm collections: ${e.message}` };
}
@@ -550,7 +550,7 @@
let claimed = 0;
let skipped = 0;
let errors = 0;
let errors = 0;
for (let i = 0; i < polisList.length; i++) {
const town_id = polisList[i];
@@ -576,7 +576,7 @@
readyFarms.push({
town_id,
farm_town_id: rel.attributes.farm_town_id,
relation_id: rel.id
relation_id: rel.id
});
}
}
@@ -588,10 +588,10 @@
for (const farm of readyFarms) {
try {
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
model_url: `FarmTownPlayerRelation/${farm.relation_id}`,
model_url: `FarmTownPlayerRelation/${farm.relation_id}`,
action_name: 'claim',
arguments: { farm_town_id: farm.farm_town_id, type: 'resources', option },
town_id: farm.town_id
arguments: { farm_town_id: farm.farm_town_id, type: 'resources', option },
town_id: farm.town_id
});
claimed++;
} catch (e) { errors++; }
@@ -601,12 +601,12 @@
}
// Refresh map icons after claiming (same as original)
try { uw.WMap.removeFarmTownLootCooldownIconAndRefreshLootTimers(); } catch(e) {}
try { uw.WMap.removeFarmTownLootCooldownIconAndRefreshLootTimers(); } catch (e) { }
// Random between-island delay: 30s 90s (only if more islands remain)
if (i < polisList.length - 1) {
const gap = randInt(30000, 90000);
log(`Farm: island done. Waiting ${(gap/1000).toFixed(0)}s before next island...`);
log(`Farm: island done. Waiting ${(gap / 1000).toFixed(0)}s before next island...`);
await sleep(gap);
}
}
@@ -750,11 +750,11 @@
}
// 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 farmCmd = cmdData.farm;
const farmUpgradeCmd = cmdData.farm_upgrade;
const marketCmd = cmdData.market;
const farmCmd = cmdData.farm;
const farmUpgradeCmd = cmdData.farm_upgrade;
// Auto-farm: if enabled, claim all ready farms (no explicit command needed)
const farmSettings = cmdData.farm_settings || {};
@@ -765,7 +765,7 @@
try {
const coll = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation');
return coll?.models?.some(r => r.attributes.relation_status === 1 && (r.attributes.lootable_at || 0) <= nowTs);
} catch(e) { return false; }
} catch (e) { return false; }
});
if (hasFarms) {
log('⚡ Auto-farm: ready farms detected, triggering loot...');