From f62809407b23a0e7948c440e388cab4cbbb29cf1 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 28 Sep 2025 11:33:24 +0300 Subject: [PATCH] [Madaradex] Fixes --- .../parsers/site/madara/en/MadaraDex.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MadaraDex.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MadaraDex.kt index 059c6333..353e4286 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MadaraDex.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/en/MadaraDex.kt @@ -15,17 +15,23 @@ import org.koitharu.kotatsu.parsers.network.UserAgents import org.koitharu.kotatsu.parsers.site.madara.MadaraParser import org.koitharu.kotatsu.parsers.util.* +private const val F_URL = "fullUrl=" + @MangaSourceParser("MADARADEX", "MadaraDex", "en", ContentType.HENTAI) internal class MadaraDex(context: MangaLoaderContext) : MadaraParser(context, MangaParserSource.MADARADEX, "madaradex.org") { + init { + context.cookieJar.insertCookies(domain, "wpmanga-adault=1") + } + override fun onCreateConfig(keys: MutableCollection>) { super.onCreateConfig(keys) keys.remove(userAgentKey) } override fun getRequestHeaders() = super.getRequestHeaders().newBuilder() - .add("sec-fetch-site", "same-site") + .set("User-Agent", UserAgents.CHROME_DESKTOP) .build() override val authUrl: String @@ -66,14 +72,12 @@ internal class MadaraDex(context: MangaLoaderContext) : override fun intercept(chain: Interceptor.Chain): Response { val request = chain.request() val url = request.url - val fullUrl = url.fragment?.substringAfter(F_URL) + val fullUrl = url.fragment?.substringAfter(F_URL, "") return if (!fullUrl.isNullOrEmpty()) { + copyCookies() val cleanUrl = url.newBuilder().fragment(null).toString() val newReq = request.newBuilder() - .header("sec-fetch-site", "same-site") .header("Referer", fullUrl) - .header("User-Agent", UserAgents.CHROME_DESKTOP) - .header("Cookie", context.cookieJar.getCookies(fullUrl).toString()) .url(cleanUrl) .build() chain.proceed(newReq) @@ -82,7 +86,5 @@ internal class MadaraDex(context: MangaLoaderContext) : } } - private companion object { - const val F_URL = "fullUrl=" - } + private fun copyCookies() = context.cookieJar.copyCookies(domain, "cdn.$domain") }