rss webView添加注入js

pull/2565/head
kunfei 2 years ago
parent eb5798045f
commit 420e50ec87
  1. 14
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt

@ -308,8 +308,9 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
}
inner class CustomWebViewClient : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: WebView?,
view: WebView,
request: WebResourceRequest?
): Boolean {
request?.let {
@ -319,22 +320,27 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
}
@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 {

Loading…
Cancel
Save