From 52e4d43191df951a4f6794f84cf068fa7450fc82 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 21 Oct 2019 10:55:19 +0800 Subject: [PATCH] up --- .../java/io/legado/app/data/entities/BookSource.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index 6a373bdef..8addf77db 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -70,8 +70,15 @@ data class BookSource( val headerMap = HashMap() headerMap["User-Agent"] = App.INSTANCE.getPrefString("user_agent") ?: userAgent header?.let { - GSON.fromJsonObject>(header)?.let { - headerMap.putAll(it) + val header1 = when { + it.startsWith("@js:", true) -> + AppConst.SCRIPT_ENGINE.eval(it.substring(4)).toString() + it.startsWith("", true) -> + AppConst.SCRIPT_ENGINE.eval(it.substring(4, it.lastIndexOf("<"))).toString() + else -> it + } + GSON.fromJsonObject>(header1)?.let { headers -> + headerMap.putAll(headers) } } return headerMap