Update HiAnime.kt

Has added z.is and .nz and removed .bz as it is giving phising altert
This commit is contained in:
Arkai1 2025-04-17 10:06:12 +05:30 committed by GitHub
parent 20620df4fe
commit 85cfd67d11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -66,8 +66,8 @@ class HiAnime : ZoroTheme(
ListPreference(screen.context).apply {
key = PREF_DOMAIN_KEY
title = "Preferred domain"
entries = arrayOf("hianimez.to", "hianime.to", "hianime.bz", "hianime.pe")
entryValues = arrayOf("https://hianimez.to", "https://hianime.to", "https://hianime.bz", "https://hianime.pe")
entries = arrayOf("hianimez.to", "hianimez.is", "hianime.to", "hianime.nz", "hianime.pe")
entryValues = arrayOf("https://hianimez.to", "https://hianimez.is", "https://hianime.to", "https://hianime.nz", "https://hianime.pe")
setDefaultValue(PREF_DOMAIN_DEFAULT)
summary = "%s"
@ -95,19 +95,24 @@ class HiAnime : ZoroTheme(
private const val PREF_DOMAIN_KEY = "preferred_domain"
private const val PREF_DOMAIN_DEFAULT = "https://hianimez.to"
private val allowedDomains = listOf(
// Updated property name to follow screaming snake case
private val ALLOWED_DOMAINS = listOf(
"https://hianimez.to",
"https://hianimez.is",
"https://hianime.to",
"https://hianime.bz",
"https://hianime.nz",
"https://hianime.pe",
)
fun getPreferredDomain(): String {
// Initialize custom SharedPreferences for the extension
fun getPreferredDomain(preferences: SharedPreferences): String {
// Fetch the saved domain from SharedPreferences
val preferences = androidx.preference.PreferenceManager.getDefaultSharedPreferences(eu.kanade.tachiyomi.App.INSTANCE)
val domain = preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT) ?: PREF_DOMAIN_DEFAULT
// Validate the domain against the allowed list
return if (allowedDomains.contains(domain)) domain else PREF_DOMAIN_DEFAULT
return if (ALLOWED_DOMAINS.contains(domain)) domain else PREF_DOMAIN_DEFAULT
}
fun createPreferences(context: Context): SharedPreferences {
return context.getSharedPreferences("source_${this::class.java.simpleName}", Context.MODE_PRIVATE)
}
}