MangaMate: Add random user agent (#3231)
* Add random user agent * Cleanup
This commit is contained in:
parent
e2bca12ccd
commit
02af60dcf5
|
@ -3,8 +3,12 @@ ext {
|
|||
extClass = '.MangaMate'
|
||||
themePkg = 'mangathemesia'
|
||||
baseUrl = 'https://manga-mate.org'
|
||||
overrideVersionCode = 0
|
||||
overrideVersionCode = 1
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
||||
dependencies {
|
||||
implementation project(':lib:randomua')
|
||||
}
|
||||
|
|
|
@ -1,14 +1,44 @@
|
|||
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.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 MangaMate : MangaThemesia(
|
||||
"漫画メイト",
|
||||
"https://manga-mate.org",
|
||||
"ja",
|
||||
dateFormat = SimpleDateFormat("MMMM d, yyyy", Locale("ja")),
|
||||
) {
|
||||
class MangaMate :
|
||||
MangaThemesia(
|
||||
"漫画メイト",
|
||||
"https://manga-mate.org",
|
||||
"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 fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
addRandomUAPreferenceToScreen(screen)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue