From 84c358b45b1c004e27db009c8b3b925c77c98020 Mon Sep 17 00:00:00 2001 From: Celeter Date: Fri, 21 Feb 2020 21:10:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9JSOUP=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/model/analyzeRule/AnalyzeByJSoup.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt index cf11dbb72..38fb633c5 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt @@ -359,8 +359,7 @@ class AnalyzeByJSoup { try { when (lastRule) { "text" -> for (element in elements) { - val text = element.text() - textS.add(text) + textS.add(element.text()) } "textNodes" -> for (element in elements) { val tn = arrayListOf() @@ -373,12 +372,15 @@ class AnalyzeByJSoup { } textS.add(join("\n", tn)) } - "ownText", "html" -> { - elements.select("script").remove() + "ownText" -> for (element in elements) { + textS.add(element.ownText()) + } + "html" -> { + elements.select("script, style").remove() val html = elements.html() textS.add(html) } - "all" -> textS.add(elements.html()) + "all" -> textS.add(elements.outerHtml()) else -> for (element in elements) { val url = element.attr(lastRule) if (!isEmpty(url) && !textS.contains(url)) { From 299cd4e9370d52c201f7416c5d2d7601ee1ca7b5 Mon Sep 17 00:00:00 2001 From: Celeter Date: Fri, 21 Feb 2020 21:13:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DRSS=E7=9A=84loadData?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=E5=AE=8C=E6=95=B4=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E5=88=A0=E6=8E=89?= =?UTF-8?q?style=3D=E7=9A=84=E5=88=A4=E6=96=AD=EF=BC=8C=E4=BD=BF=E6=A0=87?= =?UTF-8?q?=E5=87=86RSS=E6=9B=B4=E5=A5=BD=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/rss/read/ReadRssActivity.kt | 11 +++-------- .../io/legado/app/ui/rss/read/ReadRssViewModel.kt | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) 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 d5d9b9b66..c68db66a1 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 @@ -77,15 +77,10 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r val url = NetworkUtils.getAbsoluteURL(it.origin, it.link) val html = viewModel.clHtml(content) if (viewModel.rssSource?.loadWithBaseUrl == true) { - webView.loadDataWithBaseURL( - url, - html, - "text/html", - "utf-8", - url - )//不想用baseUrl进else + webView.loadDataWithBaseURL(url, html, "text/html", "utf-8", url)//不想用baseUrl进else } else { - webView.loadData(html, "text/html;charset=utf-8", "utf-8")//经测试可以解决中文乱码 + //webView.loadData(html, "text/html;charset=utf-8", "utf-8")//经测试可以解决中文乱码 + webView.loadDataWithBaseURL(null, html, "text/html;charset=utf-8", "utf-8", url) } } }) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index 0ace44358..17b66f41c 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -86,7 +86,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), } fun clHtml(content: String): String { - return if (content.contains("