From 218335baa6097892e83231b1bed27b41313dfe8e Mon Sep 17 00:00:00 2001 From: ywzhaiqi Date: Sun, 7 Sep 2014 10:15:46 +0800 Subject: [PATCH] =?UTF-8?q?Super=5FpreloaderPlus=5Fone=206.3.9=20=E6=96=B0?= =?UTF-8?q?=E5=86=99=E4=BA=86=E4=B8=80=E4=B8=AA=E8=8E=B7=E5=8F=96=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E9=A1=B5=E6=95=B0=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入了 parseUri 函数,并用新方法获取实际页数 - 移除了 @downloadURL - 添加站点规则:AOL 搜索 --- Super_preloaderPlus/src/main.js | 85 ++++++++++++++- Super_preloaderPlus/src/meta.js | 8 +- Super_preloaderPlus/src/rule.js | 8 ++ .../super_preloaderplus_one.user.js | 101 ++++++++++++++++-- 4 files changed, 186 insertions(+), 16 deletions(-) diff --git a/Super_preloaderPlus/src/main.js b/Super_preloaderPlus/src/main.js index b82b568b..497d77ea 100644 --- a/Super_preloaderPlus/src/main.js +++ b/Super_preloaderPlus/src/main.js @@ -2544,13 +2544,96 @@ function gmCompatible() { }; } +// parseUri 1.2.2 +// (c) Steven Levithan +// MIT License +var parseUri = function(str) { + var o = parseUri.options, + m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), + uri = {}, + i = 14; + + while (i--) uri[o.key[i]] = m[i] || ""; + + uri[o.ds.name] = {}; + uri[o.ds.name][0] = {}; + uri[o.ds.name][0]['key'] = (uri.protocol ? uri.protocol : 'http') + '://' + uri.host + (uri.port ? ':' + uri.port : '') + '/'; + uri[o.ds.name][0]['val'] = '/'; + var i = 0, + tempsub = '/', + subs = uri[o.key[10]].substr(1).split('/'); + for (var j = 1; j < (subs.length + 1); j++, i++) { + tempsub += tempsub === '/' ? subs[i] : '/' + subs[i]; + if (subs[i]) { + uri[o.ds.name][j] = {}; + uri[o.ds.name][j]['key'] = subs[i]; + uri[o.ds.name][j]['val'] = tempsub; + } + } + + uri[o.q.name] = {}; + uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) { + if ($1) uri[o.q.name][$1] = $2; + }); + uri[o.aq.name] = {}; + uri[o.key[13]].replace(o.aq.parser, function($0, $1, $2) { + if ($1) uri[o.aq.name][$1] = $2; + }); + + return uri; +}; +parseUri.options = { + strictMode: false, + key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], + q: { + name: "queryKey", + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + aq: { + name: "anchorqueryKey", + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + ds: { + name: "directorySub" + }, + parser: { + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ + } +}; + + // By lastDream2013 略加修改,原版只能用于 Firefox function getRalativePageStr(lastUrl, currentUrl, nextUrl) { + function getDigital(str) { + var num = str.replace(/^p/i, ''); + return parseInt(num, 10); + } + var getRalativePageNumArray = function (lasturl, url) { if (!lasturl || !url) { return [0, 0]; } + // 新的方法 + var lastQueryKeys = parseUri(lasturl).queryKey, + curQueryKeys = parseUri(url).queryKey, + name, lastNum, curNum; + for (name in curQueryKeys) { + if (!(name in lastQueryKeys)) continue; + + lastNum = getDigital(lastQueryKeys[name]); + curNum = getDigital(curQueryKeys[name]); + + if (isNaN(lastNum) || isNaN(curNum)) { + continue; + } + + return [lastNum, curNum]; + } + + + // 以前的 lastDream2013 的方式 var lasturlarray = lasturl.split(/-|\.|\&|\/|=|#|\?/), urlarray = url.split(/-|\.|\&|\/|=|#|\?/), url_info, @@ -2558,7 +2641,7 @@ function getRalativePageStr(lastUrl, currentUrl, nextUrl) { // 一些 url_info 为 p1,p2,p3 之类的 var handleInfo = function(s) { if (s) { - return s.replace('p', ''); + return s.replace(/^p/, ''); } return s; }; diff --git a/Super_preloaderPlus/src/meta.js b/Super_preloaderPlus/src/meta.js index 812be8ee..ca20f4b3 100644 --- a/Super_preloaderPlus/src/meta.js +++ b/Super_preloaderPlus/src/meta.js @@ -4,14 +4,8 @@ // @namespace https://github.com/ywzhaiqi // @description 预读+翻页..全加速你的浏览体验... // @author ywzhaiqi && NLF(原作者) -// @version 6.3.8 +// @version 6.3.9 // @homepageURL https://greasyfork.org/scripts/293-super-preloaderplus-one -// @updateURL https://greasyfork.org/scripts/293-super-preloaderplus-one/code/Super_preloaderPlus_one.meta.js -// @downloadURL https://greasyfork.org/scripts/293-super-preloaderplus-one/code/Super_preloaderPlus_one.user.js - -// homepageURL https://userscripts.org/scripts/show/178900 -// downloadURL https://userscripts.org/scripts/source/178900.user.js -// updateURL https://userscripts.org/scripts/source/178900.meta.js // @grant GM_addStyle // @grant GM_getValue diff --git a/Super_preloaderPlus/src/rule.js b/Super_preloaderPlus/src/rule.js index 6c5f5aac..5057b802 100644 --- a/Super_preloaderPlus/src/rule.js +++ b/Super_preloaderPlus/src/rule.js @@ -283,6 +283,14 @@ var SITEINFO=[ replaceE: '//div[@class="pagination"]', } }, + {name: 'AOL 搜索', + url: '^http://(www\\.)aolsearch.com/search\\?.+?[?&]q=', + siteExample: 'http://www.aolsearch.com/search?q=test', + nextLink: '//a[span[@class="nextRes"][text()="Next"]]', + autopager: { + pageElement: '//*[@id="c"]/div' + } + }, {name: "Google custom", url: /^https?:\/\/74\.125\.128\.147\/custom/i, nextLink: 'id("pnnext") | id("navbar navcnt nav")//td[span]/following-sibling::td[1]/a | id("nn")/parent::a', diff --git a/Super_preloaderPlus/super_preloaderplus_one.user.js b/Super_preloaderPlus/super_preloaderplus_one.user.js index 1906d60a..0c1377ed 100644 --- a/Super_preloaderPlus/super_preloaderplus_one.user.js +++ b/Super_preloaderPlus/super_preloaderplus_one.user.js @@ -4,14 +4,8 @@ // @namespace https://github.com/ywzhaiqi // @description 预读+翻页..全加速你的浏览体验... // @author ywzhaiqi && NLF(原作者) -// @version 6.3.8 +// @version 6.3.9 // @homepageURL https://greasyfork.org/scripts/293-super-preloaderplus-one -// @updateURL https://greasyfork.org/scripts/293-super-preloaderplus-one/code/Super_preloaderPlus_one.meta.js -// @downloadURL https://greasyfork.org/scripts/293-super-preloaderplus-one/code/Super_preloaderPlus_one.user.js - -// homepageURL https://userscripts.org/scripts/show/178900 -// downloadURL https://userscripts.org/scripts/source/178900.user.js -// updateURL https://userscripts.org/scripts/source/178900.meta.js // @grant GM_addStyle // @grant GM_getValue @@ -328,6 +322,14 @@ var SITEINFO=[ replaceE: '//div[@class="pagination"]', } }, + {name: 'AOL 搜索', + url: '^http://(www\\.)aolsearch.com/search\\?.+?[?&]q=', + siteExample: 'http://www.aolsearch.com/search?q=test', + nextLink: '//a[span[@class="nextRes"][text()="Next"]]', + autopager: { + pageElement: '//*[@id="c"]/div' + } + }, {name: "Google custom", url: /^https?:\/\/74\.125\.128\.147\/custom/i, nextLink: 'id("pnnext") | id("navbar navcnt nav")//td[span]/following-sibling::td[1]/a | id("nn")/parent::a', @@ -6336,13 +6338,96 @@ function gmCompatible() { }; } +// parseUri 1.2.2 +// (c) Steven Levithan +// MIT License +var parseUri = function(str) { + var o = parseUri.options, + m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), + uri = {}, + i = 14; + + while (i--) uri[o.key[i]] = m[i] || ""; + + uri[o.ds.name] = {}; + uri[o.ds.name][0] = {}; + uri[o.ds.name][0]['key'] = (uri.protocol ? uri.protocol : 'http') + '://' + uri.host + (uri.port ? ':' + uri.port : '') + '/'; + uri[o.ds.name][0]['val'] = '/'; + var i = 0, + tempsub = '/', + subs = uri[o.key[10]].substr(1).split('/'); + for (var j = 1; j < (subs.length + 1); j++, i++) { + tempsub += tempsub === '/' ? subs[i] : '/' + subs[i]; + if (subs[i]) { + uri[o.ds.name][j] = {}; + uri[o.ds.name][j]['key'] = subs[i]; + uri[o.ds.name][j]['val'] = tempsub; + } + } + + uri[o.q.name] = {}; + uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) { + if ($1) uri[o.q.name][$1] = $2; + }); + uri[o.aq.name] = {}; + uri[o.key[13]].replace(o.aq.parser, function($0, $1, $2) { + if ($1) uri[o.aq.name][$1] = $2; + }); + + return uri; +}; +parseUri.options = { + strictMode: false, + key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], + q: { + name: "queryKey", + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + aq: { + name: "anchorqueryKey", + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + ds: { + name: "directorySub" + }, + parser: { + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ + } +}; + + // By lastDream2013 略加修改,原版只能用于 Firefox function getRalativePageStr(lastUrl, currentUrl, nextUrl) { + function getDigital(str) { + var num = str.replace(/^p/i, ''); + return parseInt(num, 10); + } + var getRalativePageNumArray = function (lasturl, url) { if (!lasturl || !url) { return [0, 0]; } + // 新的方法 + var lastQueryKeys = parseUri(lasturl).queryKey, + curQueryKeys = parseUri(url).queryKey, + name, lastNum, curNum; + for (name in curQueryKeys) { + if (!(name in lastQueryKeys)) continue; + + lastNum = getDigital(lastQueryKeys[name]); + curNum = getDigital(curQueryKeys[name]); + + if (isNaN(lastNum) || isNaN(curNum)) { + continue; + } + + return [lastNum, curNum]; + } + + + // 以前的 lastDream2013 的方式 var lasturlarray = lasturl.split(/-|\.|\&|\/|=|#|\?/), urlarray = url.split(/-|\.|\&|\/|=|#|\?/), url_info, @@ -6350,7 +6435,7 @@ function getRalativePageStr(lastUrl, currentUrl, nextUrl) { // 一些 url_info 为 p1,p2,p3 之类的 var handleInfo = function(s) { if (s) { - return s.replace('p', ''); + return s.replace(/^p/, ''); } return s; };