Files
grok-keygen/turnstilePatch/script.js
T
chaos c87b01967f Refactor registration flow, update config, replace Turnstile patch
- Major refactor of grok_register_ttk.py: improved flow, error handling, logging
- Update config.example.json and config.json with new fields
- Replace turnstilePatch/content.js with new script.js approach
- Update start.sh for better Chromium/Turnstile handling
- Remove deprecated turnstilePatch/content.js
2026-07-12 14:44:02 +08:00

25 lines
1.0 KiB
JavaScript

function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// CDP Input.dispatchMouseEvent creates MouseEvent where
// .screenX/.screenY equal .clientX/.clientY. Cloudflare Turnstile detects
// this (Chromium issue 40280325). Patch with realistic screen coords.
// Source: ObjectAscended/CDP-bug-MouseEvent-.screenX-.screenY-patcher
// Ported from ReinerBRO/grok-register + Git-creat7/grokRegister-cpa.
// old method wouldn't work on 4k screens
let screenX = getRandomInt(800, 1200);
let screenY = getRandomInt(400, 600);
Object.defineProperty(MouseEvent.prototype, "screenX", { value: screenX });
Object.defineProperty(MouseEvent.prototype, "screenY", { value: screenY });
// Best-effort: also cover PointerEvent if present (CF may read either).
try {
if (typeof PointerEvent !== "undefined" && PointerEvent.prototype) {
Object.defineProperty(PointerEvent.prototype, "screenX", { value: screenX });
Object.defineProperty(PointerEvent.prototype, "screenY", { value: screenY });
}
} catch (e) {}