Skip to content

Commit 6d22efe

Browse files
committed
fix
1 parent fa49259 commit 6d22efe

1 file changed

Lines changed: 53 additions & 6 deletions

File tree

JiandanHero/JiandanHero.user.js

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:en Jiandan Hero
44
// @name:zh-TW 煎蛋俠
55
// @namespace hoothin
6-
// @version 1.1
6+
// @version 1.2
77
// @description 为煎蛋jandan.net提供左右方向键快捷翻页、鼠标悬停显示大图、屏蔽指定用户发言等功能
88
// @description:en Tools for jandan.net
99
// @description:zh-TW 為煎蛋jandan.net提供左右方向鍵快捷翻頁、鼠標懸停顯示大圖、屏蔽指定用戶發言等功能
@@ -16,6 +16,23 @@
1616

1717
(function() {
1818
'use strict';
19+
var timer,getImgWH=function(img,callBack){
20+
if(timer)clearInterval(timer);
21+
var check=function(){
22+
if(img.width>0 || img.height>0){
23+
if(timer)clearInterval(timer);
24+
callBack();
25+
return true;
26+
}else{
27+
return false;
28+
}
29+
};
30+
var geted=check();
31+
if(!geted){
32+
timer = setInterval(check,40);
33+
}
34+
};
35+
1936
document.addEventListener("keydown", function(e) {
2037
if(/INPUT|TEXTAREA/.test(document.activeElement.tagName))return;
2138
switch(e.keyCode){
@@ -30,6 +47,7 @@
3047
}
3148
});
3249
var authors=document.querySelectorAll("div.author"),i;
50+
var isHttps=location.protocol=="https:";
3351
for(i=0;i<authors.length;i++){
3452
let author=authors[i];
3553
let authorId=author.querySelector("strong").title.replace(//,"");
@@ -68,22 +86,27 @@
6886
}
6987
};
7088
}
71-
var imgs=document.querySelectorAll("img");
89+
var imgs=document.querySelectorAll("img"),left,top,src;
7290
var bigImg=document.createElement("img");
7391
bigImg.style.cssText="pointer-events: none;position:fixed;z-index:999";
7492
for(i=0;i<imgs.length;i++){
75-
let img=imgs[i],left,top;
93+
let img=imgs[i];
7694
img.onmouseover=function(e){
77-
bigImg.src=img.src.replace(/\b(custom|square)\b/,"medium").replace(/\.sinaimg\.cn\/mw600/,".sinaimg.cn/large");
95+
src=img.src.replace(/\b(custom|square)\b/,"medium").replace(/\.sinaimg\.cn\/(mw600|thumb\d+)/,".sinaimg.cn/large");
96+
src=isHttps?src.replace(/http\:\/\//,"https://"):src.replace(/https\:\/\//,"http://");
97+
bigImg.src=img.src;
98+
bigImg.src=src;
7899
document.body.appendChild(bigImg);
79-
bigImg.onload=function(){
100+
relocBigImg(left, top);
101+
getImgWH(bigImg,function(){
80102
relocBigImg(left, top);
81-
};
103+
});
82104
};
83105
img.onmouseout=function(e){
84106
document.body.removeChild(bigImg);
85107
bigImg.removeAttribute("height");
86108
bigImg.removeAttribute("width");
109+
bigImg.src=null;
87110
};
88111
img.onmousemove=function(e){
89112
left=e.clientX;
@@ -94,6 +117,30 @@
94117
relocBigImg(left, top);
95118
};
96119
}
120+
$("p").on("mouseover","div.gif-mask",function(e){
121+
src=this.previousSibling.getAttribute("org_src").replace(/\b(custom|square)\b/,"medium").replace(/\.sinaimg\.cn\/(mw600|thumb\d+)/,".sinaimg.cn/large");
122+
src=isHttps?src.replace(/http\:\/\//,"https://"):src.replace(/https\:\/\//,"http://");
123+
bigImg.src=this.previousSibling.src;
124+
bigImg.src=src;
125+
document.body.appendChild(bigImg);
126+
getImgWH(bigImg,function(){
127+
relocBigImg(left, top);
128+
});
129+
});
130+
$("p").on("mouseout","div.gif-mask",function(e){
131+
document.body.removeChild(bigImg);
132+
bigImg.removeAttribute("height");
133+
bigImg.removeAttribute("width");
134+
bigImg.src=null;
135+
});
136+
$("p").on("mousemove","div.gif-mask",function(e){
137+
left=e.clientX;
138+
top=e.clientY;
139+
if(!bigImg.src || bigImg.src===""){
140+
this.onmouseover(null);
141+
}
142+
relocBigImg(left, top);
143+
});
97144
function relocBigImg(left, top){
98145
var type=bigImg.height/bigImg.width>document.documentElement.clientHeight/document.documentElement.clientWidth;
99146
if(type && bigImg.height>document.documentElement.clientHeight){

0 commit comments

Comments
 (0)