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