2019-04-22 02:46:29 +02:00
|
|
|
package exh.patch
|
|
|
|
|
|
2019-04-22 05:01:41 +02:00
|
|
|
import android.app.Application
|
2019-04-22 02:46:29 +02:00
|
|
|
import exh.ui.captcha.BrowserActionActivity
|
|
|
|
|
import exh.util.interceptAsHtml
|
2019-04-22 05:01:41 +02:00
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
|
|
import uy.kohesive.injekt.api.get
|
2019-04-22 02:46:29 +02:00
|
|
|
|
2019-04-22 05:01:41 +02:00
|
|
|
val CAPTCHA_DETECTION_PATCH: EHInterceptor = { request, response, sourceId ->
|
2020-04-04 22:30:05 +02:00
|
|
|
if (!response.isSuccessful) {
|
2019-04-22 05:01:41 +02:00
|
|
|
response.interceptAsHtml { doc ->
|
|
|
|
|
// Find captcha
|
2020-06-12 03:49:27 +02:00
|
|
|
if (doc.getElementsByClass("g-recaptcha").isNotEmpty() || doc.getElementsByClass("h-captcha").isNotEmpty()) {
|
2019-04-22 05:01:41 +02:00
|
|
|
// Found it, allow the user to solve this thing
|
|
|
|
|
BrowserActionActivity.launchUniversal(
|
2020-05-02 06:46:24 +02:00
|
|
|
Injekt.get<Application>(),
|
|
|
|
|
sourceId,
|
2022-04-08 21:30:30 +02:00
|
|
|
request.url.toString(),
|
2019-04-22 05:01:41 +02:00
|
|
|
)
|
2019-04-22 02:46:29 +02:00
|
|
|
}
|
2019-04-22 05:01:41 +02:00
|
|
|
}
|
2022-09-12 01:43:45 +02:00
|
|
|
} else {
|
|
|
|
|
response
|
|
|
|
|
}
|
2020-04-04 22:30:05 +02:00
|
|
|
}
|