HentaiFox: Fix thumbnails on mobile UAs (#691)

This commit is contained in:
beerpsi 2024-01-27 14:41:31 +07:00 committed by GitHub
parent 84b0d91aa2
commit 9912e4a598
2 changed files with 12 additions and 4 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'HentaiFox'
extClass = '.HentaiFox'
extVersionCode = 4
extVersionCode = 5
isNsfw = true
}

View File

@ -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<Page> = throw UnsupportedOperationException()
@ -212,4 +212,12 @@ class HentaiFox : ParsedHttpSource() {
Filter.Select<String>(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")
}
}