MG Komik: fix cf block, pagination (#3777)

This commit is contained in:
Luqman 2024-06-28 18:00:50 +07:00 committed by Draff
parent 72905b0433
commit af9252e798
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 38 additions and 1 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.MGKomik' extClass = '.MGKomik'
themePkg = 'madara' themePkg = 'madara'
baseUrl = 'https://mgkomik.id' baseUrl = 'https://mgkomik.id'
overrideVersionCode = 13 overrideVersionCode = 14
isNsfw = false isNsfw = false
} }

View File

@ -1,6 +1,9 @@
package eu.kanade.tachiyomi.extension.id.mgkomik package eu.kanade.tachiyomi.extension.id.mgkomik
import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import okhttp3.Request
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
@ -15,7 +18,41 @@ class MGKomik : Madara(
override val mangaSubString = "komik" override val mangaSubString = "komik"
override fun headersBuilder() = super.headersBuilder().apply {
add("Sec-Fetch-Dest", "document")
add("Sec-Fetch-Mode", "navigate")
add("Sec-Fetch-Site", "same-origin")
add("Upgrade-Insecure-Requests", "1")
add("X-Requested-With", randomString((1..20).random())) // added for webview, and removed in interceptor for normal use
}
override val client = network.cloudflareClient.newBuilder()
.addInterceptor { chain ->
val request = chain.request()
val headers = request.headers.newBuilder().apply {
removeAll("X-Requested-With")
}.build()
chain.proceed(request.newBuilder().headers(headers).build())
}
.rateLimit(9, 2)
.build()
override fun popularMangaNextPageSelector() = ".wp-pagenavi span.current + a"
override fun searchMangaNextPageSelector() = "a.page.larger" override fun searchMangaNextPageSelector() = "a.page.larger"
override fun latestUpdatesRequest(page: Int): Request =
if (useLoadMoreRequest()) {
loadMoreRequest(page, popular = false)
} else {
GET("$baseUrl/$mangaSubString/${searchPage(page)}", headers)
}
override val chapterUrlSuffix = "" override val chapterUrlSuffix = ""
private fun randomString(length: Int): String {
val charPool = ('a'..'z') + ('A'..'Z') + ('.')
return List(length) { charPool.random() }.joinToString("")
}
} }