diff --git a/src/id/mgkomik/build.gradle b/src/id/mgkomik/build.gradle index 83c279a4b..86d009fb9 100644 --- a/src/id/mgkomik/build.gradle +++ b/src/id/mgkomik/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.MGKomik' themePkg = 'madara' baseUrl = 'https://mgkomik.id' - overrideVersionCode = 13 + overrideVersionCode = 14 isNsfw = false } diff --git a/src/id/mgkomik/src/eu/kanade/tachiyomi/extension/id/mgkomik/MGKomik.kt b/src/id/mgkomik/src/eu/kanade/tachiyomi/extension/id/mgkomik/MGKomik.kt index 4780e5644..5ae926e41 100644 --- a/src/id/mgkomik/src/eu/kanade/tachiyomi/extension/id/mgkomik/MGKomik.kt +++ b/src/id/mgkomik/src/eu/kanade/tachiyomi/extension/id/mgkomik/MGKomik.kt @@ -1,6 +1,9 @@ package eu.kanade.tachiyomi.extension.id.mgkomik 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.util.Locale @@ -15,7 +18,41 @@ class MGKomik : Madara( 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 latestUpdatesRequest(page: Int): Request = + if (useLoadMoreRequest()) { + loadMoreRequest(page, popular = false) + } else { + GET("$baseUrl/$mangaSubString/${searchPage(page)}", headers) + } + override val chapterUrlSuffix = "" + + private fun randomString(length: Int): String { + val charPool = ('a'..'z') + ('A'..'Z') + ('.') + return List(length) { charPool.random() }.joinToString("") + } }