Update town.js

This commit is contained in:
2025-08-19 13:00:43 +00:00
parent e9715cfffd
commit ff267cf05e

16
town.js
View File

@@ -1,8 +1,8 @@
// ==UserScript==
// @name Grepolis Town Stats Extended Clean (with Sea, Buildings, Researches, Points, Gods)
// @name Grepolis Town Stats Extended Clean (with Alliance & World)
// @namespace http://tampermonkey.net/
// @version 1.8
// @description Sends town stats with coords, sea, full building orders, researches, points, and gods
// @version 1.9
// @description Sends town stats with coords, sea, full building orders, researches, points, gods, alliance_id, world_id
// @author Dimitrios + GPT
// @match https://*.grepolis.com/game/*
// @grant unsafeWindow
@@ -14,7 +14,7 @@
const uw = unsafeWindow || window;
let paused = false;
console.log("🚀 Town Stats Extended Clean (with Sea, Buildings, Researches, Points, Gods) loaded");
console.log("🚀 Town Stats Extended Clean (with Alliance & World) loaded");
// -----------------------------
// Toolbar pause/resume button
@@ -68,6 +68,8 @@
const player = uw.Game?.player_name || "unknown";
const player_id = uw.Game?.player_id || "unknown";
const total_points = uw.Game?.player_points || 0;
const alliance_id = uw.Game?.alliance_id || null;
const world_id = uw.Game?.world_id || null;
const townStats = Object.values(towns).map(town => {
const res = town.resources();
@@ -108,13 +110,13 @@
researches = town.researches();
}
// Village points — use fixed getPoints
// Village points
let points = 0;
if (typeof town.getPoints === 'function') {
points = town.getPoints();
}
// God — keep original logic
// God
let god = null;
if (typeof town.god === 'function') {
god = town.god();
@@ -140,7 +142,7 @@
};
});
return { player, player_id, total_points, towns: townStats };
return { player, player_id, alliance_id, world_id, total_points, towns: townStats };
}
// -----------------------------