Enhance Cloudflare challenge detection logic (#619)

添加了验证body内的,防止一些网站的漏判
This commit is contained in:
Y-Ymeow
2025-11-29 14:20:02 +08:00
committed by GitHub
parent b9c06779ad
commit 7e3addf7a6

View File

@@ -128,10 +128,15 @@ void passCloudflare(CloudflareException e, void Function() onFinished) async {
var head =
await controller.evaluateJavascript("document.head.innerHTML") ??
"";
var body =
await controller.evaluateJavascript("document.body.innerHTML") ??
"";
Log.info("Cloudflare", "Checking head: $head");
var isChallenging = head.contains('#challenge-success-text') ||
head.contains("#challenge-error-text") ||
head.contains("#challenge-form");
head.contains("#challenge-form") ||
body.contains("challenge-platform") ||
body.contains("window._cf_chl_opt");
if (!isChallenging) {
Log.info(
"Cloudflare",
@@ -159,10 +164,14 @@ void passCloudflare(CloudflareException e, void Function() onFinished) async {
void check(InAppWebViewController controller) async {
var head = await controller.evaluateJavascript(
source: "document.head.innerHTML") as String;
var body = await controller.evaluateJavascript(
source: "document.body.innerHTML") as String;
Log.info("Cloudflare", "Checking head: $head");
var isChallenging = head.contains('#challenge-success-text') ||
head.contains("#challenge-error-text") ||
head.contains("#challenge-form");
head.contains("#challenge-form") ||
body.contains("challenge-platform") ||
body.contains("window._cf_chl_opt");
if (!isChallenging) {
Log.info(
"Cloudflare",