From 60899b207cc0be52d6dbe4af8560b94597e0a542 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 1 Jan 2019 08:08:06 +0800 Subject: [PATCH] =?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/updateLog.md | 1 + .../bookshelf/model/analyzeRule/AnalyzeRule.java | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 799a31d434..bf3819ad82 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,6 +4,7 @@ **2019/01/01** * 祝大家元旦快乐 * 修复不显示再按一次退出程序的BUG +* 支持不写规则用js直接处理网页内容 **2018/12/30** * 目录和书签可以滑动切换 diff --git a/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeRule.java b/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeRule.java index 9917267a30..5ee74e776d 100644 --- a/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeRule.java +++ b/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeRule.java @@ -147,7 +147,7 @@ public AnalyzeCollection getElements(String rule) { if (!StringUtils.isTrimEmpty(source.rule)) { switch (source.mode) { case JSon: - collection = new AnalyzeCollection(getAnalyzeByJSonPath().readList(source.rule), _isJSON); + collection = new AnalyzeCollection(getAnalyzeByJSonPath().readList(source.rule), true); break; case XPath: collection = new AnalyzeCollection(getAnalyzeByXPath().getElements(source.rule)); @@ -171,8 +171,6 @@ class SourceRule { String js; SourceRule(String ruleStr) { - if (_isJSON && !StringUtils.startWithIgnoreCase(ruleStr, "@JSON:")) - throw new AssertionError("Content analyze"); String str[] = ruleStr.split("@js:"); if (StringUtils.startWithIgnoreCase(str[0], "@XPath:")) { mode = Mode.XPath; @@ -181,7 +179,11 @@ class SourceRule { mode = Mode.JSon; rule = str[0].substring(6); } else { - mode = Mode.Default; + if (_isJSON) { + mode = Mode.JSon; + } else { + mode = Mode.Default; + } rule = str[0]; } if (str.length > 1) {