Skip to content

Commit 56d94ac

Browse files
committed
add nextPage
1 parent 453d406 commit 56d94ac

1 file changed

Lines changed: 131 additions & 3 deletions

File tree

Picviewer CE+/Picviewer CE+.user.js

Lines changed: 131 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// @description Powerful picture viewing tool online, which can popup/scale/rotate/batch save pictures or find the HD original picture automatically
77
// @description:zh-CN NLF 的围观图修改版,增加高清原图查找显示(在线看图工具,支持图片翻转、旋转、缩放、弹出大图、批量保存、查找原图)
88
// @description:zh-TW NLF 的圍觀圖修改版,增加高清原圖查詢顯示(線上看圖工具,支援圖片翻轉、旋轉、縮放、彈出大圖、批量儲存、查詢原圖)
9-
// @version 2017.3.8.1
9+
// @version 2017.3.12.1
1010
// @created 2011-6-15
1111
// @namespace http://userscripts.org/users/NLF
1212
// @homepage http://hoothin.com
@@ -1645,6 +1645,11 @@
16451645
'<span title="点击退出收藏模式" class="pv-gallery-head-command pv-gallery-head-command-exit-collection">'+
16461646
'<span>退出收藏</span>'+
16471647
'<span class="pv-gallery-vertical-align-helper"></span>'+
1648+
'</span>'+
1649+
1650+
'<span title="加载下一页的图片" class="pv-gallery-head-command pv-gallery-head-command-nextPage">'+
1651+
'<span>加载更多</span>'+
1652+
'<span class="pv-gallery-vertical-align-helper"></span>'+
16481653
'</span>'+
16491654

16501655
'<span title="弹出照片进行复杂操作" class="pv-gallery-head-command pv-gallery-head-command-operate">'+
@@ -1836,6 +1841,7 @@
18361841
'head-left-img-info-scaling',
18371842

