mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
update fork / build (push) Has been cancelled
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
update fork / build (push) Has been cancelled
This commit is contained in:
@@ -235,12 +235,12 @@ interface BaseSource : JsExtensions {
|
||||
@Throws(Exception::class)
|
||||
fun evalJS(jsStr: String, bindingsConfig: ScriptBindings.() -> Unit = {}): Any? {
|
||||
val bindings = buildScriptBindings { bindings ->
|
||||
bindings.apply(bindingsConfig)
|
||||
bindings["java"] = this
|
||||
bindings["source"] = this
|
||||
bindings["baseUrl"] = getKey()
|
||||
bindings["cookie"] = CookieStore
|
||||
bindings["cache"] = CacheManager
|
||||
bindings.apply(bindingsConfig)
|
||||
}
|
||||
val sharedScope = getShareScope()
|
||||
val scope = if (sharedScope == null) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.size
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.script.rhino.RhinoScriptEngine
|
||||
import com.script.rhino.runScriptWithContext
|
||||
import io.legado.app.R
|
||||
import io.legado.app.base.VMBaseActivity
|
||||
import io.legado.app.constant.AppConst
|
||||
@@ -473,11 +473,13 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
|
||||
val source = viewModel.rssSource
|
||||
val js = source?.shouldOverrideUrlLoading
|
||||
if (!js.isNullOrBlank()) {
|
||||
val result = RhinoScriptEngine.runCatching {
|
||||
eval(js) {
|
||||
put("java", rssJsExtensions)
|
||||
put("url", url.toString())
|
||||
}.toString()
|
||||
val result = kotlin.runCatching {
|
||||
runScriptWithContext(lifecycleScope.coroutineContext) {
|
||||
source.evalJS(js) {
|
||||
put("java", rssJsExtensions)
|
||||
put("url", url.toString())
|
||||
}.toString()
|
||||
}
|
||||
}.onFailure {
|
||||
AppLog.put("url跳转拦截js出错", it)
|
||||
}.getOrNull()
|
||||
|
||||
Reference in New Issue
Block a user