From 058aeaa54e6195756213ebe6aa819747143dc894 Mon Sep 17 00:00:00 2001 From: Chopper <156493704+choppeh@users.noreply.github.com> Date: Sat, 8 Jun 2024 02:16:23 -0300 Subject: [PATCH] Hiperdex: Add randomUA (#3459) Add randomUA --- src/en/hiperdex/build.gradle | 6 +++++- .../kanade/tachiyomi/extension/en/hiperdex/Hiperdex.kt | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/en/hiperdex/build.gradle b/src/en/hiperdex/build.gradle index 1ef2f29e3..5ce478df1 100644 --- a/src/en/hiperdex/build.gradle +++ b/src/en/hiperdex/build.gradle @@ -3,8 +3,12 @@ ext { extClass = '.Hiperdex' themePkg = 'madara' baseUrl = 'https://hiperdex.com' - overrideVersionCode = 11 + overrideVersionCode = 12 isNsfw = true } apply from: "$rootDir/common.gradle" + +dependencies { + implementation project(':lib:randomua') +} diff --git a/src/en/hiperdex/src/eu/kanade/tachiyomi/extension/en/hiperdex/Hiperdex.kt b/src/en/hiperdex/src/eu/kanade/tachiyomi/extension/en/hiperdex/Hiperdex.kt index f72335994..6f0a60ad2 100644 --- a/src/en/hiperdex/src/eu/kanade/tachiyomi/extension/en/hiperdex/Hiperdex.kt +++ b/src/en/hiperdex/src/eu/kanade/tachiyomi/extension/en/hiperdex/Hiperdex.kt @@ -5,6 +5,10 @@ import android.content.SharedPreferences import android.widget.Toast import androidx.preference.EditTextPreference 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.source.ConfigurableSource import okhttp3.HttpUrl.Companion.toHttpUrl @@ -30,6 +34,10 @@ class Hiperdex : override val client = super.client.newBuilder() .addInterceptor(::domainChangeIntercept) + .setRandomUserAgent( + preferences.getPrefUAType(), + preferences.getPrefCustomUA(), + ) .build() private var lastDomain = "" @@ -102,6 +110,7 @@ class Hiperdex : } } screen.addPreference(baseUrlPref) + addRandomUAPreferenceToScreen(screen) } private var SharedPreferences.baseUrlHost