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 fd5053f02..373c31de5 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 @@ -137,7 +137,7 @@ data class BookSource( if (a.isBlank()) { val bindings = SimpleBindings() bindings["baseUrl"] = bookSourceUrl - bindings["java"] = JsExtensions() + bindings["java"] = JsExtensions a = AppConst.SCRIPT_ENGINE.eval( it.substring(4, it.lastIndexOf("<")), bindings diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index f317c52b5..ad4024379 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -8,7 +8,7 @@ import java.util.regex.Pattern @Suppress("unused") -class JsExtensions { +object JsExtensions { /** * js实现跨域访问,不能删 diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 8c9730fa8..8e6ded010 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -9,6 +9,7 @@ import io.legado.app.constant.Pattern.JS_PATTERN import io.legado.app.data.api.IHttpGetApi import io.legado.app.data.api.IHttpPostApi import io.legado.app.data.entities.BaseBook +import io.legado.app.help.JsExtensions import io.legado.app.help.http.HttpHelper import io.legado.app.utils.* import kotlinx.coroutines.Deferred @@ -139,6 +140,7 @@ class AnalyzeUrl( var jsEval: Any val sb = StringBuffer(ruleUrl.length) val simpleBindings = SimpleBindings() + simpleBindings["java"] = JsExtensions simpleBindings["baseUrl"] = baseUrl simpleBindings["page"] = page simpleBindings["key"] = key @@ -238,7 +240,7 @@ class AnalyzeUrl( book: BaseBook? ): Any { val bindings = SimpleBindings() - bindings["java"] = this + bindings["java"] = JsExtensions bindings["page"] = page bindings["key"] = key bindings["book"] = book