MangaDistrict: Preset genresList & preserve tagList order when saving (#8004)

This commit is contained in:
Cuong-Tran 2025-03-11 19:33:53 +07:00 committed by Draff
parent fe96b31232
commit 6205dad385
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 119 additions and 13 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.MangaDistrict' extClass = '.MangaDistrict'
themePkg = 'madara' themePkg = 'madara'
baseUrl = 'https://mangadistrict.com' baseUrl = 'https://mangadistrict.com'
overrideVersionCode = 9 overrideVersionCode = 10
isNsfw = true isNsfw = true
} }

View File

@ -37,7 +37,15 @@ class MangaDistrict :
override val mangaSubString = "read-scan" override val mangaSubString = "read-scan"
private val preferences: SharedPreferences by getPreferencesLazy() private val preferences: SharedPreferences by getPreferencesLazy {
try {
val oldTagSet = getStringSet(TAG_LIST_PREF, emptySet())!!
edit()
.remove(TAG_LIST_PREF)
.putString(TAG_LIST_PREF, oldTagSet.joinToString("%"))
.apply()
} catch (_: Exception) {}
}
override fun popularMangaNextPageSelector() = "div[role=navigation] span.current + a.page" override fun popularMangaNextPageSelector() = "div[role=navigation] span.current + a.page"
@ -112,14 +120,12 @@ class MangaDistrict :
} }
private fun loadTagListFromPreferences(): Set<Pair<String, String>> = private fun loadTagListFromPreferences(): Set<Pair<String, String>> =
preferences.getStringSet(TAG_LIST_PREF, emptySet()) preferences.getString(TAG_LIST_PREF, "")
?.mapNotNull { ?.let {
it.split('|') it.split('%').mapNotNull { tag ->
tag.split('|')
.let { splits -> .let { splits ->
if (splits.size == 2) { if (splits.size == 2) splits[0] to splits[1] else null
splits[0] to splits[1]
} else {
null
} }
} }
} }
@ -129,9 +135,9 @@ class MangaDistrict :
private var tagList: Set<Pair<String, String>> = loadTagListFromPreferences() private var tagList: Set<Pair<String, String>> = loadTagListFromPreferences()
set(value) { set(value) {
preferences.edit().putStringSet( preferences.edit().putString(
TAG_LIST_PREF, TAG_LIST_PREF,
value.map { "${it.first}|${it.second}" }.toSet(), value.joinToString("%") { "${it.first}|${it.second}" },
).apply() ).apply()
field = value field = value
} }
@ -155,6 +161,106 @@ class MangaDistrict :
} }
} }
// console.log([...document.querySelectorAll("div.checkbox-group .checkbox")].map((el) => `Genre("${el.querySelector("label").innerText.trim()}", "${el.querySelector("input").getAttribute('value')}"),`).join('\n'))
override var genresList = listOf(
Genre("3D", "3d"),
Genre("Action", "action"),
Genre("Adapted to Anime", "adapted-to-anime"),
Genre("Adventure", "adventure"),
Genre("Aliens", "aliens"),
Genre("Animal Characteristics", "animal-characteristics"),
Genre("Based on Another Work", "based-on-another-work"),
Genre("BL", "bl"),
Genre("BL Uncensored", "bl-uncensored"),
Genre("Borderline H", "borderline-h"),
Genre("Cohabitation", "cohabitation"),
Genre("Collection of Stories", "collection-of-stories"),
Genre("Comedy", "comedy"),
Genre("Comics", "comics"),
Genre("Cooking", "cooking"),
Genre("Coworkers", "coworkers"),
Genre("Crime", "crime"),
Genre("Crossdressing", "crossdressing"),
Genre("Delinquents", "delinquents"),
Genre("Demons", "demons"),
Genre("Detectives", "detectives"),
Genre("Doujinshi", "doujinshi"),
Genre("Drama", "drama"),
Genre("Ecchi", "ecchi"),
Genre("Explicit Sex", "explicit-sex"),
Genre("Fantasy", "fantasy"),
Genre("Fetish", "fetish"),
Genre("Full Color", "full-color"),
Genre("Gender Bender", "gender-bender"),
Genre("Ghosts", "ghosts"),
Genre("GL", "gl"),
Genre("Gyaru", "gyaru"),
Genre("Harem", "harem"),
Genre("Historical", "historical"),
Genre("Horror", "horror"),
Genre("Incest", "incest"),
Genre("Isekai", "isekai"),
Genre("Japanese Webtoons", "japanese-webtoons"),
Genre("Josei", "josei"),
Genre("Light Novels", "light-novels"),
Genre("Mafia", "mafia"),
Genre("Magic", "magic"),
Genre("Magical Girl", "magical-girl"),
Genre("Manhua", "manhua"),
Genre("Manhwa", "manhwa"),
Genre("Martial Arts", "martial-arts"),
Genre("Mature Romance", "mature-romance"),
Genre("Mecha", "mecha"),
Genre("Medical", "medical"),
Genre("Military", "military"),
Genre("Monster Girls", "monster-girls"),
Genre("Monsters", "monsters"),
Genre("Music", "music"),
Genre("Mystery", "mystery"),
Genre("Ninja", "ninja"),
Genre("Nudity", "nudity"),
Genre("One Shot", "one-shot"),
Genre("Person in a Strange World", "person-in-a-strange-world"),
Genre("Police", "police"),
Genre("Psychological", "psychological"),
Genre("Reincarnation", "reincarnation"),
Genre("Reverse Harem", "reverse-harem"),
Genre("Romance", "romance"),
Genre("Salaryman", "salaryman"),
Genre("Samurai", "samurai"),
Genre("School Life", "school-life"),
Genre("Sci Fi", "sci-fi"),
Genre("Seinen", "seinen"),
Genre("Sexual Abuse", "sexual-abuse"),
Genre("Sexual Content", "sexual-content"),
Genre("Shoujo", "shoujo"),
Genre("Shoujo-ai", "shoujo-ai"),
Genre("Shounen", "shounen"),
Genre("Shounen-ai", "shounen-ai"),
Genre("Siblings", "siblings"),
Genre("Slice of Life", "slice-of-life"),
Genre("Smut", "smut"),
Genre("Sports", "sports"),
Genre("Summoned Into Another World", "summoned-into-another-world"),
Genre("Superheroes", "superheroes"),
Genre("Supernatural", "supernatural"),
Genre("Survival", "survival"),
Genre("Thriller", "thriller"),
Genre("Time Travel", "time-travel"),
Genre("Transfer Students", "transfer-students"),
Genre("Uncensored", "uncensored"),
Genre("Vampires", "vampires"),
Genre("Violence", "violence"),
Genre("Virtual Reality", "virtual-reality"),
Genre("Web Novels", "web-novels"),
Genre("Webtoons", "webtoons"),
Genre("Western", "western"),
Genre("Work Life", "work-life"),
Genre("Yaoi", "yaoi"),
Genre("Yuri", "yuri"),
Genre("Zombies", "zombies"),
)
private fun isRemoveTitleVersion() = preferences.getBoolean(REMOVE_TITLE_VERSION_PREF, false) private fun isRemoveTitleVersion() = preferences.getBoolean(REMOVE_TITLE_VERSION_PREF, false)
private fun getImgRes() = preferences.getString(IMG_RES_PREF, IMG_RES_DEFAULT)!! private fun getImgRes() = preferences.getString(IMG_RES_PREF, IMG_RES_DEFAULT)!!