Skip to content

Commit 4c4f561

Browse files
committed
fix
1 parent dd243b8 commit 4c4f561

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

JiandanHero/JiandanHero.user.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// ==UserScript==
22
// @name 煎蛋侠
3-
// @name:en JiandanHero
3+
// @name:en Jiandan Hero
44
// @name:zh-TW 煎蛋俠
55
// @namespace hoothin
6-
// @version 0.5
6+
// @version 0.6
77
// @description 为煎蛋jandan.net提供左右方向键快捷翻页、鼠标悬停显示大图、屏蔽指定用户发言等功能
8-
// @description:en Tools for jiandan
8+
// @description:en Tools for jandan.net
99
// @description:zh-TW 為煎蛋jandan.net提供左右方向鍵快捷翻頁、鼠標懸停顯示大圖、屏蔽指定用戶發言等功能
1010
// @author hoothin
1111
// @match http*://jandan.net/*
@@ -34,7 +34,7 @@
3434
let author=authors[i];
3535
let authorId=author.querySelector("strong").title.replace(//,"");
3636
let changeBtn=document.createElement("a");
37-
changeBtn.href="javascript:void(0);";
37+
changeBtn.href=`javascript:void(0);`;
3838
changeBtn.id="changeBtn";
3939
changeBtn.style.display="none";
4040
author.insertBefore(changeBtn,author.querySelector("br"));
@@ -72,32 +72,38 @@
7272
var bigImg=document.createElement("img");
7373
bigImg.style.cssText="pointer-events: none;position:fixed;z-index:999";
7474
for(i=0;i<imgs.length;i++){
75-
let img=imgs[i];
75+
let img=imgs[i],left,top;
7676
img.onmouseover=function(e){
7777
bigImg.src=img.src.replace(/\/s\/custom\//,"/s/medium/").replace(/\.sinaimg\.cn\/mw600/,".sinaimg.cn/large");
7878
document.body.appendChild(bigImg);
79+
bigImg.onload=function(){
80+
relocBigImg(left, top);
81+
};
7982
};
8083
img.onmouseout=function(e){
8184
document.body.removeChild(bigImg);
8285
bigImg.removeAttribute("height");
8386
};
8487
img.onmousemove=function(e){
85-
var left=e.clientX;
86-
var top=e.clientY;
88+
left=e.clientX;
89+
top=e.clientY;
8790
if(!bigImg.src || bigImg.src===""){
8891
img.onmouseover(null);
8992
}
90-
if(bigImg.height>document.documentElement.clientHeight){
91-
bigImg.height=document.documentElement.clientHeight;
92-
}
93-
if(top+bigImg.height>document.documentElement.clientHeight){
94-
top=document.documentElement.clientHeight-bigImg.height;
95-
}
96-
if(left+bigImg.width>document.documentElement.clientWidth){
97-
left=document.documentElement.clientWidth-bigImg.width;
98-
}
99-
bigImg.style.left=left+10+"px";
100-
bigImg.style.top=top+"px";
93+
relocBigImg(left, top);
10194
};
10295
}
96+
function relocBigImg(left, top){
97+
if(bigImg.height>document.documentElement.clientHeight){
98+
bigImg.height=document.documentElement.clientHeight;
99+
}
100+
if(top+bigImg.height>document.documentElement.clientHeight){
101+
top=document.documentElement.clientHeight-bigImg.height;
102+
}
103+
if(left+bigImg.width>document.documentElement.clientWidth){
104+
left=document.documentElement.clientWidth-bigImg.width;
105+
}
106+
bigImg.style.left=left+10+"px";
107+
bigImg.style.top=top+"px";
108+
}
103109
})();

0 commit comments

Comments
 (0)