TheBlank: Add random UA (#5351)

Add random UA
This commit is contained in:
Chopper 2024-10-04 04:56:07 -03:00 committed by Draff
parent f584c2d169
commit c423d85e2e
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 32 additions and 7 deletions

View File

@ -3,8 +3,12 @@ ext {
extClass = '.TheBlank'
themePkg = 'madara'
baseUrl = 'https://theblank.net'
overrideVersionCode = 1
overrideVersionCode = 2
isNsfw = true
}
apply from: "$rootDir/common.gradle"
dependencies {
implementation project(':lib:randomua')
}

View File

@ -1,22 +1,43 @@
package eu.kanade.tachiyomi.extension.en.theblank
import android.app.Application
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.rateLimit
import eu.kanade.tachiyomi.source.ConfigurableSource
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.text.SimpleDateFormat
import java.util.Locale
class TheBlank : Madara(
"The Blank Scanlation",
"https://theblank.net",
"en",
dateFormat = SimpleDateFormat("dd/MM/yy", Locale.US),
) {
class TheBlank :
Madara(
"The Blank Scanlation",
"https://theblank.net",
"en",
dateFormat = SimpleDateFormat("dd/MM/yy", Locale.US),
),
ConfigurableSource {
private val preferences = Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
override val client = super.client.newBuilder()
.rateLimit(1)
.setRandomUserAgent(
preferences.getPrefUAType(),
preferences.getPrefCustomUA(),
)
.build()
override val useNewChapterEndpoint = true
override val useLoadMoreRequest = LoadMoreStrategy.Always
override fun chapterListSelector() = "li.wp-manga-chapter:not(.vip-permission)"
override fun setupPreferenceScreen(screen: PreferenceScreen) {
addRandomUAPreferenceToScreen(screen)
}
}