Update Grepolis_Data_Sender.user.js
This commit is contained in:
@@ -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,31 +178,34 @@
|
||||
}
|
||||
|
||||
try {
|
||||
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");
|
||||
forceCloseMarketplaceWindows();
|
||||
|
||||
// Wait 1.5s and switch to Sell tab
|
||||
setTimeout(() => {
|
||||
const newWin = Array.from(document.querySelectorAll(".classic_window.market"))
|
||||
.find(win => win.querySelector("#premium_exchange"));
|
||||
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 reopen Premium Exchange");
|
||||
|
||||
if (newWin) {
|
||||
const sellTab = newWin.querySelector(".gp_page_caption.js-page-caption-1");
|
||||
if (sellTab) {
|
||||
sellTab.click();
|
||||
console.log("🔁 Switched to Premium Exchange Sell tab");
|
||||
setTimeout(() => {
|
||||
const newWin = Array.from(document.querySelectorAll(".classic_window.market"))
|
||||
.find(win => win.querySelector("#premium_exchange"));
|
||||
|
||||
if (newWin) {
|
||||
const sellTab = newWin.querySelector(".gp_page_caption.js-page-caption-1");
|
||||
if (sellTab) {
|
||||
sellTab.click();
|
||||
console.log("🔁 Switched to Premium Exchange Sell tab");
|
||||
} else {
|
||||
console.warn("⚠️ Sell tab not found in reopened window");
|
||||
}
|
||||
} else {
|
||||
console.warn("⚠️ Sell tab not found in window");
|
||||
console.warn("❌ Premium Exchange window not found after reopening");
|
||||
}
|
||||
} else {
|
||||
console.warn("❌ Premium Exchange window not found after click");
|
||||
}
|
||||
}, 1500);
|
||||
} else {
|
||||
console.warn("❌ Marketplace area not found — cannot trigger Premium Exchange");
|
||||
}
|
||||
}, 1500);
|
||||
} else {
|
||||
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();
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user