Fix blank page on cloudflare guard

(cherry picked from commit 07599ade3aeb127f643b45e84a6b9ccdb1d0ba6d)

Co-authored-by: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com>
This commit is contained in:
Jobobby04 2026-02-27 13:49:26 -05:00 committed by Cuong-Tran
parent f5e1c1e5ce
commit 3344fd0755

View file

@ -93,14 +93,30 @@ class EhLoginActivity : BaseActivity() {
xLogD(url)
val parsedUrl = url.toUri()
if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) {
// Hide distracting content
if (!parsedUrl.queryParameterNames.contains(PARAM_SKIP_INJECT)) {
view.evaluateJavascript(HIDE_JS, null)
}
// Check login result
view.evaluateJavascript(
"""
(function() {
let html = document.documentElement.innerHTML;
return html.includes("/cdn-cgi/");
})();
""".trimIndent(),
) { result ->
val isCloudflareBlock = result == "true"
if (parsedUrl.getQueryParameter("code")?.toInt() != 0) {
if (checkLoginCookies(url)) view.loadUrl("https://exhentai.org/")
if (isCloudflareBlock) {
xLogD("Cloudflare block detected — skipping logic")
return@evaluateJavascript
}
// Hide distracting content
if (!parsedUrl.queryParameterNames.contains(PARAM_SKIP_INJECT)) {
view.evaluateJavascript(HIDE_JS, null)
}
// Check login result
if (parsedUrl.getQueryParameter("code")?.toIntOrNull() != 0) {
if (checkLoginCookies(url)) view.loadUrl("https://exhentai.org/")
}
}
} else if (parsedUrl.host.equals("exhentai.org", ignoreCase = true)) {
// At ExHentai, check that everything worked out...