[Remanga] Ability to change user-agent
This commit is contained in:
@@ -3,12 +3,12 @@ package org.koitharu.kotatsu.parsers.network
|
||||
object UserAgents {
|
||||
|
||||
const val CHROME_MOBILE =
|
||||
"Mozilla/5.0 (Linux; Android 12) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.196 Mobile Safari/537.36"
|
||||
"Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.196 Mobile Safari/537.36"
|
||||
|
||||
const val CHROME_DESKTOP =
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
|
||||
|
||||
const val FIREFOX_DESKTOP = "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0"
|
||||
|
||||
const val KOTATSU = "Kotatsu/5.3 (Android 12;;; en)"
|
||||
const val KOTATSU = "Kotatsu/5.3 (Android 13;;; en)"
|
||||
}
|
||||
|
||||
@@ -29,9 +29,12 @@ internal class RemangaParser(
|
||||
context: MangaLoaderContext,
|
||||
) : PagedMangaParser(context, MangaSource.REMANGA, PAGE_SIZE), MangaParserAuthProvider {
|
||||
|
||||
private val baseHeaders = Headers.Builder()
|
||||
.add("User-Agent", UserAgents.CHROME_MOBILE)
|
||||
.build()
|
||||
private val userAgentKey = ConfigKey.UserAgent(UserAgents.CHROME_MOBILE)
|
||||
|
||||
private val baseHeaders: Headers
|
||||
get() = Headers.Builder()
|
||||
.add("User-Agent", config[userAgentKey])
|
||||
.build()
|
||||
|
||||
override val headers
|
||||
get() = getApiHeaders()
|
||||
@@ -224,6 +227,11 @@ internal class RemangaParser(
|
||||
return jo.getJSONObject("content").getString("username")
|
||||
}
|
||||
|
||||
override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) {
|
||||
super.onCreateConfig(keys)
|
||||
keys.add(userAgentKey)
|
||||
}
|
||||
|
||||
private fun getApiHeaders(): Headers {
|
||||
val userCookie = context.cookieJar.getCookies(domain).find {
|
||||
it.name == "user"
|
||||
|
||||
Reference in New Issue
Block a user