pull/46/head
kunfei 5 years ago
parent 7e8758f2cf
commit b62eb40eee
  1. 2
      app/src/main/java/io/legado/app/constant/AppConst.kt
  2. 2
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  3. 3
      app/src/main/java/io/legado/app/help/http/AjaxWebView.kt
  4. 3
      app/src/main/java/io/legado/app/help/storage/OldRule.kt

@ -19,6 +19,8 @@ object AppConst {
const val channelIdReadAloud = "channel_read_aloud"
const val channelIdWeb = "channel_web"
const val UA_NAME = "User-Agent"
val userAgent: String by lazy {
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
}

@ -69,7 +69,7 @@ data class BookSource(
@Throws(Exception::class)
fun getHeaderMap(): Map<String, String> {
val headerMap = HashMap<String, String>()
headerMap["User-Agent"] = App.INSTANCE.getPrefString("user_agent") ?: userAgent
headerMap[AppConst.UA_NAME] = App.INSTANCE.getPrefString("user_agent") ?: userAgent
header?.let {
val header1 = when {
it.startsWith("@js:", true) ->

@ -9,6 +9,7 @@ import android.os.Message
import android.text.TextUtils
import android.webkit.*
import io.legado.app.App
import io.legado.app.constant.AppConst
import org.apache.commons.text.StringEscapeUtils
import java.lang.ref.WeakReference
@ -101,7 +102,7 @@ class AjaxWebView {
var javaScript: String? = null
val userAgent: String?
get() = this.headerMap?.get("User-Agent")
get() = this.headerMap?.get(AppConst.UA_NAME)
val isSniff: Boolean
get() = !TextUtils.isEmpty(sourceRegex)

@ -1,5 +1,6 @@
package io.legado.app.help.storage
import io.legado.app.constant.AppConst
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.*
import io.legado.app.help.storage.Restore.jsonPath
@ -131,7 +132,7 @@ object OldRule {
private fun uaToHeader(ua: String?): String? {
if (ua.isNullOrEmpty()) return null
val map = mapOf(Pair("User-Agent", ua))
val map = mapOf(Pair(AppConst.UA_NAME, ua))
return GSON.toJson(map)
}

Loading…
Cancel
Save