Align Turnstile with zip refs and harden interactive CF path

Restore MV2 turnstilePatch (content.js), zip-style headed browser flags,
system-default browser path, and interactive-safe solver that skips reset
while the human checkbox is up to avoid 验证失败 after the button appears.
This commit is contained in:
chaos committed 2026-07-12 07:04:38 +08:00
1 parent c87b01967f
commit 60e24b89c1
5 files changed
+449 -157

No files matched your search

+137
View File
@@ -0,0 +1,137 @@
// Turnstile Patch - 隐藏自动化标识,加速 Turnstile 验证
// 在 document_start 阶段执行,确保在页面脚本之前生效
// Source: grok-register / grok_reg-protocol_cpa (zip reference)
(function () {
"use strict";
// 1. 隐藏 navigator.webdriver 标识
// Chrome 自动化模式下 navigator.webdriver = true,Turnstile 会检测此属性
try {
Object.defineProperty(navigator, "webdriver", {
get: function () {
return false;
},
configurable: true,
});
} catch (e) {}
// 2. 移除 Chrome 自动化相关的 Runtime 属性
try {
if (window.chrome && window.chrome.runtime) {
delete window.chrome.runtime.onConnect;
delete window.chrome.runtime.onMessage;
}
} catch (e) {}
// 3. 覆盖 permissions.query,隐藏 notifications 权限异常
try {
var origQuery = navigator.permissions.query.bind(navigator.permissions);
navigator.permissions.query = function (params) {
if (params.name === "notifications") {
return Promise.resolve({ state: Notification.permission });
}
return origQuery(params);
};
} catch (e) {}
// 4. 修补 plugin 数量,模拟正常浏览器
try {
Object.defineProperty(navigator, "plugins", {
get: function () {
return [1, 2, 3, 4, 5];
},
configurable: true,
});
} catch (e) {}
// 5. 修补 languages 属性
try {
Object.defineProperty(navigator, "languages", {
get: function () {
return ["en-US", "en"];
},
configurable: true,
});
} catch (e) {}
// 6. CDP MouseEvent.screenX/screenY 与 client 相同会被 CF 检测(Chromium 40280325)
// 两个 zip 的 getTurnstileToken 也会在 iframe 内再补一次;扩展层提前全局打补丁更稳
try {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var _sx = getRandomInt(800, 1200);
var _sy = getRandomInt(400, 600);
Object.defineProperty(MouseEvent.prototype, "screenX", {
configurable: true,
get: function () {
return _sx + (this.clientX || 0);
},
});
Object.defineProperty(MouseEvent.prototype, "screenY", {
configurable: true,
get: function () {
return _sy + (this.clientY || 0);
},
});
} catch (e) {}
// 7. 页面加载完成后,自动监控并点击 Turnstile 复选框
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", autoClickTurnstile);
} else {
autoClickTurnstile();
}
function autoClickTurnstile() {
// 定时检查 Turnstile iframe 是否出现
var checkCount = 0;
var maxChecks = 100; // 最多检查 100 次(约 50 秒)
var timer = setInterval(function () {
checkCount++;
if (checkCount > maxChecks) {
clearInterval(timer);
return;
}
try {
// 查找 Turnstile iframe
var iframes = document.querySelectorAll(
'iframe[src*="challenges.cloudflare.com"], iframe[src*="turnstile"]'
);
for (var i = 0; i < iframes.length; i++) {
var iframe = iframes[i];
try {
// 尝试访问 iframe 内部的 checkbox
var body = iframe.contentDocument || iframe.contentWindow.document;
var checkbox = body.querySelector(
'input[type="checkbox"], .mark, #cf-chl-widget-nomu1_resp'
);
if (checkbox && !checkbox.checked) {
checkbox.click();
}
} catch (e) {
// 跨域限制,尝试通过 postMessage 触发
try {
iframe.contentWindow.postMessage(
{ type: "turnstile-auto-click" },
"*"
);
} catch (e2) {}
}
}
// 也尝试直接操作 Turnstile API
if (
window.turnstile &&
typeof window.turnstile.getResponse === "function"
) {
var resp = window.turnstile.getResponse();
if (resp && resp.length > 0) {
clearInterval(timer); // 已获得 token,停止检查
}
}
} catch (e) {}
}, 500);
}
})();
+8 -9
View File
@@ -1,16 +1,15 @@
{
"manifest_version": 3,
"name": "Turnstile Patcher",
"version": "2.1",
"description": "Patch CDP MouseEvent.screenX/screenY for Turnstile (ReinerBRO / Git-creat7)",
"manifest_version": 2,
"name": "Turnstile Patch",
"version": "1.0.0",
"description": "Patch browser automation detection for Turnstile",
"content_scripts": [
{
"js": ["./script.js"],
"matches": ["<all_urls>"],
"js": ["content.js"],
"run_at": "document_start",
"all_frames": true,
"world": "MAIN",
"match_about_blank": true
"all_frames": true
}
]
],
"permissions": ["activeTab"]
}
-24
View File
@@ -1,24 +0,0 @@
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) {}