|
3 | 3 | // @name:en Jiandan Hero |
4 | 4 | // @name:zh-TW 煎蛋俠 |
5 | 5 | // @namespace hoothin |
6 | | -// @version 1.1 |
| 6 | +// @version 1.2 |
7 | 7 | // @description 为煎蛋jandan.net提供左右方向键快捷翻页、鼠标悬停显示大图、屏蔽指定用户发言等功能 |
8 | 8 | // @description:en Tools for jandan.net |
9 | 9 | // @description:zh-TW 為煎蛋jandan.net提供左右方向鍵快捷翻頁、鼠標懸停顯示大圖、屏蔽指定用戶發言等功能 |
|
16 | 16 |
|
17 | 17 | (function() { |
18 | 18 | '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 | + |
19 | 36 | document.addEventListener("keydown", function(e) { |
20 | 37 | if(/INPUT|TEXTAREA/.test(document.activeElement.tagName))return; |
21 | 38 | switch(e.keyCode){ |
|
30 | 47 | } |
31 | 48 | }); |
32 | 49 | var authors=document.querySelectorAll("div.author"),i; |
| 50 | + var isHttps=location.protocol=="https:"; |
33 | 51 | for(i=0;i<authors.length;i++){ |
34 | 52 | let author=authors[i]; |
35 | 53 | let authorId=author.querySelector("strong").title.replace(/防伪码:/,""); |
|
68 | 86 | } |
69 | 87 | }; |
70 | 88 | } |
71 | | - var imgs=document.querySelectorAll("img"); |
| 89 | + var imgs=document.querySelectorAll("img"),left,top,src; |
72 | 90 | var bigImg=document.createElement("img"); |
73 | 91 | bigImg.style.cssText="pointer-events: none;position:fixed;z-index:999"; |
74 | 92 | for(i=0;i<imgs.length;i++){ |
75 | | - let img=imgs[i],left,top; |
| 93 | + let img=imgs[i]; |
76 | 94 | 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; |
78 | 99 | document.body.appendChild(bigImg); |
79 | | - bigImg.onload=function(){ |
| 100 | + relocBigImg(left, top); |
| 101 | + getImgWH(bigImg,function(){ |
80 | 102 | relocBigImg(left, top); |
81 | | - }; |
| 103 | + }); |
82 | 104 | }; |
83 | 105 | img.onmouseout=function(e){ |
84 | 106 | document.body.removeChild(bigImg); |
85 | 107 | bigImg.removeAttribute("height"); |
86 | 108 | bigImg.removeAttribute("width"); |
| 109 | + bigImg.src=null; |
87 | 110 | }; |
88 | 111 | img.onmousemove=function(e){ |
89 | 112 | left=e.clientX; |
|
94 | 117 | relocBigImg(left, top); |
95 | 118 | }; |
96 | 119 | } |
| 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 | + }); |
97 | 144 | function relocBigImg(left, top){ |
98 | 145 | var type=bigImg.height/bigImg.width>document.documentElement.clientHeight/document.documentElement.clientWidth; |
99 | 146 | if(type && bigImg.height>document.documentElement.clientHeight){ |
|
0 commit comments