diff --git a/src/es/emperorscan/build.gradle b/src/es/emperorscan/build.gradle index f42202e2b..6bf183350 100644 --- a/src/es/emperorscan/build.gradle +++ b/src/es/emperorscan/build.gradle @@ -3,7 +3,11 @@ ext { extClass = '.EmperorScan' themePkg = 'madara' baseUrl = 'https://emperorscan.com' - overrideVersionCode = 1 + overrideVersionCode = 2 } apply from: "$rootDir/common.gradle" + +dependencies { + implementation(project(':lib:randomua')) +} diff --git a/src/es/emperorscan/src/eu/kanade/tachiyomi/extension/es/emperorscan/EmperorScan.kt b/src/es/emperorscan/src/eu/kanade/tachiyomi/extension/es/emperorscan/EmperorScan.kt index 8fb494f3e..6cee947b6 100644 --- a/src/es/emperorscan/src/eu/kanade/tachiyomi/extension/es/emperorscan/EmperorScan.kt +++ b/src/es/emperorscan/src/eu/kanade/tachiyomi/extension/es/emperorscan/EmperorScan.kt @@ -1,14 +1,47 @@ package eu.kanade.tachiyomi.extension.es.emperorscan +import android.app.Application +import android.content.SharedPreferences +import androidx.preference.PreferenceScreen +import eu.kanade.tachiyomi.lib.randomua.addRandomUAPreferenceToScreen +import eu.kanade.tachiyomi.lib.randomua.getPrefCustomUA +import eu.kanade.tachiyomi.lib.randomua.getPrefUAType +import eu.kanade.tachiyomi.lib.randomua.setRandomUserAgent import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.network.interceptor.rateLimitHost +import eu.kanade.tachiyomi.source.ConfigurableSource +import okhttp3.HttpUrl.Companion.toHttpUrl +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get import java.text.SimpleDateFormat import java.util.Locale -class EmperorScan : Madara( - "Emperor Scan", - "https://emperorscan.com", - "es", - SimpleDateFormat("MMMM dd, yyyy", Locale("es")), -) { - override val mangaDetailsSelectorDescription = "div.sinopsis div.contenedor" +class EmperorScan : + Madara( + "Emperor Scan", + "https://emperorscan.com", + "es", + SimpleDateFormat("MMMM dd, yyyy", Locale("es")), + ), + ConfigurableSource { + + private val preferences: SharedPreferences = + Injekt.get().getSharedPreferences("source_$id", 0x0000) + + override val useLoadMoreRequest = LoadMoreStrategy.Never + override val useNewChapterEndpoint = true + + override val client = super.client.newBuilder() + .setRandomUserAgent( + preferences.getPrefUAType(), + preferences.getPrefCustomUA(), + ) + .rateLimitHost(baseUrl.toHttpUrl(), 2) + .build() + + override val mangaDetailsSelectorDescription = "div.tab-summary div.sinopsis p" + + override fun setupPreferenceScreen(screen: PreferenceScreen) { + addRandomUAPreferenceToScreen(screen) + } }