18381843
'head-command-close',
1844+
'head-command-nextPage',
18391845
'head-command-operate',
18401846
'head-command-slide-show',
18411847
'head-command-slide-show-button-inner',
@@ -2667,6 +2673,8 @@ padding-left:24px;">'+shareItem.name+'</span>');
26672673
new ImgWindowC(this);
26682674
},
26692675
});
2676+
}else if(eleMaps['head-command-nextPage'].contains(target)){
2677+
self.nextPage();
26702678
}else if(eleMaps['head-command-collect'].contains(target)){
26712679
if(collection.favorite){
26722680
collection.remove();
@@ -3320,6 +3328,126 @@ padding-left:24px;">'+shareItem.name+'</span>');
33203328
}
33213329
}
33223330
},
3331+
curPage:document,
3332+
getPage:function(){
3333+
var curPage=this.curPage;
3334+
let pre=curPage.querySelector("a.prev");
3335+
let next=curPage.querySelector("a.next");
3336+
if(!pre)pre=curPage.querySelector(".prev>a");
3337+
if(!next)next=curPage.querySelector(".next>a");
3338+
if(!pre && !next){
3339+
let aTags=curPage.querySelectorAll("a");
3340+
if(!pre){
3341+
let pref,pres,pret;
3342+
for(var i=0;i<aTags.length;i++){
3343+
let aTag=aTags[i];
3344+
if(pref && pres && pret)break;
3345+
if(!pref){
3346+
if(//.test(aTag.innerHTML)){
3347+
pref=aTag;
3348+
}
3349+
}
3350+
if(!pres){
3351+
if(aTag.innerHTML=="&lt;"){
3352+
pres=aTag;
3353+
}
3354+
}
3355+
if(!pret){
3356+
if(aTag.innerHTML=="«"){
3357+
pret=aTag;
3358+
}
3359+
}
3360+
}
3361+
pre=pref||pres||pret;
3362+
}
3363+
if(!next){
3364+
let nextf,nexts,nextt;
3365+
for(var i=0;i<aTags.length;i++){
3366+
let aTag=aTags[i];
3367+
if(nextf && nexts && nextt)break;
3368+
if(!nextf){
3369+
if(//.test(aTag.innerHTML)){
3370+
nextf=aTag;
3371+
}
3372+
}
3373+
if(!nexts){
3374+
if(aTag.innerHTML=="&gt;"){
3375+
nexts=aTag;
3376+
}
3377+
}
3378+
if(!nextt){
3379+
if(aTag.innerHTML=="»"){
3380+
nextt=aTag;
3381+
}
3382+
}
3383+
}
3384+
next=nextf||nexts||nextt;
3385+
}
3386+
}
3387+
if(!pre && !next){
3388+
let pageDiv=curPage.querySelector("div.wp-pagenavi");
3389+
if(pageDiv){
3390+
var cur=pageDiv.querySelector("span.current");
3391+
pre=cur.previousSibling;
3392+
next=cur.nextSibling;
3393+
}
3394+
}
3395+
return {pre:pre,next:next};
3396+
},
3397+
canonicalUri:function(src, base_path){
3398+
var root_page = /^[^?#]*\//.exec(location.href)[0],
3399+
root_domain = /^\w+\:\/\/\/?[^\/]+/.exec(root_page)[0],
3400+
absolute_regex = /^\w+\:\/\//;
3401+
if (/^\/\/\/?/.test(src)){
3402+
src = location.protocol + src;
3403+
}
3404+
else if (!absolute_regex.test(src) && src.charAt(0) != "/"){
3405+
src = (base_path || "") + src;
3406+
}
3407+
return absolute_regex.test(src) ? src : ((src.charAt(0) == "/" ? root_domain : root_page) + src);
3408+
},
3409+
nextPage:function(){
3410+
var pageObj=this.getPage();
3411+
if(!pageObj.next)return;
3412+
var nextUrl=pageObj.next;
3413+
if(nextUrl.tagName!="A"){
3414+
nextUrl=nextUrl.querySelector("a");
3415+
if(!nextUrl)return;
3416+
}
3417+
var self = this;
3418+
GM_xmlhttpRequest({
3419+
method: 'GET',
3420+
url: self.canonicalUri(nextUrl.getAttribute("href")),
3421+
onload: function(d) {
3422+
let html=document.implementation.createHTMLDocument('');
3423+
html.documentElement.innerHTML = d.responseText;
3424+
self.curPage=html;
3425+
let imgs=html.querySelectorAll('img');
3426+
var container = document.querySelector('.pv-gallery-container'),
3427+
preloadContainer = document.querySelector('.pv-gallery-preloaded-img-container');
3428+
imgs = Array.prototype.slice.call(imgs).filter(function(img){
3429+
return !(container.contains(img) || preloadContainer.contains(img));
3430+
});
3431+
imgs.forEach(function(img) {
3432+
var isrc=img.outerHTML.replace(/.*src="(.*?)".*/,"$1");
3433+
var nimg = new Image();
3434+
nimg.src = isrc;
3435+
nimg.onload=function(){
3436+
if (self._dataCache[this.src]) return;
3437+
var result = findPic(this);
3438+
if (result) {
3439+
self.data.push(result);
3440+
self._appendThumbSpans([result]);
3441+
}
3442+
self._dataCache[this.src] = true;
3443+
self.loadThumb();
3444+
};
3445+
});
3446+
},
3447+
onerror: function(e) {
3448+
}
3449+
});
3450+
},
33233451
runOnce:function(){//运行一次来获取某些数据。
33243452
var thumbSpanCS=unsafeWindow.getComputedStyle(this.selected);
33253453
this.thumbSpanOuterSize=this.isHorizontal?
@@ -7294,7 +7422,7 @@ background-image:url("'+ prefs.icons.magnifier +'");\
72947422
}
72957423

72967424
function tag(n) {
7297-
return n.tagName && n.tagName.toUpperCase();
7425+
return n && n.tagName && n.tagName.toUpperCase();
72987426
}
72997427

73007428
function qs(s, n) {
@@ -7305,7 +7433,7 @@ background-image:url("'+ prefs.icons.magnifier +'");\
73057433
var a, img, url, info;
73067434
if(tag(node) == 'A') {
73077435
a = node;
7308-
} else {
7436+
} else if(node.parentNode){
73097437
if(tag(node) == 'IMG') {
73107438
img = node;
73117439
if(img.src.substr(0, 5) != 'data:') url = rel2abs(img.src, location.href);

0 commit comments

Comments
 (0)