From b09dcf7b67391e2ceffe2f3867078d20f34b78a9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 11 Jan 2022 16:26:08 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/NetworkUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt index 978844a8d..f4fa7386b 100644 --- a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt +++ b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt @@ -153,7 +153,7 @@ object NetworkUtils { } /** - * 获取二级域名,供cookie保存和读取 + * 获取域名,供cookie保存和读取 * http://1.2.3.4 => 1.2.3.4 * https://www.example.com => example.com * http://www.biquge.com.cn => biquge.com.cn From baccd099e6fc6da123176ae180cbdf58dc4ab6c2 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Thu, 13 Jan 2022 15:39:40 +0800 Subject: [PATCH 02/16] =?UTF-8?q?fix:=E4=B8=80=E7=BA=A7=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E6=97=B6=EF=BC=8C=E7=9B=AE=E5=BD=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/webBook/BookChapterList.kt | 4 ++-- app/src/main/java/io/legado/app/model/webBook/WebBook.kt | 4 ++-- .../app/ui/book/read/page/provider/ChapterProvider.kt | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt index 72d13880d..faf5f1fa4 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt @@ -193,8 +193,8 @@ object BookChapterList { } if (bookChapter.url.isEmpty()) { if (bookChapter.isVolume) { - bookChapter.url = bookChapter.title - Debug.log(bookSource.bookSourceUrl, "一级目录${index}未获取到url,使用章节标题替代") + bookChapter.url = bookChapter.title + index + Debug.log(bookSource.bookSourceUrl, "一级目录${index}未获取到url,使用${bookChapter.title}${index}替代") } else { bookChapter.url = baseUrl Debug.log(bookSource.bookSourceUrl, "目录${index}未获取到url,使用baseUrl替代") diff --git a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt index c1f727fd0..9cda244cf 100644 --- a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt @@ -261,8 +261,8 @@ object WebBook { Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}") return bookChapter.url } - if(bookChapter.isVolume && bookChapter.url == bookChapter.title) { - Debug.log(bookSource.bookSourceUrl, "⇒一级目录获取链接为空,使用${bookChapter.tag}") + if(bookChapter.isVolume && bookChapter.url.startsWith(bookChapter.title)) { + Debug.log(bookSource.bookSourceUrl, "⇒一级目录正文不解析规则") return bookChapter.tag ?: "" } return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index d42c60a66..ebfbcb0f8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -129,7 +129,7 @@ object ChapterProvider { matcher.appendTail(sb) text = sb.toString() val isTitle = index == 0 - val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank() + val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1 val textPaint = if (isTitle) titlePaint else contentPaint if (!(isTitle && ReadBookConfig.titleMode == 2)) { setTypeText( @@ -147,7 +147,7 @@ object ChapterProvider { val text = content.substring(start, matcher.start()) if (text.isNotBlank()) { val isTitle = index == 0 - val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank() + val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1 val textPaint = if (isTitle) titlePaint else contentPaint if (!(isTitle && ReadBookConfig.titleMode == 2)) { setTypeText( @@ -169,7 +169,7 @@ object ChapterProvider { val text = content.substring(start, content.length) if (text.isNotBlank()) { val isTitle = index == 0 - val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank() + val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1 val textPaint = if (isTitle) titlePaint else contentPaint if (!(isTitle && ReadBookConfig.titleMode == 2)) { setTypeText( From 2ddb8cebe7b3d17ec289cb1cb41e2c09744f2b4c Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Thu, 13 Jan 2022 17:23:58 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E7=9A=84=E5=8D=B7=E8=BF=9E=E6=8E=A5=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=20=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=BF=94=E5=9B=9E=E4=B8=BA=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/entities/BookChapter.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt index cf5b2b2b7..5c80fc034 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt @@ -109,6 +109,8 @@ data class BookChapter( } fun getAbsoluteURL(): String { + //二级目录解析的卷链接为空 返回目录页的链接 + if (url.startsWith(title) && isVolume) return baseUrl val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) val urlBefore = if (urlMatcher.find()) url.substring(0, urlMatcher.start()) else url val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl, urlBefore) From 38402b272956b2a803c89744d7587f72183bcc84 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 14 Jan 2022 14:44:18 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/item_chapter_list.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/item_chapter_list.xml b/app/src/main/res/layout/item_chapter_list.xml index 1a8abbfc7..f80e52edc 100644 --- a/app/src/main/res/layout/item_chapter_list.xml +++ b/app/src/main/res/layout/item_chapter_list.xml @@ -17,7 +17,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/iv_checked" - app:layout_constraintBottom_toBottomOf="parent" /> + app:layout_constraintBottom_toTopOf="@id/tv_tag" /> From 4a5cd21c296f6a2c86e42c4f274afe7b1e4d9fbc Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 14 Jan 2022 15:42:48 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/about/AboutFragment.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt index ab158dca6..a88986385 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt @@ -22,12 +22,6 @@ class AboutFragment : PreferenceFragmentCompat() { private val licenseUrl = "https://github.com/gedoor/legado/blob/master/LICENSE" private val disclaimerUrl = "https://gedoor.github.io/MyBookshelf/disclaimer.html" private val qqGroups = linkedMapOf( - Pair("(QQ群VIP中转)1017837876", "0d9-zpmqbYfK3i_wt8uCvQoB2lmXadrg"), - Pair("(QQ群VIP1)701903217", "-iolizL4cbJSutKRpeImHlXlpLDZnzeF"), - Pair("(QQ群VIP2)263949160", "xwfh7_csb2Gf3Aw2qexEcEtviLfLfd4L"), - Pair("(QQ群VIP3)680280282", "_N0i7yZObjKSeZQvzoe2ej7j02kLnOOK"), - Pair("(QQ群VIP4)682555679", "VF2UwvUCuaqlo6pddWTe_kw__a1_Fr8O"), - Pair("(QQ群VIP5)161622578", "S81xdnhJ5EBC389LTUvoyiyM-wr71pvJ"), Pair("(QQ群1)805192012", "6GlFKjLeIk5RhQnR3PNVDaKB6j10royo"), Pair("(QQ群2)773736122", "5Bm5w6OgLupXnICbYvbgzpPUgf0UlsJF"), Pair("(QQ群3)981838750", "g_Sgmp2nQPKqcZQ5qPcKLHziwX_mpps9"), From 0a3e767d01bfe927d7303d937e924172c7b659fd Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Fri, 14 Jan 2022 20:32:18 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E4=B9=A6=E6=BA=90=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=98=BE=E7=A4=BApayAction=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 ++- app/src/main/assets/web/bookSource/index.html | 6 ++++++ .../app/ui/book/source/edit/BookSourceEditActivity.kt | 2 ++ app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 9 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index f4a45e8fd..c7d195cc2 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -15,7 +15,8 @@ * 紧急修复在线tts朗读bug * 紧急修复登录问题 -* 添加isVolume规则,支持二级目录,页眉标题、正文标题显示优化 by Xwite +* 添加isVolume规则,支持二级目录,正文标题显示优化 by Xwite +* 书源编辑界面显示payAction规则 **2022/01/10** diff --git a/app/src/main/assets/web/bookSource/index.html b/app/src/main/assets/web/bookSource/index.html index b29d62842..3d07d0f6b 100644 --- a/app/src/main/assets/web/bookSource/index.html +++ b/app/src/main/assets/web/bookSource/index.html @@ -311,6 +311,12 @@ title="imageStyle" placeholder="FULL:铺满 不填:默认样式"> +
+
购买操作:
+ +

其它规则
diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 9c30bbb4f..0a59dc75a 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -281,6 +281,7 @@ class BookSourceEditActivity : add(EditEntity("sourceRegex", cr?.sourceRegex, R.string.rule_source_regex)) add(EditEntity("replaceRegex", cr?.replaceRegex, R.string.rule_replace_regex)) add(EditEntity("imageStyle", cr?.imageStyle, R.string.rule_image_style)) + add(EditEntity("payAction", cr?.payAction, R.string.rule_pay_action)) } binding.tabLayout.selectTab(binding.tabLayout.getTabAt(0)) setEditEntities(0) @@ -376,6 +377,7 @@ class BookSourceEditActivity : "sourceRegex" -> contentRule.sourceRegex = it.value "replaceRegex" -> contentRule.replaceRegex = it.value "imageStyle" -> contentRule.imageStyle = it.value + "payAction" -> contentRule.payAction = it.value } } source.ruleSearch = searchRule diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 622e5e4ff..38fb6435c 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -423,6 +423,7 @@ 资源正则(sourceRegex) 替换规则(replaceRegex) 图片样式(imageStyle) + pay action(payAction) 图标(sourceIcon) 列表规则(ruleArticles) diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 3a17a80eb..ed121ea77 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -427,6 +427,7 @@ 资源正则(sourceRegex) 替换规则(replaceRegex) 图片样式(imageStyle) + pay action(payAction) 图标(sourceIcon) 列表规则(ruleArticles) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index a2e00281d..4ea4750da 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -420,6 +420,7 @@ 正文下一頁 URL 規則 (nextContentUrl) WebViewJs (webJs) 資源正則 (sourceRegex) + 购买操作(payAction) 圖標 (sourceIcon) 列表規則 (ruleArticles) 列表下一頁規則 (ruleArticles) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index aac171aab..2c163ac5d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -426,6 +426,7 @@ 圖片樣式(imageStyle) 取代規則(replaceRegex) 資源正則(sourceRegex) + 购买操作(payAction) 圖示(sourceIcon) 列表規則(ruleArticles) diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index fe9b236f3..bd023a0a0 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -426,6 +426,7 @@ 图片样式(imageStyle) 替换规则(replaceRegex) 资源正则(sourceRegex) + 购买操作(payAction) 图标(sourceIcon) 列表规则(ruleArticles) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e0ae17a7b..d88a10077 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -427,6 +427,7 @@ 资源正则(sourceRegex) 替换规则(replaceRegex) 图片样式(imageStyle) + 购买操作(payAction) 图标(sourceIcon) 列表规则(ruleArticles) From 80e2cdb0c2f3b6ca54398d70fbc4ebbe7c70e529 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 15 Jan 2022 09:55:00 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E6=96=87=E6=A1=A3;=E5=87=8F=E5=B0=91=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/help/jsExtensions.md | 0 app/src/main/assets/help/jsHelp.md | 197 ++++++++++++++++++ app/src/main/assets/help/ruleHelp.md | 90 +------- app/src/main/assets/updateLog.md | 1 + .../source/edit/BookSourceEditActivity.kt | 23 +- 5 files changed, 211 insertions(+), 100 deletions(-) delete mode 100644 app/src/main/assets/help/jsExtensions.md create mode 100644 app/src/main/assets/help/jsHelp.md diff --git a/app/src/main/assets/help/jsExtensions.md b/app/src/main/assets/help/jsExtensions.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/src/main/assets/help/jsHelp.md b/app/src/main/assets/help/jsHelp.md new file mode 100644 index 000000000..3aea6696a --- /dev/null +++ b/app/src/main/assets/help/jsHelp.md @@ -0,0 +1,197 @@ +# js变量和函数 + +书源规则中使用js可访问以下变量 +> java 变量-当前类 +> baseUrl 变量-当前url,String +> result 变量-上一步的结果 +> book 变量-[书籍类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/data/entities/Book.kt) +> chapter 变量-[当前目录类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/data/entities/BookChapter.kt) +> source 变量-[基础书源类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/data/entities/BaseSource.kt) +> cookie 变量-[cookie操作类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/help/http/CookieStore.kt) +> cache 变量-[缓存操作类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/help/CacheManager.kt) +> title 变量-当前标题,String +> src 内容,源码 +> nextChapterUrl 变量 下一章节url + +## 当前类对象的可使用的部分方法 + +### [AnalyzeUrl](https://github.com/gedoor/legado/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt) 部分函数 +> js中通过java.调用,只在`登录检查JS`规则中有效 +``` +initUrl() //重新解析url,可以用于登录检测js登录后重新解析url重新访问 +getHeaderMap().putAll(source.getHeaderMap(true)) //重新设置登录头 +getStrResponse( jsStr: String? = null, sourceRegex: String? = null) //返回访问结果,文本类型,书源内部重新登录后可调用此方法重新返回结果 +getResponse(): Response //返回访问结果,网络朗读引擎采用的是这个,调用登录后在调用这方法可以重新访问,参考阿里云登录检测 +``` + +### [js扩展类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/help/JsExtensions.kt) 部分函数 +* 变量存取 +``` +java.get(key) +java.put(key, value) +``` +* 网络请求 +``` +java.ajax(urlStr) +java.ajaxAll(urlList: Array): Array +``` +* 调试 +``` +java.log(msg) +java.logType(var) +``` +* 缓存网络文件 +``` +获取 +java.cacheFile(url) +java.cacheFile(url,saveTime) +执行内容 +eval(String(java.cacheFile(url))) +删除缓存文件 +cache.delete(java.md5Encode16(url)) +``` +* 获取网络zip文件里面的数据 +``` +java.getZipStringContent(url: String, path: String) +``` +* base64 +> flags参数可省略,默认Base64.NO_WRAP,查看[flags参数说明](https://blog.csdn.net/zcmain/article/details/97051870) +``` +java.base64Decode(str: String, flags: Int) +java.base64Encode(str: String, flags: Int) +``` +* 文件 +> 所有对于文件的读写删操作都是相对路径,只能操作阅读缓存/android/data/{package}/cache/内的文件 +``` +java.readTxtFile(path: String): String +java.deleteFile(path: String) +``` +**** +> [常见加密解密算法介绍](https://www.yijiyong.com/algorithm/encryption/01-intro.html) +> [相关概念](https://blog.csdn.net/OrangeJack/article/details/82913804) +* AES +``` +* @param data 传入的原始数据 +* @param key AES加密的key +* @param transformation AES加密的方式 例如AES/ECB/PKCS5Padding +* @param iv ECB模式的偏移向量 +java.aesDecodeToString(str: String, key: String, transformation: String, iv: String) +java.aesBase64DecodeToString(str: String, key: String, transformation: String, iv: String) +java.aesEncodeToString(str: String, key: String, transformation: String, iv: String) +java.aesEncodeToBase64String(str: String, key: String, transformation: String, iv: String) +``` +* 3DES +``` +* @param data 被加密的字符串 +* @param key 密钥 +* @param mode 模式 ECB/CBC/CFB/OFB/CTR +* @param padding 补码方式 NoPadding/PKCS5Padding/ +* @param iv 加盐 +java.tripleDESEncodeBase64Str(data: String,key: String,mode: String,padding: String,iv: String): String? +java.tripleDESDecodeStr(data: String,key: String,mode: String,padding: String,iv: String): String? +``` +* 摘要 +``` +* @param data 被摘要数据 +* @param algorithm 签名算法 MD5/SHA1/SHA256/SHA512 +java.digestHex(data: String,algorithm: String,): String? +java.digestBase64Str(data: String,algorithm: String,): String? +``` +* md5 +``` +java.md5Encode(str) +java.md5Encode16(str) + +``` + +## book对象的可用属性 +> 使用方法: 在js中或{{}}中使用book.属性的方式即可获取.如在正文内容后加上 ##{{book.name+"正文卷"+title}} 可以净化 书名+正文卷+章节名称(如 我是大明星正文卷第二章我爸是豪门总裁) 这一类的字符. +``` +bookUrl // 详情页Url(本地书源存储完整文件路径) +tocUrl // 目录页Url (toc=table of Contents) +origin // 书源URL(默认BookType.local) +originName //书源名称 or 本地书籍文件名 +name // 书籍名称(书源获取) +author // 作者名称(书源获取) +kind // 分类信息(书源获取) +customTag // 分类信息(用户修改) +coverUrl // 封面Url(书源获取) +customCoverUrl // 封面Url(用户修改) +intro // 简介内容(书源获取) +customIntro // 简介内容(用户修改) +charset // 自定义字符集名称(仅适用于本地书籍) +type // 0:text 1:audio +group // 自定义分组索引号 +latestChapterTitle // 最新章节标题 +latestChapterTime // 最新章节标题更新时间 +lastCheckTime // 最近一次更新书籍信息的时间 +lastCheckCount // 最近一次发现新章节的数量 +totalChapterNum // 书籍目录总数 +durChapterTitle // 当前章节名称 +durChapterIndex // 当前章节索引 +durChapterPos // 当前阅读的进度(首行字符的索引位置) +durChapterTime // 最近一次阅读书籍的时间(打开正文的时间) +canUpdate // 刷新书架时更新书籍信息 +order // 手动排序 +originOrder //书源排序 +variable // 自定义书籍变量信息(用于书源规则检索书籍信息) + ``` + +## chapter对象的部分可用属性 +> 使用方法: 在js中或{{}}中使用chapter.属性的方式即可获取.如在正文内容后加上 ##{{chapter.title+chapter.index}} 可以净化 章节标题+序号(如 第二章 天仙下凡2) 这一类的字符. + ``` + url // 章节地址 + title // 章节标题 + baseUrl //用来拼接相对url + bookUrl // 书籍地址 + index // 章节序号 + resourceUrl // 音频真实URL + tag // + start // 章节起始位置 + end // 章节终止位置 + variable //变量 + ``` + +## source对象的部分可用函数 +* 获取书源url +``` +source.getKey() +``` +* 书源变量存取 +``` +source.setVariable(variable: String?) +source.getVariable() +``` + +* 登录头操作 +``` +source.getLoginHeader() +source.getLoginHeaderMap(): Map? +source.putLoginHeader(header: String) +source.removeLoginHeader() +``` +## cookie对象的部分可用函数 +``` +获取全部cookie +cookie.getCookie(url) +获取cookie某一键值 +cookie.getKey(url,key) +删除cookie +cookie.removeCookie(key) +``` + +## cache对象的部分可用函数 +> saveTime单位:秒,可省略 +> 保存至数据库和缓存文件(50M),保存的内容较大时请使用`getFile putFile` +``` +保存 +cache.put(key, value , saveTime) +读取数据库 +cache.get(key) +删除 +cache.delete(key) +缓存文件内容 +cache.putFile(key, value, saveTime) +读取文件内容 +cache.getFile(key) +``` \ No newline at end of file diff --git a/app/src/main/assets/help/ruleHelp.md b/app/src/main/assets/help/ruleHelp.md index b2b1bb0b8..3ddc61526 100644 --- a/app/src/main/assets/help/ruleHelp.md +++ b/app/src/main/assets/help/ruleHelp.md @@ -2,8 +2,7 @@ * [书源帮助文档](https://alanskycn.gitee.io/teachme/Rule/source.html) * [订阅源帮助文档](https://alanskycn.gitee.io/teachme/Rule/rss.html) -* [js扩展类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/help/JsExtensions.kt) -* 辅助键盘❓中可插入URL参数模板,打开帮助,选择文件 +* 辅助键盘❓中可插入URL参数模板,打开帮助,js教程,正则教程,选择文件 * 规则标志, {{......}}内使用规则必须有明显的规则标志,没有规则标志当作js执行 ``` @@ 默认规则,直接写时可以省略@@ @@ -29,25 +28,6 @@ ] ``` -* 获取登录后的cookie -``` -获取全部 -cookie.getCookie(url) -获取某一键值 -cookie.getKey(url,key) -``` - -* 缓存网络文件 -``` -获取 -java.cacheFile(url) -java.cacheFile(url,saveTime) -执行内容 -eval(String(java.cacheFile(url))) -删除缓存文件 -cache.delete(java.md5Encode16(url)) -``` - * 请求头,支持http代理,socks4 socks5代理设置 ``` socks5代理 @@ -64,19 +44,6 @@ http代理 } 注意:这些请求头是无意义的,会被忽略掉 ``` - -* js 变量和函数 -``` -java 变量-当前类 -baseUrl 变量-当前url,String -result 变量-上一步的结果 -book 变量-书籍类,方法见 io.legado.app.data.entities.Book -cookie 变量-cookie操作类,方法见 io.legado.app.help.http.CookieStore -cache 变量-缓存操作类,方法见 io.legado.app.help.CacheManager -chapter 变量-当前目录类,方法见 io.legado.app.data.entities.BookChapter -title 变量-当前标题,String -src 内容,源码 -``` * url添加js参数,解析url时执行,可在访问url时处理url,例 ``` @@ -113,7 +80,7 @@ https://www.baidu.com,{"js":"java.url=java.url+'yyyy'"} })() ``` -* 正文图片链接支持修改headers +* 图片链接支持修改headers ``` let options = { "headers": {"User-Agent": "xxxx","Referrer":baseUrl,"Cookie":"aaa=vbbb;"} @@ -121,58 +88,7 @@ let options = { '' ``` - ## 部分js对象属性说明 -上述js变量与函数中,一些js的对象属性用的频率较高,在此列举。方便写源的时候快速翻阅。 - -### book对象的可用属性 -> 使用方法: 在js中或{{}}中使用book.属性的方式即可获取.如在正文内容后加上 ##{{book.name+"正文卷"+title}} 可以净化 书名+正文卷+章节名称(如 我是大明星正文卷第二章我爸是豪门总裁) 这一类的字符. -``` -bookUrl // 详情页Url(本地书源存储完整文件路径) -tocUrl // 目录页Url (toc=table of Contents) -origin // 书源URL(默认BookType.local) -originName //书源名称 or 本地书籍文件名 -name // 书籍名称(书源获取) -author // 作者名称(书源获取) -kind // 分类信息(书源获取) -customTag // 分类信息(用户修改) -coverUrl // 封面Url(书源获取) -customCoverUrl // 封面Url(用户修改) -intro // 简介内容(书源获取) -customIntro // 简介内容(用户修改) -charset // 自定义字符集名称(仅适用于本地书籍) -type // 0:text 1:audio -group // 自定义分组索引号 -latestChapterTitle // 最新章节标题 -latestChapterTime // 最新章节标题更新时间 -lastCheckTime // 最近一次更新书籍信息的时间 -lastCheckCount // 最近一次发现新章节的数量 -totalChapterNum // 书籍目录总数 -durChapterTitle // 当前章节名称 -durChapterIndex // 当前章节索引 -durChapterPos // 当前阅读的进度(首行字符的索引位置) -durChapterTime // 最近一次阅读书籍的时间(打开正文的时间) -canUpdate // 刷新书架时更新书籍信息 -order // 手动排序 -originOrder //书源排序 -variable // 自定义书籍变量信息(用于书源规则检索书籍信息) - ``` - -### chapter对象的可用属性 -> 使用方法: 在js中或{{}}中使用chapter.属性的方式即可获取.如在正文内容后加上 ##{{chapter.title+chapter.index}} 可以净化 章节标题+序号(如 第二章 天仙下凡2) 这一类的字符. - ``` - url // 章节地址 - title // 章节标题 - baseUrl //用来拼接相对url - bookUrl // 书籍地址 - index // 章节序号 - resourceUrl // 音频真实URL - tag // - start // 章节起始位置 - end // 章节终止位置 - variable //变量 - ``` - -### 字体解析使用 +* 字体解析使用 > 使用方法,在正文替换规则中使用,原理根据f1字体的字形数据到f2中查找字形对应的编码 ``` diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index c7d195cc2..ddd0ae7a9 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -17,6 +17,7 @@ * 紧急修复登录问题 * 添加isVolume规则,支持二级目录,正文标题显示优化 by Xwite * 书源编辑界面显示payAction规则 +* 书源编辑中的辅助键盘❓中可查看js说明文档 **2022/01/10** diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 0a59dc75a..6ac7ddf74 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -77,7 +77,7 @@ class BookSourceEditActivity : override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) if (!LocalConfig.ruleHelpVersionIsLast) { - showRuleHelp() + showHelp("ruleHelp") } } @@ -119,7 +119,7 @@ class BookSourceEditActivity : getString(R.string.share_book_source), ErrorCorrectionLevel.L ) - R.id.menu_help -> showRuleHelp() + R.id.menu_help -> showHelp("ruleHelp") R.id.menu_login -> getSource().let { source -> if (checkSource(source)) { viewModel.save(source) { @@ -420,26 +420,23 @@ class BookSourceEditActivity : } private fun showHelpDialog() { - val items = arrayListOf("插入URL参数", "书源教程", "正则教程", "选择文件") + val items = arrayListOf("插入URL参数", "书源教程", "js教程", "正则教程", "选择文件") selector(getString(R.string.help), items) { _, index -> when (index) { 0 -> insertText(AppConst.urlOption) - 1 -> showRuleHelp() - 2 -> showRegexHelp() - 3 -> selectDoc.launch { + 1 -> showHelp("ruleHelp") + 2 -> showHelp("jsHelp") + 3 -> showHelp("regexHelp") + 4 -> selectDoc.launch { mode = HandleFileContract.FILE } } } } - private fun showRuleHelp() { - val mdText = String(assets.open("help/ruleHelp.md").readBytes()) - showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD)) - } - - private fun showRegexHelp() { - val mdText = String(assets.open("help/regexHelp.md").readBytes()) + private fun showHelp(fileName: String) { + //显示目录help下的帮助文档 + val mdText = String(assets.open("help/${fileName}.md").readBytes()) showDialogFragment(TextDialog(mdText, TextDialog.Mode.MD)) } From 128a1eec27b91a579d021245e5a7b004afb6db20 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 15 Jan 2022 10:30:47 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E6=B7=BB=E5=8A=A0AnalyzeRule=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/help/jsHelp.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/main/assets/help/jsHelp.md b/app/src/main/assets/help/jsHelp.md index 3aea6696a..6076ca8f6 100644 --- a/app/src/main/assets/help/jsHelp.md +++ b/app/src/main/assets/help/jsHelp.md @@ -24,6 +24,25 @@ getStrResponse( jsStr: String? = null, sourceRegex: String? = null) //返回访 getResponse(): Response //返回访问结果,网络朗读引擎采用的是这个,调用登录后在调用这方法可以重新访问,参考阿里云登录检测 ``` +### [AnalyzeRule](https://github.com/gedoor/legado/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt) 部分函数 +* 获取文本/文本列表 +> `mContent` 待解析源代码,默认为当前页面 +> `isUrl` 链接标识,默认为`false` +``` +java.getString(ruleStr: String?, mContent: Any? = null, isUrl: Boolean = false) +java.getStringList(ruleStr: String?, mContent: Any? = null, isUrl: Boolean = false) +``` +* 设置解析内容 +``` +java.setContent(content: Any?, baseUrl: String? = null): +``` +* 获取Element/Element列表 +> 如果要改变解析源代码,请先使用`java.setContent` +``` +java.getElement(ruleStr: String) +java.getElements(ruleStr: String) +``` + ### [js扩展类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/help/JsExtensions.kt) 部分函数 * 变量存取 ``` From 88be84a7f8106b0186ca74f840def42a61f65043 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 15 Jan 2022 10:37:48 +0800 Subject: [PATCH 09/16] update jsHelp.md --- app/src/main/assets/help/jsHelp.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/help/jsHelp.md b/app/src/main/assets/help/jsHelp.md index 6076ca8f6..6d08173f9 100644 --- a/app/src/main/assets/help/jsHelp.md +++ b/app/src/main/assets/help/jsHelp.md @@ -95,8 +95,11 @@ java.deleteFile(path: String) * @param transformation AES加密的方式 例如AES/ECB/PKCS5Padding * @param iv ECB模式的偏移向量 java.aesDecodeToString(str: String, key: String, transformation: String, iv: String) + java.aesBase64DecodeToString(str: String, key: String, transformation: String, iv: String) + java.aesEncodeToString(str: String, key: String, transformation: String, iv: String) + java.aesEncodeToBase64String(str: String, key: String, transformation: String, iv: String) ``` * 3DES @@ -107,6 +110,7 @@ java.aesEncodeToBase64String(str: String, key: String, transformation: String, i * @param padding 补码方式 NoPadding/PKCS5Padding/ * @param iv 加盐 java.tripleDESEncodeBase64Str(data: String,key: String,mode: String,padding: String,iv: String): String? + java.tripleDESDecodeStr(data: String,key: String,mode: String,padding: String,iv: String): String? ``` * 摘要 @@ -114,13 +118,13 @@ java.tripleDESDecodeStr(data: String,key: String,mode: String,padding: String,iv * @param data 被摘要数据 * @param algorithm 签名算法 MD5/SHA1/SHA256/SHA512 java.digestHex(data: String,algorithm: String,): String? + java.digestBase64Str(data: String,algorithm: String,): String? ``` * md5 ``` java.md5Encode(str) java.md5Encode16(str) - ``` ## book对象的可用属性 From b105970b1847c92afad6d78f453eaf4aba587061 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 15 Jan 2022 14:38:41 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/web/bookSource/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/web/bookSource/index.html b/app/src/main/assets/web/bookSource/index.html index 3d07d0f6b..0686388c3 100644 --- a/app/src/main/assets/web/bookSource/index.html +++ b/app/src/main/assets/web/bookSource/index.html @@ -251,7 +251,7 @@ placeholder="选择章节链接 (规则结果为String类型的Url)">
-
Volume标识:
+
卷名标识:
From f59556be1481983930b3a615b1602531bd0311ff Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 15 Jan 2022 16:16:16 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index fa6f2ecf4..3f4b6c700 100644 --- a/build.gradle +++ b/build.gradle @@ -3,11 +3,14 @@ buildscript { ext.kotlin_version = '1.6.10' repositories { + //原仓库 google() mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } - maven { url 'https://maven.aliyun.com/repository/public' } - maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } + //镜像仓库,无法连接源仓库自行启用镜像仓库,不要提交修改 + //maven { url 'https://maven.aliyun.com/repository/google' } + //maven { url 'https://maven.aliyun.com/repository/public' } + //maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } } dependencies { classpath 'com.android.tools.build:gradle:7.0.4' @@ -19,10 +22,13 @@ buildscript { allprojects { repositories { + //原仓库 google() mavenCentral() - maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://jitpack.io' } + //镜像仓库,无法连接源仓库自行启用镜像仓库,不要提交修改 + //maven { url 'https://maven.aliyun.com/repository/google' } + //maven { url 'https://maven.aliyun.com/repository/public' } } } From d9567fa573e6943366f1e4b6dbad433a6975f97d Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 15 Jan 2022 17:08:05 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/IntentHelp.kt | 15 +++++++ .../io/legado/app/utils/ContextExtensions.kt | 44 +++++++++++-------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/IntentHelp.kt b/app/src/main/java/io/legado/app/help/IntentHelp.kt index aeb0e9be5..c1f918e8e 100644 --- a/app/src/main/java/io/legado/app/help/IntentHelp.kt +++ b/app/src/main/java/io/legado/app/help/IntentHelp.kt @@ -2,12 +2,27 @@ package io.legado.app.help import android.content.Context import android.content.Intent +import android.net.Uri import io.legado.app.R import io.legado.app.utils.toastOnUi +import splitties.init.appCtx @Suppress("unused") object IntentHelp { + fun getBrowserIntent(url: String): Intent { + return getBrowserIntent(Uri.parse(url)) + } + + fun getBrowserIntent(uri: Uri): Intent { + val intent = Intent(Intent.ACTION_VIEW) + intent.data = uri + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + if (intent.resolveActivity(appCtx.packageManager) == null) { + return Intent.createChooser(intent, "请选择浏览器") + } + return intent + } fun toTTSSetting(context: Context) { //跳转到文字转语音设置界面 diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index f04eba50c..8c0ad814c 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -27,6 +27,7 @@ import androidx.preference.PreferenceManager import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import io.legado.app.R import io.legado.app.constant.AppConst +import io.legado.app.help.IntentHelp import timber.log.Timber import java.io.File import java.io.FileOutputStream @@ -62,6 +63,20 @@ inline fun Context.servicePendingIntent( return getService(this, 0, intent, flags) } +@SuppressLint("UnspecifiedImmutableFlag") +fun Context.activityPendingIntent( + intent: Intent, + action: String +): PendingIntent? { + intent.action = action + val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + FLAG_UPDATE_CURRENT or FLAG_MUTABLE + } else { + FLAG_UPDATE_CURRENT + } + return getActivity(this, 0, intent, flags) +} + @SuppressLint("UnspecifiedImmutableFlag") inline fun Context.activityPendingIntent( action: String, @@ -145,8 +160,8 @@ fun Context.restart() { intent?.let { intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK - or Intent.FLAG_ACTIVITY_CLEAR_TASK - or Intent.FLAG_ACTIVITY_CLEAR_TOP + or Intent.FLAG_ACTIVITY_CLEAR_TASK + or Intent.FLAG_ACTIVITY_CLEAR_TOP ) startActivity(intent) //杀掉以前进程 @@ -284,25 +299,18 @@ val Context.externalCache: File get() = this.externalCacheDir ?: this.cacheDir fun Context.openUrl(url: String) { - openUrl(Uri.parse(url)) + try { + startActivity(IntentHelp.getBrowserIntent(url)) + } catch (e: Exception) { + toastOnUi(e.localizedMessage ?: "open url error") + } } fun Context.openUrl(uri: Uri) { - val intent = Intent(Intent.ACTION_VIEW) - intent.data = uri - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - if (intent.resolveActivity(packageManager) != null) { - try { - startActivity(intent) - } catch (e: Exception) { - toastOnUi(e.localizedMessage ?: "open url error") - } - } else { - try { - startActivity(Intent.createChooser(intent, "请选择浏览器")) - } catch (e: Exception) { - toastOnUi(e.localizedMessage ?: "open url error") - } + try { + startActivity(IntentHelp.getBrowserIntent(uri)) + } catch (e: Exception) { + toastOnUi(e.localizedMessage ?: "open url error") } } From b3cf0954f4d123065477734210ab58f83647145c Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 15 Jan 2022 17:35:22 +0800 Subject: [PATCH 13/16] =?UTF-8?q?fix:jsHelp.md=E9=93=BE=E6=8E=A5=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/help/jsHelp.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/assets/help/jsHelp.md b/app/src/main/assets/help/jsHelp.md index 6d08173f9..aeeedf3f3 100644 --- a/app/src/main/assets/help/jsHelp.md +++ b/app/src/main/assets/help/jsHelp.md @@ -15,7 +15,7 @@ ## 当前类对象的可使用的部分方法 -### [AnalyzeUrl](https://github.com/gedoor/legado/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt) 部分函数 +### [AnalyzeUrl](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt) 部分函数 > js中通过java.调用,只在`登录检查JS`规则中有效 ``` initUrl() //重新解析url,可以用于登录检测js登录后重新解析url重新访问 @@ -24,7 +24,7 @@ getStrResponse( jsStr: String? = null, sourceRegex: String? = null) //返回访 getResponse(): Response //返回访问结果,网络朗读引擎采用的是这个,调用登录后在调用这方法可以重新访问,参考阿里云登录检测 ``` -### [AnalyzeRule](https://github.com/gedoor/legado/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt) 部分函数 +### [AnalyzeRule](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt) 部分函数 * 获取文本/文本列表 > `mContent` 待解析源代码,默认为当前页面 > `isUrl` 链接标识,默认为`false` @@ -204,7 +204,7 @@ cookie.removeCookie(key) ``` ## cache对象的部分可用函数 -> saveTime单位:秒,可省略 +> saveTime单位:秒,可省略 > 保存至数据库和缓存文件(50M),保存的内容较大时请使用`getFile putFile` ``` 保存 From dcaf183a38cf4f75d81efd95bc1153a6e8ef6225 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 17 Jan 2022 11:44:25 +0800 Subject: [PATCH 14/16] =?UTF-8?q?fix:=E8=B4=AD=E4=B9=B0=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=8A=A5=E9=94=99;=E6=B7=BB=E5=8A=A0=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/help/jsHelp.md | 9 ++++- app/src/main/assets/help/ruleHelp.md | 33 +++++++++++++++++++ app/src/main/assets/updateLog.md | 6 ++-- .../app/ui/book/read/ReadBookActivity.kt | 2 +- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/src/main/assets/help/jsHelp.md b/app/src/main/assets/help/jsHelp.md index aeeedf3f3..804dd0d87 100644 --- a/app/src/main/assets/help/jsHelp.md +++ b/app/src/main/assets/help/jsHelp.md @@ -189,10 +189,17 @@ source.getVariable() * 登录头操作 ``` source.getLoginHeader() -source.getLoginHeaderMap(): Map? +source.getLoginHeaderMap().get(key: String) source.putLoginHeader(header: String) source.removeLoginHeader() ``` +* 用户登录信息操作 +> 使用`登录UI`规则,并成功登录,阅读自动加密保存登录UI规则中除type为button的信息 +``` +source.getLoginInfo() +source.getLoginInfoMap().get(key: String) +source.removeLoginInfo() +``` ## cookie对象的部分可用函数 ``` 获取全部cookie diff --git a/app/src/main/assets/help/ruleHelp.md b/app/src/main/assets/help/ruleHelp.md index 3ddc61526..cf6541c3f 100644 --- a/app/src/main/assets/help/ruleHelp.md +++ b/app/src/main/assets/help/ruleHelp.md @@ -11,6 +11,36 @@ : regex规则,不可省略,只可以用在书籍列表和目录列表 ``` +* 登录UI +> 不使用内置webView登录网站,需要使用`登录URL`规则实现登录逻辑,可使用`登录检查JS`检查登录结果 +``` +规则填写示范 +[ + { + name: "telephone", + type: "text" + }, + { + name: "password", + type: "password" + }, + { + name: "注册", + type: "button", + action: "http://www.yooike.com/xiaoshuo/#/register?title=%E6%B3%A8%E5%86%8C" + } +] +成功登录后在js中获取读取登录信息 +source.getLoginInfo() +source.getLoginInfoMap().get("telephone") +登录信息示范 +{ + "telephone":"123456", + "password":"123456" +} + +``` + * 发现url格式 ```json [ @@ -104,3 +134,6 @@ let options = { ``` +* 购买操作 +> 返回购买链接,可直接填写链接或者JavaScript +> 可用变量 book chapter \ No newline at end of file diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index ddd0ae7a9..1eda788b7 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -11,13 +11,15 @@ * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! +**2020/01/17** +* 添加payAction规则,返回购买链接 +* 书源编辑中的辅助键盘❓中可查看js说明文档 + **2022/01/11** * 紧急修复在线tts朗读bug * 紧急修复登录问题 * 添加isVolume规则,支持二级目录,正文标题显示优化 by Xwite -* 书源编辑界面显示payAction规则 -* 书源编辑中的辅助键盘❓中可查看js说明文档 **2022/01/10** diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 4aa72b8f7..28ba6e57f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -842,7 +842,7 @@ class ReadBookActivity : BaseReadBookActivity(), startActivity { putExtra("title", getString(R.string.chapter_pay)) putExtra("url", it) - IntentData.put(it, ReadBook.bookSource) + IntentData.put(it, ReadBook.bookSource?.getHeaderMap(true)) } } }.onError { From 3346d0d49e1d2844e07376158b9b250ee4d43c09 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 17 Jan 2022 17:43:17 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/WebService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/WebService.kt b/app/src/main/java/io/legado/app/service/WebService.kt index 676cba0bc..d1e1283e9 100644 --- a/app/src/main/java/io/legado/app/service/WebService.kt +++ b/app/src/main/java/io/legado/app/service/WebService.kt @@ -10,7 +10,6 @@ import io.legado.app.constant.AppConst import io.legado.app.constant.EventBus import io.legado.app.constant.IntentAction import io.legado.app.constant.PreferKey -import io.legado.app.ui.main.MainActivity import io.legado.app.utils.* import io.legado.app.web.HttpServer import io.legado.app.web.WebSocketServer @@ -61,6 +60,7 @@ class WebService : BaseService() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { when (intent?.action) { IntentAction.stop -> stopSelf() + "copyHostAddress" -> sendToClip(hostAddress) else -> upWebServer() } return super.onStartCommand(intent, flags, startId) @@ -114,7 +114,7 @@ class WebService : BaseService() { .setContentTitle(getString(R.string.web_service)) .setContentText(notificationContent) .setContentIntent( - activityPendingIntent("webService") + servicePendingIntent("copyHostAddress") ) builder.addAction( R.drawable.ic_stop_black_24dp, From 4e0959ba36055f2985658ce85e3faeb6c40f6868 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 17 Jan 2022 17:43:56 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/service/WebService.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/WebService.kt b/app/src/main/java/io/legado/app/service/WebService.kt index d1e1283e9..fea7ca733 100644 --- a/app/src/main/java/io/legado/app/service/WebService.kt +++ b/app/src/main/java/io/legado/app/service/WebService.kt @@ -44,6 +44,15 @@ class WebService : BaseService() { upTile(true) } + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + when (intent?.action) { + IntentAction.stop -> stopSelf() + "copyHostAddress" -> sendToClip(hostAddress) + else -> upWebServer() + } + return super.onStartCommand(intent, flags, startId) + } + override fun onDestroy() { super.onDestroy() isRun = false @@ -57,15 +66,6 @@ class WebService : BaseService() { upTile(false) } - override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - when (intent?.action) { - IntentAction.stop -> stopSelf() - "copyHostAddress" -> sendToClip(hostAddress) - else -> upWebServer() - } - return super.onStartCommand(intent, flags, startId) - } - private fun upWebServer() { if (httpServer?.isAlive == true) { httpServer?.stop()