diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index 604f449e3..4e72e0f93 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -308,8 +308,9 @@ class ReadRssActivity : VMBaseActivity } inner class CustomWebViewClient : WebViewClient() { + override fun shouldOverrideUrlLoading( - view: WebView?, + view: WebView, request: WebResourceRequest? ): Boolean { request?.let { @@ -319,22 +320,27 @@ class ReadRssActivity : VMBaseActivity } @Suppress("DEPRECATION", "OVERRIDE_DEPRECATION", "KotlinRedundantDiagnosticSuppress") - override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { + override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean { url?.let { return shouldOverrideUrlLoading(Uri.parse(it)) } return true } - override fun onPageFinished(view: WebView?, url: String?) { + override fun onPageFinished(view: WebView, url: String?) { super.onPageFinished(view, url) - view?.title?.let { title -> + view.title?.let { title -> if (title != url && title != view.url && title.isNotBlank() && url != "about:blank") { binding.titleBar.title = title } else { binding.titleBar.title = intent.getStringExtra("title") } } + viewModel.rssSource?.injectJs?.let { + if (it.isNotBlank()) { + view.evaluateJavascript(it, null) + } + } } private fun shouldOverrideUrlLoading(url: Uri): Boolean {