Skip to content

Commit 524ecbf

Browse files
committed
fix for frame
1 parent b010e50 commit 524ecbf

1 file changed

Lines changed: 33 additions & 18 deletions

File tree

Picviewer CE+/Picviewer CE+.user.js

Lines changed: 33 additions & 18 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.4.9.1
9+
// @version 2017.4.9.2
1010
// @created 2011-6-15
1111
// @namespace http://userscripts.org/users/NLF
1212
// @homepage http://hoothin.com
@@ -2469,7 +2469,7 @@ padding-left:24px;">'+shareItem.name+'</span>');
24692469
canScroll=false;
24702470
setTimeout(function(){
24712471
canScroll=true;
2472-
},200);
2472+
},500);
24732473
next ? self.selectNext() : self.selectPrevious();
24742474
}
24752475
}
@@ -2826,7 +2826,9 @@ padding-left:24px;">'+shareItem.name+'</span>');
28262826
};
28272827
return ret;
28282828
},
2829+
previous:false,
28292830
selectPrevious:function(){
2831+
this.previous=true;
28302832
this.select(this.getThumSpan(true));
28312833
},
28322834
selectNext:function(){
@@ -3077,6 +3079,10 @@ padding-left:24px;">'+shareItem.name+'</span>');
30773079
y:0,
30783080
});
30793081

3082+
if(this.previous){
3083+
this.previous=false;
3084+
this.imgScrollbarV.scrollBy(999999);
3085+
}
30803086
this.collection.check();//检查是否在收藏里面。
30813087

30823088
},
@@ -3160,6 +3166,7 @@ padding-left:24px;">'+shareItem.name+'</span>');
31603166
this._dataCache = {};
31613167
}
31623168
(data || this.data).forEach(function(item) {
3169+
if(!item)return;
31633170
iStatisCopy[item.type].count++;
31643171
var spanMark=document.createElement("span");
31653172
thumbnails.appendChild(spanMark);
@@ -3169,7 +3176,7 @@ padding-left:24px;">'+shareItem.name+'</span>');
31693176
(item.xhr ? '" data-xhr="' + encodeURIComponent(JSON.stringify(item.xhr)) : '') +
31703177
'" data-description="' + encodeURIComponent(item.description || '') +
31713178
'" data-thumb-src="' + item.imgSrc +
3172-
'" title="' + item.img.title +
3179+
'" title="' + (item.img?item.img.title:"") +
31733180
'">' +
31743181
'<span class="pv-gallery-vertical-align-helper"></span>' +
31753182
'<span class="pv-gallery-sidebar-thumb-loading" title="正在读取中......"></span>' +
@@ -3178,6 +3185,7 @@ padding-left:24px;">'+shareItem.name+'</span>');
31783185

31793186
var self = this;
31803187
(data || this.data).forEach(function(d) {
3188+
if(!d)return;
31813189
self._dataCache[d.imgSrc] = true;
31823190
});
31833191

@@ -3285,7 +3293,9 @@ padding-left:24px;">'+shareItem.name+'</span>');
32853293
},
32863294

32873295
unique:function(data){
3288-
var imgSrc=data.target.src;
3296+
var imgSrc;
3297+
if(data.target)
3298+
imgSrc=data.target.src;
32893299

32903300
var data_i,
32913301
data_i_src,
@@ -6868,6 +6878,7 @@ background-color:rgba(255, 0, 0, 0.150);\
68686878

68696879
//删除不能发送的项。
68706880
var delCantClone=function(obj){
6881+
if(!obj)return;
68716882
delete obj.img;
68726883
delete obj.imgPA;
68736884
};
@@ -6908,7 +6919,7 @@ background-color:rgba(255, 0, 0, 0.150);\
69086919
document.addEventListener('pv-topWindowValid',function(e){
69096920
topWindowValid=e.detail;
69106921
if(topWindowValid){//如果顶层窗口有效
6911-
openInTop()
6922+
openInTop();
69126923
}else{
69136924
self.open();
69146925
};
@@ -6922,14 +6933,19 @@ background-color:rgba(255, 0, 0, 0.150);\
69226933

69236934
},
69246935
getAllValidImgs:function(){
6925-
var imgs=document.getElementsByTagName('img'), // html collection
6926-
validImgs=[]
6927-
;
6928-
arrayFn.forEach.call(imgs,function(img,index,imgs){
6929-
var result=findPic(img);
6930-
if(result){
6931-
validImgs.push(result);
6932-
};
6936+
var doc=window.parent==window?document:window.parent.document;
6937+
var validImgs=[],imgsHandle=function(imgs){
6938+
arrayFn.forEach.call(imgs,function(img,index,imgs){
6939+
var result=findPic(img);
6940+
if(result){
6941+
validImgs.push(result);
6942+
};
6943+
});
6944+
};
6945+
imgsHandle(doc.getElementsByTagName('img'));
6946+
arrayFn.forEach.call(doc.querySelectorAll("iframe"),function(iframe){
6947+
if(iframe.src.replace(/\/[^\/]*$/,"").indexOf(location.hostname)!=-1)
6948+
imgsHandle(iframe.contentWindow.document.getElementsByTagName('img'));
69336949
});
69346950
return validImgs;
69356951
},
@@ -7244,7 +7260,6 @@ background-image:url("'+ prefs.icons.magnifier +'");\
72447260
open:function(e,buttonType){
72457261
var waitImgLoad = e && e.ctrlKey ? !prefs.waitImgLoad : prefs.waitImgLoad; //按住ctrl取反向值
72467262
var openInTopWindow = e && e.shiftKey ? !prefs.framesPicOpenInTopWindow : prefs.framesPicOpenInTopWindow; //按住shift取反向值
7247-
72487263
if (!waitImgLoad && buttonType == 'magnifier' && !envir.chrome) { //非chrome的background-image需要全部载入后才能显示出来
72497264
waitImgLoad = true;
72507265
};
@@ -7790,9 +7805,10 @@ background-image:url("'+ prefs.icons.magnifier +'");\
77907805
document.dispatchEvent(cusEvent);
77917806
}break;
77927807
case 'topWindowValid':{
7808+
if(data.from)
77937809
window.postMessage({
77947810
messageID:messageID,
7795-
command:'topWindowValid',
7811+
command:'topWindowValid_frame',
77967812
valid:document.body.nodeName!='FRAMESET',
77977813
to:data.from,
77987814
},'*');
@@ -7832,7 +7848,7 @@ background-image:url("'+ prefs.icons.magnifier +'");\
78327848
case 'sendFail':{
78337849
frameSentData=frameSentSuccessData;//frameSentData重置为发送成功的数据。
78347850
}break;
7835-
case 'topWindowValid':{
7851+
case 'topWindowValid_frame':{
78367852
var cusEvent=document.createEvent('CustomEvent');
78377853
cusEvent.initCustomEvent('pv-topWindowValid',false,false,data.valid);
78387854
document.dispatchEvent(cusEvent);
@@ -7899,7 +7915,6 @@ background-image:url("'+ prefs.icons.magnifier +'");\
78997915
}
79007916

79017917
function clikToOpen(data){
7902-
79037918
var preventDefault = matchedRule.clikToOpen.preventDefault;
79047919

79057920
function mouseout(){
@@ -7934,7 +7949,7 @@ background-image:url("'+ prefs.icons.magnifier +'");\
79347949
},100);
79357950

79367951
return function(){
7937-
mouseout()
7952+
mouseout();
79387953
};
79397954
}
79407955

0 commit comments

Comments
 (0)