TachiyomiSY-Plus/app/src/main/java/exh/patch/UniversalCaptchaDetection.kt
Rani Sargees b90a2ab22d add hcaptcha to captcha detection
(cherry picked from commit 7c01082270aa98a4840af3b0c1bfd6534570682d)
2020-06-11 22:12:21 -04:00

24 lines
801 B
Kotlin

package exh.patch
import android.app.Application
import exh.ui.captcha.BrowserActionActivity
import exh.util.interceptAsHtml
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
val CAPTCHA_DETECTION_PATCH: EHInterceptor = { request, response, sourceId ->
if (!response.isSuccessful) {
response.interceptAsHtml { doc ->
// Find captcha
if (doc.getElementsByClass("g-recaptcha").isNotEmpty() || doc.getElementsByClass("h-captcha").isNotEmpty()) {
// Found it, allow the user to solve this thing
BrowserActionActivity.launchUniversal(
Injekt.get<Application>(),
sourceId,
request.url.toString()
)
}
}
} else response
}