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== // ==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/ // @namespace http://tampermonkey.net/
// @version 6.7 // @version 6.8
// @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. // @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 // @author Dimitrios
// @match https://*.grepolis.com/game/* // @match https://*.grepolis.com/game/*
// @grant unsafeWindow // @grant unsafeWindow
@@ -13,7 +13,7 @@
(function () { (function () {
'use strict'; '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; const uw = typeof unsafeWindow !== "undefined" ? unsafeWindow : window;
let latestBasicPayload = null; 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() { function refreshGoldWindow() {
if (paused) { if (paused) {
console.log("⏸️ DeepScan is paused — skipping refresh"); console.log("⏸️ DeepScan is paused — skipping refresh");
@@ -163,12 +178,14 @@
} }
try { try {
forceCloseMarketplaceWindows();
setTimeout(() => {
const marketArea = document.querySelector("area#building_main_area_market"); const marketArea = document.querySelector("area#building_main_area_market");
if (marketArea) { if (marketArea) {
marketArea.dispatchEvent(new MouseEvent("click", { bubbles: true })); 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(() => { setTimeout(() => {
const newWin = Array.from(document.querySelectorAll(".classic_window.market")) const newWin = Array.from(document.querySelectorAll(".classic_window.market"))
.find(win => win.querySelector("#premium_exchange")); .find(win => win.querySelector("#premium_exchange"));
@@ -179,15 +196,16 @@
sellTab.click(); sellTab.click();
console.log("🔁 Switched to Premium Exchange Sell tab"); console.log("🔁 Switched to Premium Exchange Sell tab");
} else { } else {
console.warn("⚠️ Sell tab not found in window"); console.warn("⚠️ Sell tab not found in reopened window");
} }
} else { } else {
console.warn("❌ Premium Exchange window not found after click"); console.warn("❌ Premium Exchange window not found after reopening");
} }
}, 1500); }, 1500);
} else { } else {
console.warn("❌ Marketplace area not found — cannot trigger Premium Exchange"); console.warn("❌ Marketplace area not found — cannot reopen Premium Exchange");
} }
}, 5000);
} catch (err) { } catch (err) {
console.error("💥 Error in refreshGoldWindow:", err); console.error("💥 Error in refreshGoldWindow:", err);
} }
@@ -196,14 +214,14 @@
// 🔁 Main loop // 🔁 Main loop
function runDataCycle() { function runDataCycle() {
setInterval(() => { setInterval(() => {
console.log("🕒 Data cycle tick — soft refresh + send stats"); console.log("🕒 Data cycle tick — close/reopen + send stats");
refreshGoldWindow(); refreshGoldWindow();
setTimeout(sendBasicStats, 3000); setTimeout(sendBasicStats, 7000); // after reopen + tab switch
}, 30000); }, 30000);
} }
window.addEventListener("load", () => { window.addEventListener("load", () => {
console.log("🚀 DeepScan v6.5 booting up..."); console.log("🚀 DeepScan v6.8 booting up...");
runDataCycle(); runDataCycle();
}); });
})(); })();