Files
grepo-remote/bot_modules/03_captcha.js
2026-04-26 12:53:14 +03:00

46 lines
1.7 KiB
JavaScript

// ================================================================
// 03_captcha.js — hCaptcha detection & server alert
// Depends on: uw, BASE_URL, log, paused (00_config.js / 01_ui.js)
// ================================================================
let captchaActive = false;
function reportCaptcha(detected) {
const player_id = uw.Game?.player_id;
if (!player_id) return;
fetch(`${BASE_URL}/api/captcha/alert?player_id=${player_id}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ detected })
}).catch(e => log(`captcha report failed: ${e}`));
}
function detectCaptcha() {
setInterval(() => {
const win = document.getElementById('hcaptcha_window');
let isVisible = false;
if (win) {
const style = window.getComputedStyle(win);
if (style.display !== 'none' && style.visibility !== 'hidden') {
isVisible = true;
}
}
if (isVisible && !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 (!isVisible && captchaActive) {
captchaActive = false;
log('✅ Captcha resolved — alert cleared (bot remains paused)');
reportCaptcha(false);
}
}, 1000);
}