From 9912e4a5989d7a0bcb77121e66665d15b3cefe8d Mon Sep 17 00:00:00 2001 From: beerpsi <92439990+beerpiss@users.noreply.github.com> Date: Sat, 27 Jan 2024 14:41:31 +0700 Subject: [PATCH] HentaiFox: Fix thumbnails on mobile UAs (#691) --- src/en/hentaifox/build.gradle | 2 +- .../tachiyomi/extension/en/hentaifox/HentaiFox.kt | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/en/hentaifox/build.gradle b/src/en/hentaifox/build.gradle index cea483e5d..56d8b1706 100644 --- a/src/en/hentaifox/build.gradle +++ b/src/en/hentaifox/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'HentaiFox' extClass = '.HentaiFox' - extVersionCode = 4 + extVersionCode = 5 isNsfw = true } diff --git a/src/en/hentaifox/src/eu/kanade/tachiyomi/extension/en/hentaifox/HentaiFox.kt b/src/en/hentaifox/src/eu/kanade/tachiyomi/extension/en/hentaifox/HentaiFox.kt index b0fb34677..4301bd986 100644 --- a/src/en/hentaifox/src/eu/kanade/tachiyomi/extension/en/hentaifox/HentaiFox.kt +++ b/src/en/hentaifox/src/eu/kanade/tachiyomi/extension/en/hentaifox/HentaiFox.kt @@ -46,7 +46,7 @@ class HentaiFox : ParsedHttpSource() { title = it.text() setUrlWithoutDomain(it.attr("href")) } - thumbnail_url = element.select("img").first()!!.attr("abs:src") + thumbnail_url = element.selectFirst("img")!!.imgAttr() } } @@ -98,7 +98,7 @@ class HentaiFox : ParsedHttpSource() { title = info.select("h1").text() genre = info.select("ul.tags a").joinToString { it.ownText() } artist = info.select("ul.artists a").joinToString { it.ownText() } - thumbnail_url = info.select("img").attr("abs:src") + thumbnail_url = info.select("img").first()!!.imgAttr() description = info.select("ul.parodies a") .let { e -> if (e.isNotEmpty()) "Parodies: ${e.joinToString { it.ownText() }}\n\n" else "" } description += info.select("ul.characters a") @@ -137,7 +137,7 @@ class HentaiFox : ParsedHttpSource() { } override fun imageUrlParse(document: Document): String { - return document.select("img#gimg").attr("abs:data-src") + return document.selectFirst("img#gimg")!!.imgAttr() } override fun pageListParse(document: Document): List = throw UnsupportedOperationException() @@ -212,4 +212,12 @@ class HentaiFox : ParsedHttpSource() { Filter.Select(displayName, vals.map { it.first }.toTypedArray()) { fun toUriPart() = vals[state].second } + + private fun Element.imgAttr() = when { + hasAttr("data-cfsrc") -> absUrl("data-cfsrc") + hasAttr("data-src") -> absUrl("data-src") + hasAttr("data-lazy-src") -> absUrl("data-lazy-src") + hasAttr("srcset") -> absUrl("srcset").substringBefore(" ") + else -> absUrl("src") + } }