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
This commit is contained in:
1 parent
7a02453601
commit
c87b01967f
7 files changed
+794
-425
No files matched your search
@@ -1,132 +0,0 @@
|
||||
// Turnstile Patch - minimal only
|
||||
// Full aggressive patches (chrome.runtime delete / permissions / plugins / languages
|
||||
// / iframe postMessage spam) were observed to break xAI signup with:
|
||||
// [permission_denied] HTTP 403
|
||||
// Keep webdriver hide only. Auto-click remains best-effort and local-only.
|
||||
// Note: CF challenge iframes are cross-origin — contentDocument click usually fails;
|
||||
// host-page click + Python CDP shadow path do the real work.
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
if (window.__grokStealthApplied) return;
|
||||
window.__grokStealthApplied = true;
|
||||
|
||||
// 1. Hide navigator.webdriver (instance + prototype when possible)
|
||||
try {
|
||||
Object.defineProperty(navigator, "webdriver", {
|
||||
get: function () {
|
||||
return false;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
} catch (e) {}
|
||||
try {
|
||||
var desc = Object.getOwnPropertyDescriptor(Navigator.prototype, "webdriver");
|
||||
if (!desc || desc.configurable) {
|
||||
Object.defineProperty(Navigator.prototype, "webdriver", {
|
||||
get: function () {
|
||||
return false;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
function firePointer(el) {
|
||||
if (!el) return;
|
||||
try {
|
||||
el.scrollIntoView({ block: "center", inline: "center" });
|
||||
} catch (e) {}
|
||||
var rect;
|
||||
try {
|
||||
rect = el.getBoundingClientRect();
|
||||
} catch (e) {
|
||||
rect = null;
|
||||
}
|
||||
var x = 12;
|
||||
var y = 12;
|
||||
if (rect && rect.width > 0) {
|
||||
x = rect.left + Math.max(6, Math.min(rect.width - 6, rect.width * 0.35));
|
||||
y = rect.top + Math.max(6, Math.min(rect.height - 6, rect.height * 0.5));
|
||||
}
|
||||
var opts = {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
view: window,
|
||||
clientX: x,
|
||||
clientY: y,
|
||||
button: 0,
|
||||
};
|
||||
var types = [
|
||||
"pointerover",
|
||||
"mouseover",
|
||||
"mousemove",
|
||||
"pointerdown",
|
||||
"mousedown",
|
||||
"pointerup",
|
||||
"mouseup",
|
||||
"click",
|
||||
];
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
var t = types[i];
|
||||
try {
|
||||
var Ev = t.indexOf("pointer") === 0 ? PointerEvent : MouseEvent;
|
||||
el.dispatchEvent(new Ev(t, opts));
|
||||
} catch (e) {
|
||||
try {
|
||||
el.dispatchEvent(new MouseEvent(t, opts));
|
||||
} catch (e2) {}
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (typeof el.click === "function") el.click();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 2. Best-effort Turnstile interaction (same-origin iframe + host widget)
|
||||
function tryClickTurnstile() {
|
||||
try {
|
||||
var iframes = document.querySelectorAll(
|
||||
'iframe[src*="challenges.cloudflare.com"], iframe[src*="turnstile"]'
|
||||
);
|
||||
for (var i = 0; i < iframes.length; i++) {
|
||||
// Host-side synthetic click (works even when iframe is cross-origin)
|
||||
firePointer(iframes[i]);
|
||||
try {
|
||||
var body = iframes[i].contentDocument || iframes[i].contentWindow.document;
|
||||
if (!body) continue;
|
||||
var checkbox = body.querySelector(
|
||||
'input[type="checkbox"], .mark, label, [role="checkbox"]'
|
||||
);
|
||||
if (checkbox && !checkbox.checked) {
|
||||
firePointer(checkbox);
|
||||
}
|
||||
} catch (e) {
|
||||
// cross-origin: host click above is enough
|
||||
}
|
||||
}
|
||||
var widgets = document.querySelectorAll(
|
||||
"div.cf-turnstile, [data-sitekey], input[name='cf-turnstile-response']"
|
||||
);
|
||||
for (var j = 0; j < widgets.length; j++) {
|
||||
firePointer(widgets[j]);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function startLoop() {
|
||||
var n = 0;
|
||||
var t = setInterval(function () {
|
||||
n++;
|
||||
tryClickTurnstile();
|
||||
// ~90s of best-effort clicks (was 40s)
|
||||
if (n > 180) clearInterval(t);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", startLoop);
|
||||
} else {
|
||||
startLoop();
|
||||
}
|
||||
})();
|
||||
@@ -1,16 +1,12 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Turnstile Patch",
|
||||
"version": "1.3.0",
|
||||
"description": "Minimal webdriver hide + best-effort host click for Turnstile",
|
||||
"name": "Turnstile Patcher",
|
||||
"version": "2.1",
|
||||
"description": "Patch CDP MouseEvent.screenX/screenY for Turnstile (ReinerBRO / Git-creat7)",
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"<all_urls>"
|
||||
],
|
||||
"js": [
|
||||
"content.js"
|
||||
],
|
||||
"js": ["./script.js"],
|
||||
"matches": ["<all_urls>"],
|
||||
"run_at": "document_start",
|
||||
"all_frames": true,
|
||||
"world": "MAIN",
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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) {}
|
||||
Reference in new issue
Block a user