From 6446c13de6f6e5ae2c51fc9915f6102727c432a1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 23 Oct 2019 15:37:28 +0800 Subject: [PATCH] up --- .../java/io/legado/app/data/entities/BookSource.kt | 14 ++++++++++++-- 1 file changed, 12 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 373c31de5..3236d5796 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 @@ -73,9 +73,9 @@ data class BookSource( header?.let { val header1 = when { it.startsWith("@js:", true) -> - AppConst.SCRIPT_ENGINE.eval(it.substring(4)).toString() + evalJS(it.substring(4)).toString() it.startsWith("", true) -> - AppConst.SCRIPT_ENGINE.eval(it.substring(4, it.lastIndexOf("<"))).toString() + evalJS(it.substring(4, it.lastIndexOf("<"))).toString() else -> it } GSON.fromJsonObject>(header1)?.let { map -> @@ -159,6 +159,16 @@ data class BookSource( return exploreKinds } + /** + * 执行JS + */ + @Throws(Exception::class) + private fun evalJS(jsStr: String): Any { + val bindings = SimpleBindings() + bindings["java"] = JsExtensions + return AppConst.SCRIPT_ENGINE.eval(jsStr, bindings) + } + data class ExploreKind( var title: String, var url: String? = null