From 7e3addf7a6953bb3071876eb1cddf66dd0360f29 Mon Sep 17 00:00:00 2001 From: Y-Ymeow <151431022+Y-Ymeow@users.noreply.github.com> Date: Sat, 29 Nov 2025 14:20:02 +0800 Subject: [PATCH] Enhance Cloudflare challenge detection logic (#619) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加了验证body内的,防止一些网站的漏判 --- lib/network/cloudflare.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/network/cloudflare.dart b/lib/network/cloudflare.dart index 8b51fe8..144d46f 100644 --- a/lib/network/cloudflare.dart +++ b/lib/network/cloudflare.dart @@ -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",