From cbecaa4406de26d4d8e5a7087494e786d6b40493 Mon Sep 17 00:00:00 2001 From: OncePunchedMan <64155117+OncePunchedMan@users.noreply.github.com> Date: Wed, 6 Jan 2021 02:07:22 +0100 Subject: [PATCH] randomize user agent (#5327) --- src/fr/scantrad/build.gradle | 2 +- .../kanade/tachiyomi/extension/fr/scantrad/Scantrad.kt | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fr/scantrad/build.gradle b/src/fr/scantrad/build.gradle index 3d39f5802..01942a1ac 100644 --- a/src/fr/scantrad/build.gradle +++ b/src/fr/scantrad/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Scantrad' pkgNameSuffix = 'fr.scantrad' extClass = '.Scantrad' - extVersionCode = 8 + extVersionCode = 9 libVersion = '1.2' } diff --git a/src/fr/scantrad/src/eu/kanade/tachiyomi/extension/fr/scantrad/Scantrad.kt b/src/fr/scantrad/src/eu/kanade/tachiyomi/extension/fr/scantrad/Scantrad.kt index 7005fe0c6..e34bc7463 100644 --- a/src/fr/scantrad/src/eu/kanade/tachiyomi/extension/fr/scantrad/Scantrad.kt +++ b/src/fr/scantrad/src/eu/kanade/tachiyomi/extension/fr/scantrad/Scantrad.kt @@ -19,6 +19,8 @@ import rx.Observable import java.text.SimpleDateFormat import java.util.Calendar import java.util.Locale +import kotlin.math.absoluteValue +import kotlin.random.Random class Scantrad : ParsedHttpSource() { @@ -32,8 +34,10 @@ class Scantrad : ParsedHttpSource() { override val client: OkHttpClient = network.cloudflareClient + protected open val userAgentRandomizer = " ${Random.nextInt().absoluteValue}" + override fun headersBuilder() = Headers.Builder().apply { - add("User-Agent", USER_AGENT) + add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36$userAgentRandomizer") } // Popular @@ -207,7 +211,4 @@ class Scantrad : ParsedHttpSource() { override fun getFilterList() = FilterList() - companion object { - private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36" - } }