captsa add alert

This commit is contained in:
2026-04-21 19:17:28 +03:00
parent 7e5bfcefa4
commit b0d933c1a0
9 changed files with 162 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name Grepolis Remote Control
// @namespace http://tampermonkey.net/
// @version 2.4
// @version 2.5
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game
// @author Dimitrios
// @match https://*.grepolis.com/game/*
@@ -279,6 +279,43 @@
}).catch(e => log(`reportResult failed: ${e}`));
}
// ----------------------------------------------------------------
// Captcha detection via MutationObserver
// Watches document.body for #hcaptcha_window being added/removed.
// Confirmed selector from live DOM: DIV#hcaptcha_window > DIV.h-captcha
// ----------------------------------------------------------------
let captchaActive = false;
function reportCaptcha(detected) {
fetch(`${BASE_URL}/api/captcha/alert`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ detected })
}).catch(e => log(`captcha report failed: ${e}`));
}
function detectCaptcha() {
const observer = new MutationObserver(() => {
const hasWindow = !!document.getElementById('hcaptcha_window');
if (hasWindow && !captchaActive) {
captchaActive = true;
paused = true;
const label = document.getElementById('grc_label');
const btn = document.getElementById('grc_btn');
if (label) label.textContent = '⚠ CAPTCHA';
if (btn) btn.style.filter = 'brightness(70%) sepia(100%) hue-rotate(300deg) saturate(1000%) contrast(0.8)';
log('⚠ CAPTCHA detected — bot paused, alerting server');
reportCaptcha(true);
} else if (!hasWindow && captchaActive) {
captchaActive = false;
// Don't auto-resume — let the user click the button manually
log('✅ Captcha resolved — alert cleared (bot remains paused)');
reportCaptcha(false);
}
});
observer.observe(document.body, { childList: true, subtree: false });
}
// ----------------------------------------------------------------
// Execute: Build
// ----------------------------------------------------------------
@@ -410,7 +447,10 @@
// Boot
// ----------------------------------------------------------------
window.addEventListener('load', () => {
log('Grepolis Remote Control v2.4 loaded');
log('Grepolis Remote Control v2.5 loaded');
// Start captcha watcher immediately
detectCaptcha();
// Push state once after load, then every 4590 seconds (randomized)
setTimeout(pushState, 5000);