Update Grepolis_Data_Sender.user.js

This commit is contained in:
2025-08-08 19:26:28 +00:00
parent 3670988ae8
commit a27c122070

View File

@@ -1,8 +1,8 @@
// ==UserScript==
// @name Grepolis Data Sender (Deep Scan v6.7 — Toolbar Pause Button + Soft Refresh & Full Stats)
// @name Grepolis Data Sender (Deep Scan v6.8 — Toolbar Pause Button + Window Reopen & Full Stats)
// @namespace http://tampermonkey.net/
// @version 6.7
// @description Sends town stats, extracts Premium Exchange title, and soft-refreshes tab every 30s via Marketplace building click. Includes pause/resume button in top toolbar.
// @version 6.8
// @description Sends town stats, extracts Premium Exchange title, and refreshes tab every 30s by closing and reopening Marketplace. Includes pause/resume button in top toolbar.
// @author Dimitrios
// @match https://*.grepolis.com/game/*
// @grant unsafeWindow
@@ -13,7 +13,7 @@
(function () {
'use strict';
console.log("💰 DeepScan v6.7 loaded — Soft refresh + Toolbar pause button + full stats");
console.log("💰 DeepScan v6.8 loaded — Toolbar pause button + window reopen + full stats");
const uw = typeof unsafeWindow !== "undefined" ? unsafeWindow : window;
let latestBasicPayload = null;
@@ -155,7 +155,22 @@
}
}
// 🏛️ Soft refresh: click building and switch tab
// ❎ Close all Marketplace windows
function forceCloseMarketplaceWindows() {
const marketWindows = document.querySelectorAll(".classic_window.market");
marketWindows.forEach(win => {
const closeBtn = win.querySelector(".buttons_container .btn_wnd.close");
if (closeBtn) {
closeBtn.click();
console.log("❎ Clicked close button for Marketplace window:", win.id);
} else {
console.warn("⚠️ Close button not found in window:", win.id);
}
});
}
// 🏛️ Refresh Premium Exchange tab by closing and reopening
function refreshGoldWindow() {
if (paused) {
console.log("⏸️ DeepScan is paused — skipping refresh");
@@ -163,12 +178,14 @@
}
try {
forceCloseMarketplaceWindows();
setTimeout(() => {
const marketArea = document.querySelector("area#building_main_area_market");
if (marketArea) {
marketArea.dispatchEvent(new MouseEvent("click", { bubbles: true }));
console.log("🏛️ Clicked Marketplace area to trigger Premium Exchange");
console.log("🏛️ Clicked Marketplace area to reopen Premium Exchange");
// Wait 1.5s and switch to Sell tab
setTimeout(() => {
const newWin = Array.from(document.querySelectorAll(".classic_window.market"))
.find(win => win.querySelector("#premium_exchange"));
@@ -179,15 +196,16 @@
sellTab.click();
console.log("🔁 Switched to Premium Exchange Sell tab");
} else {
console.warn("⚠️ Sell tab not found in window");
console.warn("⚠️ Sell tab not found in reopened window");
}
} else {
console.warn("❌ Premium Exchange window not found after click");
console.warn("❌ Premium Exchange window not found after reopening");
}
}, 1500);
} else {
console.warn("❌ Marketplace area not found — cannot trigger Premium Exchange");
console.warn("❌ Marketplace area not found — cannot reopen Premium Exchange");
}
}, 5000);
} catch (err) {
console.error("💥 Error in refreshGoldWindow:", err);
}
@@ -196,14 +214,14 @@
// 🔁 Main loop
function runDataCycle() {
setInterval(() => {
console.log("🕒 Data cycle tick — soft refresh + send stats");
console.log("🕒 Data cycle tick — close/reopen + send stats");
refreshGoldWindow();
setTimeout(sendBasicStats, 3000);
setTimeout(sendBasicStats, 7000); // after reopen + tab switch
}, 30000);
}
window.addEventListener("load", () => {
console.log("🚀 DeepScan v6.5 booting up...");
console.log("🚀 DeepScan v6.8 booting up...");
runDataCycle();
});
})();