Linting Fixes AZ
This commit is contained in:
@@ -9,13 +9,14 @@ import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
private val HIDE_SCRIPT = """
|
||||
document.querySelector("#forgot_button").style.visibility = "hidden";
|
||||
document.querySelector("#signup_button").style.visibility = "hidden";
|
||||
document.querySelector("#announcement").style.visibility = "hidden";
|
||||
document.querySelector("nav").style.visibility = "hidden";
|
||||
document.querySelector("footer").style.visibility = "hidden";
|
||||
""".trimIndent()
|
||||
private val HIDE_SCRIPT =
|
||||
"""
|
||||
document.querySelector("#forgot_button").style.visibility = "hidden";
|
||||
document.querySelector("#signup_button").style.visibility = "hidden";
|
||||
document.querySelector("#announcement").style.visibility = "hidden";
|
||||
document.querySelector("nav").style.visibility = "hidden";
|
||||
document.querySelector("footer").style.visibility = "hidden";
|
||||
""".trimIndent()
|
||||
|
||||
private fun verifyComplete(url: String): Boolean {
|
||||
return url.toHttpUrlOrNull()?.let { parsed ->
|
||||
@@ -28,14 +29,14 @@ val MANGADEX_LOGIN_PATCH: EHInterceptor = { request, response, sourceId ->
|
||||
response.interceptAsHtml { doc ->
|
||||
if (doc.title().trim().equals("Login - MangaDex", true)) {
|
||||
BrowserActionActivity.launchAction(
|
||||
Injekt.get<Application>(),
|
||||
::verifyComplete,
|
||||
HIDE_SCRIPT,
|
||||
"https://mangadex.org/login",
|
||||
"Login",
|
||||
(Injekt.get<SourceManager>().get(sourceId) as? HttpSource)?.headers?.toMultimap()?.mapValues {
|
||||
it.value.joinToString(",")
|
||||
} ?: emptyMap()
|
||||
Injekt.get<Application>(),
|
||||
::verifyComplete,
|
||||
HIDE_SCRIPT,
|
||||
"https://mangadex.org/login",
|
||||
"Login",
|
||||
(Injekt.get<SourceManager>().get(sourceId) as? HttpSource)?.headers?.toMultimap()?.mapValues {
|
||||
it.value.joinToString(",")
|
||||
} ?: emptyMap()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -43,43 +44,43 @@ val MANGADEX_LOGIN_PATCH: EHInterceptor = { request, response, sourceId ->
|
||||
}
|
||||
|
||||
val MANGADEX_SOURCE_IDS = listOf(
|
||||
2499283573021220255,
|
||||
8033579885162383068,
|
||||
1952071260038453057,
|
||||
2098905203823335614,
|
||||
5098537545549490547,
|
||||
4505830566611664829,
|
||||
9194073792736219759,
|
||||
6400665728063187402,
|
||||
4938773340256184018,
|
||||
5860541308324630662,
|
||||
5189216366882819742,
|
||||
2655149515337070132,
|
||||
1145824452519314725,
|
||||
3846770256925560569,
|
||||
3807502156582598786,
|
||||
4284949320785450865,
|
||||
5463447640980279236,
|
||||
8578871918181236609,
|
||||
6750440049024086587,
|
||||
3339599426223341161,
|
||||
5148895169070562838,
|
||||
1493666528525752601,
|
||||
1713554459881080228,
|
||||
4150470519566206911,
|
||||
1347402746269051958,
|
||||
3578612018159256808,
|
||||
425785191804166217,
|
||||
8254121249433835847,
|
||||
3260701926561129943,
|
||||
1411768577036936240,
|
||||
3285208643537017688,
|
||||
737986167355114438,
|
||||
1471784905273036181,
|
||||
5967745367608513818,
|
||||
3781216447842245147,
|
||||
4774459486579224459,
|
||||
4710920497926776490,
|
||||
5779037855201976894
|
||||
2499283573021220255,
|
||||
8033579885162383068,
|
||||
1952071260038453057,
|
||||
2098905203823335614,
|
||||
5098537545549490547,
|
||||
4505830566611664829,
|
||||
9194073792736219759,
|
||||
6400665728063187402,
|
||||
4938773340256184018,
|
||||
5860541308324630662,
|
||||
5189216366882819742,
|
||||
2655149515337070132,
|
||||
1145824452519314725,
|
||||
3846770256925560569,
|
||||
3807502156582598786,
|
||||
4284949320785450865,
|
||||
5463447640980279236,
|
||||
8578871918181236609,
|
||||
6750440049024086587,
|
||||
3339599426223341161,
|
||||
5148895169070562838,
|
||||
1493666528525752601,
|
||||
1713554459881080228,
|
||||
4150470519566206911,
|
||||
1347402746269051958,
|
||||
3578612018159256808,
|
||||
425785191804166217,
|
||||
8254121249433835847,
|
||||
3260701926561129943,
|
||||
1411768577036936240,
|
||||
3285208643537017688,
|
||||
737986167355114438,
|
||||
1471784905273036181,
|
||||
5967745367608513818,
|
||||
3781216447842245147,
|
||||
4774459486579224459,
|
||||
4710920497926776490,
|
||||
5779037855201976894
|
||||
)
|
||||
const val MANGADEX_DOMAIN = "mangadex.org"
|
||||
|
||||
@@ -16,8 +16,10 @@ fun OkHttpClient.Builder.injectPatches(sourceIdProducer: () -> Long): OkHttpClie
|
||||
}
|
||||
|
||||
fun findAndApplyPatches(sourceId: Long): EHInterceptor {
|
||||
return ((EH_INTERCEPTORS[sourceId] ?: emptyList()) +
|
||||
(EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR] ?: emptyList())).merge()
|
||||
return (
|
||||
(EH_INTERCEPTORS[sourceId] ?: emptyList()) +
|
||||
(EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR] ?: emptyList())
|
||||
).merge()
|
||||
}
|
||||
|
||||
fun List<EHInterceptor>.merge(): EHInterceptor {
|
||||
@@ -30,12 +32,12 @@ fun List<EHInterceptor>.merge(): EHInterceptor {
|
||||
|
||||
private const val EH_UNIVERSAL_INTERCEPTOR = -1L
|
||||
private val EH_INTERCEPTORS: Map<Long, List<EHInterceptor>> = mapOf(
|
||||
EH_UNIVERSAL_INTERCEPTOR to listOf(
|
||||
CAPTCHA_DETECTION_PATCH // Auto captcha detection
|
||||
),
|
||||
EH_UNIVERSAL_INTERCEPTOR to listOf(
|
||||
CAPTCHA_DETECTION_PATCH // Auto captcha detection
|
||||
),
|
||||
|
||||
// MangaDex login support
|
||||
*MANGADEX_SOURCE_IDS.map { id ->
|
||||
id to listOf(MANGADEX_LOGIN_PATCH)
|
||||
}.toTypedArray()
|
||||
// MangaDex login support
|
||||
*MANGADEX_SOURCE_IDS.map { id ->
|
||||
id to listOf(MANGADEX_LOGIN_PATCH)
|
||||
}.toTypedArray()
|
||||
)
|
||||
|
||||
@@ -13,9 +13,9 @@ val CAPTCHA_DETECTION_PATCH: EHInterceptor = { request, response, sourceId ->
|
||||
if (doc.getElementsByClass("g-recaptcha").isNotEmpty()) {
|
||||
// Found it, allow the user to solve this thing
|
||||
BrowserActionActivity.launchUniversal(
|
||||
Injekt.get<Application>(),
|
||||
sourceId,
|
||||
request.url.toString()
|
||||
Injekt.get<Application>(),
|
||||
sourceId,
|
||||
request.url.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user