MangaMate: Add random user agent (#3231)

* Add random user agent

* Cleanup
This commit is contained in:
Chopper 2024-05-26 04:55:29 -03:00 committed by Draff
parent e2bca12ccd
commit 02af60dcf5
2 changed files with 41 additions and 7 deletions

View File

@ -3,8 +3,12 @@ ext {
extClass = '.MangaMate' extClass = '.MangaMate'
themePkg = 'mangathemesia' themePkg = 'mangathemesia'
baseUrl = 'https://manga-mate.org' baseUrl = 'https://manga-mate.org'
overrideVersionCode = 0 overrideVersionCode = 1
isNsfw = true isNsfw = true
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"
dependencies {
implementation project(':lib:randomua')
}

View File

@ -1,14 +1,44 @@
package eu.kanade.tachiyomi.extension.ja.mangamate package eu.kanade.tachiyomi.extension.ja.mangamate
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.mangathemesia.MangaThemesia import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
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.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
class MangaMate : MangaThemesia( class MangaMate :
"漫画メイト", MangaThemesia(
"https://manga-mate.org", "漫画メイト",
"ja", "https://manga-mate.org",
dateFormat = SimpleDateFormat("MMMM d, yyyy", Locale("ja")), "ja",
) { dateFormat = SimpleDateFormat("MMMM d, yyyy", Locale("ja")),
),
ConfigurableSource {
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}
override val client = super.client.newBuilder()
.setRandomUserAgent(
preferences.getPrefUAType(),
preferences.getPrefCustomUA(),
)
.rateLimit(3)
.build()
override val seriesAuthorSelector = ".fmed b:contains(作者) + span" override val seriesAuthorSelector = ".fmed b:contains(作者) + span"
override fun setupPreferenceScreen(screen: PreferenceScreen) {
addRandomUAPreferenceToScreen(screen)
}
} }