From c423d85e2e1bcc5bec91bc8975d92474110febd7 Mon Sep 17 00:00:00 2001 From: Chopper <156493704+choppeh@users.noreply.github.com> Date: Fri, 4 Oct 2024 04:56:07 -0300 Subject: [PATCH] TheBlank: Add random UA (#5351) Add random UA --- src/en/theblank/build.gradle | 6 +++- .../extension/en/theblank/TheBlank.kt | 33 +++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/en/theblank/build.gradle b/src/en/theblank/build.gradle index b0861ff02..6d1a36bcd 100644 --- a/src/en/theblank/build.gradle +++ b/src/en/theblank/build.gradle @@ -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') +} diff --git a/src/en/theblank/src/eu/kanade/tachiyomi/extension/en/theblank/TheBlank.kt b/src/en/theblank/src/eu/kanade/tachiyomi/extension/en/theblank/TheBlank.kt index 054bb64af..d4e3902fa 100644 --- a/src/en/theblank/src/eu/kanade/tachiyomi/extension/en/theblank/TheBlank.kt +++ b/src/en/theblank/src/eu/kanade/tachiyomi/extension/en/theblank/TheBlank.kt @@ -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().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) + } }