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:
parent
f5e1c1e5ce
commit
3344fd0755
1 changed files with 23 additions and 7 deletions
|
|
@ -93,14 +93,30 @@ class EhLoginActivity : BaseActivity() {
|
||||||
xLogD(url)
|
xLogD(url)
|
||||||
val parsedUrl = url.toUri()
|
val parsedUrl = url.toUri()
|
||||||
if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) {
|
if (parsedUrl.host.equals("forums.e-hentai.org", ignoreCase = true)) {
|
||||||
// Hide distracting content
|
view.evaluateJavascript(
|
||||||
if (!parsedUrl.queryParameterNames.contains(PARAM_SKIP_INJECT)) {
|
"""
|
||||||
view.evaluateJavascript(HIDE_JS, null)
|
(function() {
|
||||||
}
|
let html = document.documentElement.innerHTML;
|
||||||
// Check login result
|
return html.includes("/cdn-cgi/");
|
||||||
|
})();
|
||||||
|
""".trimIndent(),
|
||||||
|
) { result ->
|
||||||
|
val isCloudflareBlock = result == "true"
|
||||||
|
|
||||||
if (parsedUrl.getQueryParameter("code")?.toInt() != 0) {
|
if (isCloudflareBlock) {
|
||||||
if (checkLoginCookies(url)) view.loadUrl("https://exhentai.org/")
|
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)) {
|
} else if (parsedUrl.host.equals("exhentai.org", ignoreCase = true)) {
|
||||||
// At ExHentai, check that everything worked out...
|
// At ExHentai, check that everything worked out...
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue