Skip to content

Commit

Permalink
5.1.3 增加 replace 中的简写 \P,修正部分用户起点新版下一页失效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ywzhaiqi committed Jul 1, 2015
1 parent 5c7fb03 commit 5f57916
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 40 deletions.
51 changes: 31 additions & 20 deletions MyNovelReader/MyNovelReader.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id mynovelreader@[email protected]
// @name My Novel Reader
// @name:zh-CN 小说阅读脚本
// @version 5.1.2
// @version 5.1.3
// @namespace https://github.com/ywzhaiqi
// @author ywzhaiqi
// @contributor Roger Au, shyangs, JixunMoe
Expand Down Expand Up @@ -295,6 +295,10 @@ var READER_AJAX = "reader-ajax"; // 内容需要 ajax 的 className

// Unicode/2000-2FFF:http://zh.wikibooks.org/wiki/Unicode/2000-2FFF

// replace 中的简写
var CHAR_ALIAS = {
'\\P': '[\\u2000-\\u2FFF\\u3004-\\u303F\\uFE00-\\uFF60]', // 小说中添加的特殊符号
}

// ===== 自动尝试的规则 =====
var Rule = {
Expand Down Expand Up @@ -400,8 +404,7 @@ Rule.specialSite = [
},
contentRemove: "span[id^='ad_'], .read_ma",
contentPatch: function(fakeStub){
// if (fakeStub.find('#content > p').size() > 0) return;
fakeStub.find('#maincontent script[src$=".txt"]').addClass('reader-ajax');
fakeStub.find('script[src$=".txt"]').addClass('reader-ajax');
},
},
{siteName: '起点新版',
Expand All @@ -423,7 +426,7 @@ Rule.specialSite = [
'手机用户请到m.qidian.com阅读。'
],
contentPatch: function(fakeStub){
fakeStub.find('#chaptercontent script[src$=".txt').addClass('reader-ajax');
fakeStub.find('script[src$=".txt"]').addClass('reader-ajax');
},
},
{siteName: "起点中文网免费频道",
Expand Down Expand Up @@ -940,6 +943,7 @@ Rule.specialSite = [
'\\(.*?平南文学网\\)',
'{首发}|【首发】',
'=长=风',
'-优-优-小-说-更-新-最-快-\\.',
{ "。\\.": "。" },
]
},
Expand Down Expand Up @@ -1216,7 +1220,7 @@ Rule.specialSite = [
mutationChildCount: 0,
},
{siteName: "读零零",
url: "http://www\\.du00\\.com/read/\\d+/\\d+/[\\d_]+\\.html",
url: "http://www\\.du00\\.(?:com|cc)/read/\\d+/\\d+/[\\d_]+\\.html",
titleReg: "(.*?)(?:第\\d+段)?,(.*) - 读零零小说网",
titlePos: 1,
prevSelector: "#footlink a:first",
Expand All @@ -1234,7 +1238,6 @@ Rule.specialSite = [
"\\*文學馆\\*",
"\\(未完待续请搜索,小说更好更新更快!",
"www\\.DU00\\.com",
'记住我们的网址.*',
],
checkSection: true
},
Expand Down Expand Up @@ -1519,8 +1522,7 @@ Rule.specialSite = [
titleSelector: '.title',
bookTitleSelector: '.linkleft > a:last',
contentReplace: [
'[《(\\+[]长.{1,2}风.{1,2}文学 www.*?net',
'[…~≡△∧√]长.风.文.学.*?t',
'\\P{1,2}长.{1,2}风.{1,2}文.{1,2}学.*?t',
]
},
{siteName: "云来阁",
Expand All @@ -1533,6 +1535,7 @@ Rule.specialSite = [
'[☆★◆〓『【◎◇].*?(?:yunlaige|云 来 阁|yunlaige).*?[☆◆★〓』】◎◇]',
'《更新最快小说网站:雲来阁http://WWW.YunLaiGe.COM》',
'◢百度搜索雲来阁,最新最快的小说更新◣',
'【當你閱讀到此章節,請您移步到雲來閣閱讀最新章節,或者,雲來閣】',
'【最新更新】',
'值得您收藏。。',
'小说“小说章节',
Expand Down Expand Up @@ -1677,9 +1680,11 @@ Rule.specialSite = [
{siteName: "小说巴士",
url: "http://www\\.xsbashi\\.com/\\d+_\\d+/",
contentReplace: [
'==如您已閱讀到此章节,请移步到“/”阅读最新章节,也可在百度直接搜索“ ”或者“”,敬请记住我们新的网址 。/',
'==如您已閱讀到此章节.*?敬请记住我们新的网址 。/',
'看小说首发推荐去眼快看书',
'最快更新,阅读请。___小/说/巴/士 Www.XSBASHI.coM___',
'___小/说/巴/士 www.XSBASHI.com___',
'lala如您已阅读到此章節,請移步到.*?速记方法:,\\]',
]
},

Expand Down Expand Up @@ -1927,11 +1932,13 @@ Rule.replaceAll = [
'(?天上掉馅饼的好活动.*?微信公众号!)?',
// '(天上掉馅饼.*中文网公众号',
'(微信添加.*qdread微信公众号!)',
'jiemei如您已阅读到此章节,请移步到.*?\\[ads:本站换新网址啦,速记方法:,.\\]',

'[\\u2000-\\u2FFF\\u3004-\\u303F\\uFE00-\\uFF60]{1,2}[顶頂].{1,3}[点小].*?o?[mw,]',
'\\P{1,2}[顶頂].{1,3}[点小].*?o?[mw,]',

'》长>风》',
'《无〈错《', '》无>错》', '\\+无\\+错\\+', '|无|错|', '~无~错~', '`无`错`小说`www.``com',
'《无〈错《', '》无>错》', '\\+无\\+错\\+', '|无|错|', '~无~错~',
'`无`错`小说`www.``com', '+无+错+小说+3w++',
'\\|优\\|优\\|小\\|说\\|更\\|新\\|最\\|快X',
];

Expand Down Expand Up @@ -3332,10 +3339,6 @@ Parser.prototype = {
// 移除文字广告等
text = this.replaceText(text, Rule.replaceAll);

if (info.contentReplace) {
text = this.replaceText(text, info.contentReplace);
}

// 去除内容中的标题
if(this.chapterTitle && Rule.titleRegExp.test(this.chapterTitle)){
try {
Expand All @@ -3355,6 +3358,10 @@ Parser.prototype = {

text = text.replace(Rule.contentReplace, '');

if (info.contentReplace) {
text = this.replaceText(text, info.contentReplace);
}

if (Config.cn2tw) {
text = this.convert2tw(text);
}
Expand Down Expand Up @@ -3482,6 +3489,10 @@ Parser.prototype = {
text = text.replace(rule, '');
break;
case _.isString(rule):
// 还原简写
_.each(CHAR_ALIAS, function(value, key) {
rule = rule.replace(key, value);
});
var regexp = new RegExp(rule, 'ig');
text = text.replace(regexp, '');
break;
Expand Down Expand Up @@ -3589,11 +3600,9 @@ Parser.prototype = {

if (this.info.indexSelector && _.isFunction(this.info.indexSelector)) {
url = this.info.indexSelector(this.$doc);
}

if(this.info.indexSelector){
} else if(this.info.indexSelector){
link = this.$doc.find(this.info.indexSelector);
}else{
} else {
var selectors = Rule.indexSelectors;
var _indexLink;
// 按照顺序选取目录链接
Expand All @@ -3609,7 +3618,9 @@ Parser.prototype = {
if(link && link.length){
url = this.checkLinks(link);
C.log("找到目录链接: " + url);
}else{
}

if (!url) {
C.log("无法找到目录链接.");
}

Expand Down
2 changes: 1 addition & 1 deletion MyNovelReader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MyNovelReader",
"version": "5.1.2",
"version": "5.1.3",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.10.0",
Expand Down
22 changes: 13 additions & 9 deletions MyNovelReader/src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ Parser.prototype = {
// 移除文字广告等
text = this.replaceText(text, Rule.replaceAll);

if (info.contentReplace) {
text = this.replaceText(text, info.contentReplace);
}

// 去除内容中的标题
if(this.chapterTitle && Rule.titleRegExp.test(this.chapterTitle)){
try {
Expand All @@ -410,6 +406,10 @@ Parser.prototype = {

text = text.replace(Rule.contentReplace, '');

if (info.contentReplace) {
text = this.replaceText(text, info.contentReplace);
}

if (Config.cn2tw) {
text = this.convert2tw(text);
}
Expand Down Expand Up @@ -537,6 +537,10 @@ Parser.prototype = {
text = text.replace(rule, '');
break;
case _.isString(rule):
// 还原简写
_.each(CHAR_ALIAS, function(value, key) {
rule = rule.replace(key, value);
});
var regexp = new RegExp(rule, 'ig');
text = text.replace(regexp, '');
break;
Expand Down Expand Up @@ -644,11 +648,9 @@ Parser.prototype = {

if (this.info.indexSelector && _.isFunction(this.info.indexSelector)) {
url = this.info.indexSelector(this.$doc);
}

if(this.info.indexSelector){
} else if(this.info.indexSelector){
link = this.$doc.find(this.info.indexSelector);
}else{
} else {
var selectors = Rule.indexSelectors;
var _indexLink;
// 按照顺序选取目录链接
Expand All @@ -664,7 +666,9 @@ Parser.prototype = {
if(link && link.length){
url = this.checkLinks(link);
C.log("找到目录链接: " + url);
}else{
}

if (!url) {
C.log("无法找到目录链接.");
}

Expand Down
27 changes: 17 additions & 10 deletions MyNovelReader/src/rule.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Unicode/2000-2FFF:http://zh.wikibooks.org/wiki/Unicode/2000-2FFF

// replace 中的简写
var CHAR_ALIAS = {
'\\P': '[\\u2000-\\u2FFF\\u3004-\\u303F\\uFE00-\\uFF60]', // 小说中添加的特殊符号
}

// ===== 自动尝试的规则 =====
var Rule = {
Expand Down Expand Up @@ -105,8 +109,7 @@ Rule.specialSite = [
},
contentRemove: "span[id^='ad_'], .read_ma",
contentPatch: function(fakeStub){
// if (fakeStub.find('#content > p').size() > 0) return;
fakeStub.find('#maincontent script[src$=".txt"]').addClass('reader-ajax');
fakeStub.find('script[src$=".txt"]').addClass('reader-ajax');
},
},
{siteName: '起点新版',
Expand All @@ -128,7 +131,7 @@ Rule.specialSite = [
'手机用户请到m.qidian.com阅读。'
],
contentPatch: function(fakeStub){
fakeStub.find('#chaptercontent script[src$=".txt').addClass('reader-ajax');
fakeStub.find('script[src$=".txt"]').addClass('reader-ajax');
},
},
{siteName: "起点中文网免费频道",
Expand Down Expand Up @@ -645,6 +648,7 @@ Rule.specialSite = [
'\\(.*?平南文学网\\)',
'{首发}|【首发】',
'=长=风',
'-优-优-小-说-更-新-最-快-\\.',
{ "。\\.": "。" },
]
},
Expand Down Expand Up @@ -921,7 +925,7 @@ Rule.specialSite = [
mutationChildCount: 0,
},
{siteName: "读零零",
url: "http://www\\.du00\\.com/read/\\d+/\\d+/[\\d_]+\\.html",
url: "http://www\\.du00\\.(?:com|cc)/read/\\d+/\\d+/[\\d_]+\\.html",
titleReg: "(.*?)(?:第\\d+段)?,(.*) - 读零零小说网",
titlePos: 1,
prevSelector: "#footlink a:first",
Expand All @@ -939,7 +943,6 @@ Rule.specialSite = [
"\\*文學馆\\*",
"\\(未完待续请搜索,小说更好更新更快!",
"www\\.DU00\\.com",
'记住我们的网址.*',
],
checkSection: true
},
Expand Down Expand Up @@ -1224,8 +1227,7 @@ Rule.specialSite = [
titleSelector: '.title',
bookTitleSelector: '.linkleft > a:last',
contentReplace: [
'[《(\\+[]长.{1,2}风.{1,2}文学 www.*?net',
'[…~≡△∧√]长.风.文.学.*?t',
'\\P{1,2}长.{1,2}风.{1,2}文.{1,2}学.*?t',
]
},
{siteName: "云来阁",
Expand All @@ -1238,6 +1240,7 @@ Rule.specialSite = [
'[☆★◆〓『【◎◇].*?(?:yunlaige|云 来 阁|yunlaige).*?[☆◆★〓』】◎◇]',
'《更新最快小说网站:雲来阁http://WWW.YunLaiGe.COM》',
'◢百度搜索雲来阁,最新最快的小说更新◣',
'【當你閱讀到此章節,請您移步到雲來閣閱讀最新章節,或者,雲來閣】',
'【最新更新】',
'值得您收藏。。',
'小说“小说章节',
Expand Down Expand Up @@ -1382,9 +1385,11 @@ Rule.specialSite = [
{siteName: "小说巴士",
url: "http://www\\.xsbashi\\.com/\\d+_\\d+/",
contentReplace: [
'==如您已閱讀到此章节,请移步到“/”阅读最新章节,也可在百度直接搜索“ ”或者“”,敬请记住我们新的网址 。/',
'==如您已閱讀到此章节.*?敬请记住我们新的网址 。/',
'看小说首发推荐去眼快看书',
'最快更新,阅读请。___小/说/巴/士 Www.XSBASHI.coM___',
'___小/说/巴/士 www.XSBASHI.com___',
'lala如您已阅读到此章節,請移步到.*?速记方法:,\\]',
]
},

Expand Down Expand Up @@ -1632,11 +1637,13 @@ Rule.replaceAll = [
'(?天上掉馅饼的好活动.*?微信公众号!)?',
// '(天上掉馅饼.*中文网公众号',
'(微信添加.*qdread微信公众号!)',
'jiemei如您已阅读到此章节,请移步到.*?\\[ads:本站换新网址啦,速记方法:,.\\]',

'[\\u2000-\\u2FFF\\u3004-\\u303F\\uFE00-\\uFF60]{1,2}[顶頂].{1,3}[点小].*?o?[mw,]',
'\\P{1,2}[顶頂].{1,3}[点小].*?o?[mw,]',

'》长>风》',
'《无〈错《', '》无>错》', '\\+无\\+错\\+', '|无|错|', '~无~错~', '`无`错`小说`www.``com',
'《无〈错《', '》无>错》', '\\+无\\+错\\+', '|无|错|', '~无~错~',
'`无`错`小说`www.``com', '+无+错+小说+3w++',
'\\|优\\|优\\|小\\|说\\|更\\|新\\|最\\|快X',
];

Expand Down

0 comments on commit 5f57916

Please sign in to comment.