Skip to content

Scan-Manga: migrate to www, fix browse and reader#17584

Open
ultimeus wants to merge 1 commit into
keiyoushi:mainfrom
ultimeus:scanmanga-www
Open

Scan-Manga: migrate to www, fix browse and reader#17584
ultimeus wants to merge 1 commit into
keiyoushi:mainfrom
ultimeus:scanmanga-www

Conversation

@ultimeus

Copy link
Copy Markdown

Closes #17374

The Scan-Manga source broke after the site's redesign, and the recent @Source migration also left domain pointing at an invalid subdomain.

Problem

  • m.scan-manga.com now 302-redirects desktop User-Agents to www.scan-manga.com (a different layout), so the old mobile selectors matched nothing. It also returns a Cloudflare 403 to mobile User-Agents, which FlareSolverr can't solve (it solves with a desktop UA, so cf_clearance is UA-mismatched) — so switching to a mobile UA isn't viable.
  • private val domain = baseUrl.toHttpUrl().host resolved to m.scan-manga.com, producing the invalid static.m.scan-manga.com / bqj.m.scan-manga.com subdomains ([FR] Scan-Manga: Broken extension due to hardcoded invalid subdomain #17374).

Changes

  • Retarget baseUrl to https://www.scan-manga.com and derive domain with topPrivateDomain(), so the static. (images) and bqj. (search) subdomains resolve correctly.
  • Rewrite the browse parsers for the current www DOM:
    • Popular (/TOP-Manga-Webtoon-45.html): div.image_manga.image_listing
    • Latest (/?po): div.listing:has(a.nom_manga)
    • Details: schema.org itemprop selectors; status from div.titre_volume_manga span
    • Chapters: li.chapitre > div.chapitre_nom a
  • Fix the reader: the packed reader script is now wrapped as eval(/*EB*/function (...)) (the /*EB*/ comment defeated the old literal selector/regex) and const idc moved to a separate inline <script>. Locate the packed script via the (comment-tolerant) Hunter regex and read idc from the whole document. The decryption itself (Hunter unpack → sml/smelel API → pako inflate) is unchanged.
  • Add search-by-URL: pasting a scan-manga manga URL into the search box opens that title directly. Useful because 18+ titles are hidden from the anonymous search/listings, but their detail/chapter/reader pages load fine.
  • Bump versionCode 23 → 24.

Testing

Compiled with Gradle and run through Tachidesk/Suwayomi (with FlareSolverr): Popular, Latest, Search, details, chapter list, and the reader all work.


Checklist:

  • Updated versionCode value in build.gradle.kts
  • Updated baseVersionCode in build.gradle.kts (if updated multisrc theme code) — N/A (not multisrc)
  • Referenced all related issues in the PR body (e.g. "Closes #xyz")
  • Set the contentWarning configuration in build.gradle.kts appropriately
  • Have not changed source names
  • Source name and language are unchanged, so the source id is unchanged
  • Have tested the modifications by compiling (Gradle) and running the extension (Tachidesk/Suwayomi)
  • Have removed web_hi_res_512.png when adding a new extension — N/A (not a new extension)
  • This PR is AI-assisted, I have reviewed the changes manually and confirmed they are not slop


// Search
// Adult (18+) titles are hidden from the anonymous search API and browse listings, but
// their detail/chapter/reader pages load fine anonymously. Allow pasting a manga URL into

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add deeplink {} block in build.gradle.kts too

@AwkwardPeak7

Copy link
Copy Markdown
Contributor

302-redirects desktop User-Agents

mihon defaults to mobile useragent, have you tested it there?

}

thumbnail_url = document.select("div.full_img_serie img[itemprop=image]").attr("src")
thumbnail_url = document.selectFirst("meta[itemprop=image]")?.attr("content")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
thumbnail_url = document.selectFirst("meta[itemprop=image]")?.attr("content")
thumbnail_url = document.selectFirst("meta[itemprop=image]")?.absUrl("content")

name = if (!extraTitle.isNullOrEmpty()) "$chapterName - $extraTitle" else chapterName
setUrlWithoutDomain(linkEl.absUrl("href"))
name = linkEl.text()
setUrlWithoutDomain(linkEl.attr("href"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove .absUrl here.

Suggested change
setUrlWithoutDomain(linkEl.attr("href"))
setUrlWithoutDomain(linkEl.absUrl("href"))

description = document.selectFirst("div.titres_desc[itemprop=description]")?.text()
genre = document.selectFirst("div.titres_souspart span[itemprop=genre]")?.text()
title = document.selectFirst("[itemprop=name][content]")?.attr("content")
?: document.selectFirst("h1")?.text().orEmpty()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title should never be empty.

Suggested change
?: document.selectFirst("h1")?.text().orEmpty()
?: document.selectFirst("h1")!!.text()

?: img?.absUrl("src")
}
}
}.distinctBy { it.url }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code might hide faulty logic. Can it be avoided?

Suggested change
}.distinctBy { it.url }
}

setUrlWithoutDomain(link.attr("href"))
title = link.text()
val img = element.selectFirst("div.logo_manga img")
thumbnail_url = img?.attr("data-original")?.takeIf { it.isNotBlank() }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.absUrl is preferred, and still empty if the attribute is not present, according to Jsoup docs.

Suggested change
thumbnail_url = img?.attr("data-original")?.takeIf { it.isNotBlank() }
thumbnail_url = img?.absUrl("data-original")?.takeIf { it.isNotEmpty() }

title = titleElement.text()
setUrlWithoutDomain(titleElement.attr("href"))
thumbnail_url = element.selectFirst("img")?.attr("data-original")
setUrlWithoutDomain(link.attr("href"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setUrlWithoutDomain(link.attr("href"))
setUrlWithoutDomain(link.absUrl("href"))

setUrlWithoutDomain(titleElement.attr("href"))
thumbnail_url = element.selectFirst("img")?.attr("data-original")
setUrlWithoutDomain(link.attr("href"))
title = img?.attr("title")?.takeIf { it.isNotBlank() } ?: link.text()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title = img?.attr("title")?.takeIf { it.isNotBlank() } ?: link.text()
title = img?.attr("title")?.takeIf { it.isNotEmpty() } ?: link.text()

thumbnail_url = element.selectFirst("img")?.attr("data-original")
setUrlWithoutDomain(link.attr("href"))
title = img?.attr("title")?.takeIf { it.isNotBlank() } ?: link.text()
thumbnail_url = img?.attr("data-original")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
thumbnail_url = img?.attr("data-original")
thumbnail_url = img?.absUrl("data-original")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Scan-Manga: Broken extension due to hardcoded invalid subdomain

3 participants