From fb4eb99065898e01b3431fe74f77ec2dd3d9858d Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Sat, 1 Jun 2024 09:22:29 +0500 Subject: [PATCH] Mangago: fix descrambling (#3313) * Mangago: fix descrambling * bump --- src/en/mangago/build.gradle | 2 +- .../kanade/tachiyomi/extension/en/mangago/Mangago.kt | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/en/mangago/build.gradle b/src/en/mangago/build.gradle index 8fe00a75b..b8672abbc 100644 --- a/src/en/mangago/build.gradle +++ b/src/en/mangago/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Mangago' extClass = '.Mangago' - extVersionCode = 14 + extVersionCode = 15 isNsfw = true } diff --git a/src/en/mangago/src/eu/kanade/tachiyomi/extension/en/mangago/Mangago.kt b/src/en/mangago/src/eu/kanade/tachiyomi/extension/en/mangago/Mangago.kt index e200bc7aa..9c61dbb77 100644 --- a/src/en/mangago/src/eu/kanade/tachiyomi/extension/en/mangago/Mangago.kt +++ b/src/en/mangago/src/eu/kanade/tachiyomi/extension/en/mangago/Mangago.kt @@ -44,9 +44,10 @@ class Mangago : ParsedHttpSource() { override val client = network.cloudflareClient.newBuilder() .rateLimit(1, 2) .addInterceptor { chain -> - val response = chain.proceed(chain.request()) + val request = chain.request() + val response = chain.proceed(request) - val fragment = response.request.url.fragment ?: return@addInterceptor response + val fragment = request.url.fragment ?: return@addInterceptor response // desckey=...&cols=... val key = fragment.substringAfter("desckey=").substringBefore("&") @@ -226,9 +227,7 @@ class Mangago : ParsedHttpSource() { // This usually means that the list is already unscrambled. } - val cols = deobfChapterJs - .substringAfter("var widthnum=heightnum=") - .substringBefore(";") + val cols = colsRegex.find(deobfChapterJs)?.groupValues?.get(1) ?: "" return imageList .split(",") @@ -458,6 +457,9 @@ class Mangago : ParsedHttpSource() { Regex("""var imgsrcs\s*=\s*['"]([a-zA-Z0-9+=/]+)['"]""") } + private val colsRegex = + Regex("""var\s*widthnum\s*=\s*heightnum\s*=\s*(\d+);""") + private val replacePosBytecode by lazy { QuickJs.create().use { it.compile(