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 ->
|
|
|
|
|
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,
|
2020-01-06 09:26:31 +01: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
|
|
|
}
|
|
|
|
|
} else response
|
2019-04-22 02:46:29 +02:00
|
|
|
}
|