[ExHentai] Option to hide suspicious content

Koitharu 3 years ago
parent 918318252e
commit e1d22b1110
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -10,4 +10,8 @@ sealed class ConfigKey<T>(
override val defaultValue: String, override val defaultValue: String,
val presetValues: Array<String>?, val presetValues: Array<String>?,
) : ConfigKey<String>("domain") ) : ConfigKey<String>("domain")
class ShowSuspiciousContent(
override val defaultValue: Boolean,
) : ConfigKey<Boolean>("show_suspicious")
} }

@ -37,6 +37,7 @@ internal class ExHentaiParser(
private val authCookies = arrayOf("ipb_member_id", "ipb_pass_hash") private val authCookies = arrayOf("ipb_member_id", "ipb_pass_hash")
private var updateDm = false private var updateDm = false
private val nextPages = SparseArrayCompat<Long>() private val nextPages = SparseArrayCompat<Long>()
private val suspiciousContentKey = ConfigKey.ShowSuspiciousContent(true)
override val isAuthorized: Boolean override val isAuthorized: Boolean
get() { get() {
@ -98,7 +99,10 @@ internal class ExHentaiParser(
if (updateDm) { if (updateDm) {
append("&inline_set=dm_e") append("&inline_set=dm_e")
} }
append("&advsearch=1&f_sh=on") append("&advsearch=1")
if (config[suspiciousContentKey]) {
append("&f_sh=on")
}
} }
val body = context.httpGet(url).parseHtml().body() val body = context.httpGet(url).parseHtml().body()
val root = body.selectFirst("table.itg") val root = body.selectFirst("table.itg")
@ -235,6 +239,11 @@ internal class ExHentaiParser(
return username return username
} }
override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) {
super.onCreateConfig(keys)
keys.add(suspiciousContentKey)
}
private fun isAuthorized(domain: String): Boolean { private fun isAuthorized(domain: String): Boolean {
val cookies = context.cookieJar.getCookies(domain).mapToSet { x -> x.name } val cookies = context.cookieJar.getCookies(domain).mapToSet { x -> x.name }
return authCookies.all { it in cookies } return authCookies.all { it in cookies }

Loading…
Cancel
Save