LuraToon: Add random user agent (#2967)

Add random user agent
This commit is contained in:
Chopper 2024-05-12 01:26:59 -03:00 committed by GitHub
parent c91b8bad17
commit c42bfff6f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 2 deletions

View File

@ -3,7 +3,11 @@ ext {
extClass = '.LuraToon'
themePkg = 'peachscan'
baseUrl = 'https://luratoon.com'
overrideVersionCode = 39
overrideVersionCode = 40
}
apply from: "$rootDir/common.gradle"
dependencies {
implementation project(':lib:randomua')
}

View File

@ -1,10 +1,39 @@
package eu.kanade.tachiyomi.extension.pt.randomscan
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.peachscan.PeachScan
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.ConfigurableSource
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class LuraToon :
PeachScan(
"Lura Toon",
"https://luratoon.com",
"pt-BR",
),
ConfigurableSource {
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}
class LuraToon : PeachScan("Lura Toon", "https://luratoon.com", "pt-BR") {
override val client = super.client.newBuilder()
.rateLimit(1, 2)
.setRandomUserAgent(
preferences.getPrefUAType(),
preferences.getPrefCustomUA(),
)
.build()
override fun setupPreferenceScreen(screen: PreferenceScreen) {
addRandomUAPreferenceToScreen(screen)
}
}