// ==UserScript== // @name 煎蛋侠 // @name:en Jiandan Hero // @name:zh-TW 煎蛋俠 // @namespace hoothin // @version 1.6 // @icon http://cdn.jandan.net/static/img/favicon.ico // @description 为煎蛋jandan.net提供左右方向键快捷翻页、上下方向键快捷切图、鼠标悬停显示大图、屏蔽指定用户发言等功能 // @description:en Tools for jandan.net // @description:zh-TW 為煎蛋jandan.net提供左右方向鍵快捷翻頁、上下方向鍵快捷切圖、鼠標懸停顯示大圖、屏蔽指定用戶發言等功能 // @author hoothin // @include http*://jandan.net/* // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @downloadURL none // ==/UserScript== (function() { 'use strict'; var timer,tempImg=document.createElement("img"),getImgWH=function(img,callBack){ if(timer)clearInterval(timer); tempImg.src=""; tempImg.src=img.src; var check=function(){ if(tempImg.width>0 || tempImg.height>0){ if(timer)clearInterval(timer); callBack(tempImg.width,tempImg.height); return true; }else{ return false; } }; var geted=check(); if(!geted){ timer = setInterval(check,40); } }; document.addEventListener("keydown", function(e) { if(/INPUT|TEXTAREA/.test(document.activeElement.tagName))return; switch(e.keyCode){ case 37://← var next=document.querySelector("span#nav_next>a"); if(next)next.click(); break; case 39://→ var pre=document.querySelector("span#nav_prev>a"); if(pre)pre.click(); break; case 38://↑ if(/jandan\.net\/(ooxx|pic)/.test(location.href)){ moveToPic(false); } break; case 40://↓ if(/jandan\.net\/(ooxx|pic)/.test(location.href)){ moveToPic(true); } break; } }); var pics=document.querySelectorAll(".commentlist .text img"),i; var currentPic; for(i=0;i $(pic).offset().top){ currentPic=pic; break; } } if(!currentPic)currentPic=pics[0]; function moveToPic(d){ for(var i=0;i(i+1)){ currentPic=pics[i+1]; }else if(!d && i>0){ currentPic=pics[i-1]; } if(currentPic.parentNode.style.display=="none")moveToPic(d); else currentPic.click(); break; } } } var authors=document.querySelectorAll("div.author"); var isHttps=location.protocol=="https:"; for(i=0;idocument.documentElement.clientHeight/document.documentElement.clientWidth; if(type && imgHeight>document.documentElement.clientHeight){ imgHeight=bigImg.height=document.documentElement.clientHeight; } if(!type && imgWidth>document.documentElement.clientWidth){ imgWidth=bigImg.width=document.documentElement.clientWidth; } if(top-imgHeight<0){ top=0; }else{ top-=imgHeight; } if(left+imgWidth>document.documentElement.clientWidth){ left=document.documentElement.clientWidth-imgWidth; } bigImg.style.left=left+10+"px"; bigImg.style.top=top+"px"; } })();