Skip to content

Commit

Permalink
Super_preloaderPlus_one 6.3.9 新写了一个获取实际页数的方法
Browse files Browse the repository at this point in the history
- 引入了 parseUri 函数,并用新方法获取实际页数
- 移除了 @downloadurl
- 添加站点规则:AOL 搜索
  • Loading branch information
ywzhaiqi committed Sep 7, 2014
1 parent 2aca4d7 commit 218335b
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 16 deletions.
85 changes: 84 additions & 1 deletion Super_preloaderPlus/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2544,21 +2544,104 @@ function gmCompatible() {
};
}

// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// 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,
lasturl_info;
// 一些 url_info 为 p1,p2,p3 之类的
var handleInfo = function(s) {
if (s) {
return s.replace('p', '');
return s.replace(/^p/, '');
}
return s;
};
Expand Down
8 changes: 1 addition & 7 deletions Super_preloaderPlus/src/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Super_preloaderPlus/src/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
101 changes: 93 additions & 8 deletions Super_preloaderPlus/super_preloaderplus_one.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -6336,21 +6338,104 @@ function gmCompatible() {
};
}

// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// 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,
lasturl_info;
// 一些 url_info 为 p1,p2,p3 之类的
var handleInfo = function(s) {
if (s) {
return s.replace('p', '');
return s.replace(/^p/, '');
}
return s;
};
Expand Down

0 comments on commit 218335b

Please sign in to comment.