komikku/app/src/main/java/exh/patch/UniversalCaptchaDetection.kt
Rani Sargees 9b883b1a09 androidx migration
I DID THIS ONE MYSELF WITHOUT TAKING IT FROM THE OTHER FORKS
YEEEEEEEEEEET
2020-01-06 03:26:31 -05:00

23 lines
No EOL
759 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()) {
// Found it, allow the user to solve this thing
BrowserActionActivity.launchUniversal(
Injekt.get<Application>(),
sourceId,
request.url.toString()
)
}
}
} else response
}