66// @description Powerful picture viewing tool online, which can popup/scale/rotate/batch save pictures automatically
77// @description:zh-CN 在线看图工具,支持图片翻转、旋转、缩放、弹出大图、批量保存
88// @description:zh-TW 線上看圖工具,支援圖片翻轉、旋轉、縮放、彈出大圖、批量儲存
9- // @version 2022.2.12.1
9+ // @version 2022.2.12.2
1010// @created 2011-6-15
1111// @namespace https://github.com/hoothin/UserScripts
1212// @homepage http://hoothin.com
@@ -2265,7 +2265,7 @@ ImgOps | https://imgops.com/#b#`;
22652265 };
22662266 this.thumbScrollbar=thumbScrollbar;
22672267
2268- var self=this;
2268+ self=this;
22692269
22702270 var imgStatistics={//图片的总类,统计,初始化值
22712271 rule:{
@@ -2736,7 +2736,7 @@ ImgOps | https://imgops.com/#b#`;
27362736 //生成分享的下拉列表
27372737 var shareMark='';
27382738 var shareItem;
2739- for(var i in prefs.share){
2739+ for(let i in prefs.share){
27402740 if(!prefs.share.hasOwnProperty(i))continue;
27412741 shareItem=prefs.share[i];
27422742 if(shareItem.limitLang && shareItem.limitLang.indexOf(lang)==-1)continue;
@@ -2829,14 +2829,14 @@ ImgOps | https://imgops.com/#b#`;
28292829 var target=e.target;
28302830 //e.preventDefault();
28312831 if(eleMaps['sidebar-container'].contains(target)){//缩略图区滚动滚轮翻图片
2832- var distance=self.thumbSpanOuterSize;
2832+ let distance=self.thumbSpanOuterSize;
28332833
28342834 if(e.deltaY<0 || e.deltaX<0){//向上滚
28352835 distance=-distance;
28362836 };
28372837 thumbScrollbar.scrollBy(distance)
28382838 }else{//图片区域滚动
2839- var distance=100;
2839+ let distance=100;
28402840 if(e.deltaY!=0){//y轴
28412841 if(self.img && self.img.classList.contains('pv-gallery-img_zoom-out')){//图片可以缩小时,滚动图片,否则切换图片。
28422842 if(e.deltaY < 0){
@@ -3971,23 +3971,23 @@ ImgOps | https://imgops.com/#b#`;
39713971 if(larger){
39723972 img.classList.add('pv-gallery-img_zoom-in');
39733973 if(contentSSize.h/contentSSize.w >=containerSize.h/containerSize.w){
3974- var height=this.imgNaturalSize.h-(contentSSize.h - containerSize.h);
3974+ let height=this.imgNaturalSize.h-(contentSSize.h - containerSize.h);
39753975 imgSty.height=height + 'px';
39763976 scaled=height/this.imgNaturalSize.h;
39773977 }else{
3978- var width=this.imgNaturalSize.w-(contentSSize.w - containerSize.w);
3978+ let width=this.imgNaturalSize.w-(contentSSize.w - containerSize.w);
39793979 imgSty.width=width + 'px';
39803980 scaled=width/this.imgNaturalSize.w;
39813981 };
39823982 scaled=(scaled*100).toFixed(2) + '%';
39833983 }else if(prefs.gallery.fitToScreenSmall){
39843984 if(this.imgNaturalSize.h/this.imgNaturalSize.w >=containerSize.h/containerSize.w){
3985- var height=contentSSize.h-50;
3985+ let height=contentSSize.h-50;
39863986 height=height<0?contentSSize.h:height;
39873987 imgSty.height=height + 'px';
39883988 scaled=height/this.imgNaturalSize.h;
39893989 }else{
3990- var width=contentSSize.w-50;
3990+ let width=contentSSize.w-50;
39913991 width=width<0?contentSSize.w:width;
39923992 imgSty.width=width + 'px';
39933993 scaled=width/this.imgNaturalSize.w;
@@ -4110,15 +4110,15 @@ ImgOps | https://imgops.com/#b#`;
41104110
41114111 this.thumbScrollbar.reset();
41124112
4113- if(this.imgSpans[index].style.display=="none"){
4114- /* for(var j in this.imgSpans){
4113+ if(this.imgSpans[index].style.display=="none" && !selectData ){
4114+ for(var j in this.imgSpans){
41154115 if (!this.imgSpans.hasOwnProperty(j)) continue;
41164116 var curSpan=this.imgSpans[j];
41174117 if(curSpan.style.display!="none"){
41184118 this.select(curSpan, true);
41194119 return;
41204120 }
4121- }*/
4121+ }
41224122 }
41234123 this.select(this.imgSpans[index], true);
41244124 },
@@ -4358,11 +4358,11 @@ ImgOps | https://imgops.com/#b#`;
43584358 if(!pre && !next){
43594359 let pageDiv=curPage.querySelector("div.wp-pagenavi");
43604360 if(pageDiv){
4361- var cur=pageDiv.querySelector("span.current");
4361+ let cur=pageDiv.querySelector("span.current");
43624362 pre=cur.previousSibling;
43634363 next=cur.nextSibling;
43644364 }else{
4365- var cur=curPage.querySelector("div.article-paging>span");
4365+ let cur=curPage.querySelector("div.article-paging>span");
43664366 if(cur){
43674367 pre=cur.previousElementSibling;
43684368 next=cur.nextElementSibling;
@@ -4375,7 +4375,7 @@ ImgOps | https://imgops.com/#b#`;
43754375 let aTags=curPage.querySelectorAll("a");
43764376 if(!pre){
43774377 let pref,pres,pret;
4378- for(var i=0;i<aTags.length;i++){
4378+ for(let i=0;i<aTags.length;i++){
43794379 let aTag=aTags[i];
43804380 if(!aTag.href || /javascript:/.test(aTag.href.trim()))continue;
43814381 if(pref && pres && pret)break;
@@ -4405,7 +4405,7 @@ ImgOps | https://imgops.com/#b#`;
44054405 }
44064406 if(!next){
44074407 let nextf,nexts,nextt;
4408- for(var i=0;i<aTags.length;i++){
4408+ for(let i=0;i<aTags.length;i++){
44094409 let aTag=aTags[i];
44104410 if(!aTag.href || /^\s*javascript:/.test(aTag.href.trim()))continue;
44114411 if(nextf && nexts && nextt)break;
@@ -5869,22 +5869,22 @@ ImgOps | https://imgops.com/#b#`;
58695869 var track=self.scrollbar.track;
58705870 switch(target){
58715871 case handle:{//手柄;功能,拖动手柄来滚动窗口
5872- var pro=self.isHorizontal ? ['left','clientX'] : ['top','clientY'];
5872+ let pro=self.isHorizontal ? ['left','clientX'] : ['top','clientY'];
58735873 var oHOffset=parseFloat(handle.style[pro[0]]);
58745874 var oClient=e[pro[1]];
58755875
58765876 var moveHandler=function(e){
58775877 self.scroll(oHOffset + e[pro[1]] - oClient,true);
58785878 };
5879- var upHandler=function(){
5879+ let upHandler=function(){
58805880 document.removeEventListener('mousemove',moveHandler,true);
58815881 document.removeEventListener('mouseup',upHandler,true);
58825882 };
58835883 document.addEventListener('mousemove',moveHandler,true);
58845884 document.addEventListener('mouseup',upHandler,true);
58855885 }break;
58865886 case track:{//轨道;功能,按住不放来连续滚动一个页面的距离
5887- var pro=self.isHorizontal ? ['left','offsetX','layerX','clientWidth','offsetWidth'] : ['top' , 'offsetY' ,'layerY','clientHeight','offsetHeight'];
5887+ let pro=self.isHorizontal ? ['left','offsetX','layerX','clientWidth','offsetWidth'] : ['top' , 'offsetY' ,'layerY','clientHeight','offsetHeight'];
58885888 var clickOffset=typeof e[pro[1]]=='undefined' ? e[pro[2]] : e[pro[1]];
58895889 var handleOffset=parseFloat(handle.style[pro[0]]);
58905890 var handleSize=handle[pro[4]];
@@ -5918,7 +5918,7 @@ ImgOps | https://imgops.com/#b#`;
59185918
59195919 checkStop();
59205920
5921- var upHandler=function(){
5921+ let upHandler=function(){
59225922 clearTimeout(scrollTimeout);
59235923 clearInterval(scrollInterval);
59245924 document.removeEventListener('mouseup',upHandler,true);
@@ -6601,7 +6601,7 @@ ImgOps | https://imgops.com/#b#`;
66016601 if(prefs.imgWindow.overlayer.shown){//是否显示覆盖层
66026602 var overlayer=ImgWindowC.overlayer;
66036603 if(!overlayer){
6604- var overlayer=document.createElement('span');
6604+ overlayer=document.createElement('span');
66056605 ImgWindowC.overlayer=overlayer;
66066606 overlayer.className='pv-pic-window-overlayer';
66076607 document.body.appendChild(overlayer);
@@ -9159,10 +9159,10 @@ ImgOps | https://imgops.com/#b#`;
91599159 function handleMessage(e){
91609160 var data=e.data;
91619161 if( !data || !data.messageID || data.messageID != messageID )return;
9162- var source=e.source;
9162+ var source=e.source,command,cusEvent ;
91639163 if(typeof source=='undefined' || source!==window){
91649164 if(!isFrame){
9165- var command=data.command;
9165+ command=data.command;
91669166 switch(command){
91679167 case 'open':{
91689168 var img=document.createElement('img');
@@ -9180,7 +9180,7 @@ ImgOps | https://imgops.com/#b#`;
91809180 });
91819181 }break;
91829182 case 'navigateToImg':{
9183- var cusEvent=document.createEvent('CustomEvent');
9183+ cusEvent=document.createEvent('CustomEvent');
91849184 cusEvent.initCustomEvent('pv-navigateToImg',false,false,data.exist);
91859185 document.dispatchEvent(cusEvent);
91869186 }break;
@@ -9196,7 +9196,7 @@ ImgOps | https://imgops.com/#b#`;
91969196 };
91979197
91989198 }else{
9199- var command=data.command;
9199+ command=data.command;
92009200 switch(command){
92019201 case 'navigateToImg':{
92029202
@@ -9228,7 +9228,7 @@ ImgOps | https://imgops.com/#b#`;
92289228 frameSentData=frameSentSuccessData;
92299229 }break;
92309230 case 'topWindowValid_frame':{
9231- var cusEvent=document.createEvent('CustomEvent');
9231+ cusEvent=document.createEvent('CustomEvent');
92329232 cusEvent.initCustomEvent('pv-topWindowValid',false,false,data.valid);
92339233 document.dispatchEvent(cusEvent);
92349234 }break;
@@ -9417,8 +9417,8 @@ ImgOps | https://imgops.com/#b#`;
94179417 var bgReg=/^\s*url\(\s*["']?(.+?)["']?\s*\)/i;
94189418 if(prefs.floatBar.listenBg && hasBg(target)){
94199419 targetBg = unsafeWindow.getComputedStyle(target).backgroundImage.replace(bgReg,"$1");
9420- var src=targetBg,nsrc=src,noActual=true,type="scale";
9421- var img={src:src};
9420+ let src=targetBg,nsrc=src,noActual=true,type="scale";
9421+ let img={src:src};
94229422 result = {
94239423 src: nsrc,
94249424 type: type,
@@ -9438,8 +9438,8 @@ ImgOps | https://imgops.com/#b#`;
94389438 }else if(prefs.floatBar.listenBg && hasBg(target.parentNode)){
94399439 target=target.parentNode;
94409440 targetBg=unsafeWindow.getComputedStyle(target).backgroundImage.replace(bgReg,"$1");
9441- var src=targetBg,nsrc=src,noActual=true,type="scale";
9442- var img={src:src};
9441+ let src=targetBg,nsrc=src,noActual=true,type="scale";
9442+ let img={src:src};
94439443 result = {
94449444 src: nsrc,
94459445 type: type,
0 commit comments