煎蛋侠

为煎蛋jandan.net提供左右方向键快捷翻页、上下方向键快捷切图、鼠标悬停显示大图、屏蔽指定用户发言等功能

目前为 2022-01-02 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 煎蛋侠
  3. // @name:en Jiandan Hero
  4. // @name:zh-TW 煎蛋俠
  5. // @namespace hoothin
  6. // @version 1.8
  7. // @icon http://cdn.jandan.net/static/img/favicon.ico
  8. // @description 为煎蛋jandan.net提供左右方向键快捷翻页、上下方向键快捷切图、鼠标悬停显示大图、屏蔽指定用户发言等功能
  9. // @description:en Tools for jandan.net
  10. // @description:zh-TW 為煎蛋jandan.net提供左右方向鍵快捷翻頁、上下方向鍵快捷切圖、鼠標懸停顯示大圖、屏蔽指定用戶發言等功能
  11. // @author hoothin
  12. // @include http*://jandan.net/*
  13. // @grant GM_setValue
  14. // @grant GM_getValue
  15. // @grant GM_deleteValue
  16. // @grant GM_addStyle
  17. // @run-at document-idle
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. 'use strict';
  22. var timer,tempImg=document.createElement("img"),getImgWH=function(img,callBack){
  23. if(timer)clearInterval(timer);
  24. tempImg.src="";
  25. tempImg.src=img.src;
  26. var check=function(){
  27. if(tempImg.width>0 || tempImg.height>0){
  28. if(timer)clearInterval(timer);
  29. callBack(tempImg.width,tempImg.height);
  30. return true;
  31. }else{
  32. return false;
  33. }
  34. };
  35. var geted=check();
  36. if(!geted){
  37. timer = setInterval(check,40);
  38. }
  39. };
  40.  
  41. document.addEventListener("keyup", function(e) {
  42. console.log(e.keyCode);
  43. if(/INPUT|TEXTAREA/.test(document.activeElement.tagName))return;
  44. switch(e.keyCode){
  45. case 37://←
  46. var next=document.querySelector("span#nav_next>a");
  47. if(next)next.click();
  48. break;
  49. case 39://→
  50. var pre=document.querySelector("span#nav_prev>a");
  51. if(pre)pre.click();
  52. break;
  53. case 38://↑
  54. if(/jandan\.net\/(ooxx|pic|girl|top|zoo|dzh)/.test(location.href)){
  55. moveToPic(false);
  56. }
  57. break;
  58. case 40://↓
  59. if(/jandan\.net\/(ooxx|pic|girl|top|zoo|dzh)/.test(location.href)){
  60. moveToPic(true);
  61. }
  62. break;
  63. }
  64. });
  65.  
  66. var pic,pics,currentPic,i;
  67.  
  68. function moveToPic(d){
  69. pics=document.querySelectorAll(".commentlist .text img,.tucao-list img");
  70. for(i=0;i<pics.length;i++){
  71. pic=pics[i];
  72. if(($(window).scrollTop() + $(window).height() / 2) < ($(pic).offset().top + $(pic).outerHeight()) &&
  73. ($(window).scrollTop() + $(window).height() / 2) > $(pic).offset().top){
  74. currentPic=pic;
  75. break;
  76. }
  77. }
  78. if(!currentPic && pics)currentPic=pics[0];
  79. for(var i=0;i<pics.length;i++){
  80. pic=pics[i];
  81. if(currentPic==pic){
  82. if(d && pics.length>(i+1)){
  83. currentPic=pics[i+1];
  84. }else if(!d && i>0){
  85. currentPic=pics[i-1];
  86. }
  87. if(currentPic.parentNode.style.display=="none")moveToPic(d);
  88. else{
  89. setTimeout(()=>{
  90. currentPic.scrollIntoView({behavior: "smooth", block: "center", inline: "center"});
  91. currentPic.click();
  92. },100);
  93. }
  94. break;
  95. }
  96. }
  97. }
  98. var authors=document.querySelectorAll("div.author,.tucao-author-bar");
  99. var isHttps=location.protocol=="https:";
  100. var isTucao=document.querySelector(".tucao-list")!=null;
  101. var isTop=location.href.indexOf("jandan.net/top")!=-1;
  102. $("body").on("mouseover", "div.author,.tucao-author-bar", e=>{
  103. let author=e.currentTarget,authorId;
  104. let changeBtn = author.querySelector("#changeBtn");
  105. if(changeBtn == null){
  106. changeBtn=document.createElement("a");
  107. changeBtn.href=`javascript:void(0);`;
  108. changeBtn.id="changeBtn";
  109. if(isTucao){
  110. authorId=author.querySelector(".tucao-author").innerText;
  111. author.appendChild(changeBtn);
  112. }else{
  113. authorId=isTop?author.querySelector("strong").innerText:author.querySelector("strong").title.replace(/防伪码:/,"");
  114. author.insertBefore(changeBtn,author.querySelector("br"));
  115. }
  116. changeBtn.onclick=function(){
  117. var author_s,j,shown;
  118. if(author.parentNode.classList.contains("hide")){
  119. shown=false;
  120. GM_deleteValue("jandanDis_"+authorId);
  121. }else{
  122. shown=true;
  123. GM_setValue("jandanDis_"+authorId,true);
  124. }
  125. authors=document.querySelectorAll("div.author,.tucao-author-bar");
  126. for(j=0;j<authors.length;j++){
  127. author_s=authors[j];
  128. if((isTucao && author_s.querySelector(".tucao-author").innerText==authorId) || !isTucao &&(
  129. (!isTop && author_s.querySelector("strong").title.replace(/防伪码:/,"")==authorId) ||
  130. (isTop && author_s.querySelector("strong").innerText==authorId))){
  131. //author_s.nextSibling.nextSibling.style.display=shown?"none":"block";
  132. if(shown){
  133. author_s.parentNode.classList.add("hide");
  134. author_s.querySelector("#changeBtn").innerHTML="显";
  135. }else{
  136. author_s.parentNode.classList.remove("hide");
  137. author_s.querySelector("#changeBtn").innerHTML="隐";
  138. }
  139. }
  140. }
  141. };
  142. if(GM_getValue("jandanDis_"+authorId)){
  143. author.parentNode.classList.add("hide");
  144. changeBtn.innerHTML="显";
  145. }else{
  146. changeBtn.innerHTML="隐";
  147. }
  148. }
  149. changeBtn.style.display="block";
  150. //console.log(e);
  151. });
  152. $("body").on("mouseout", "div.author,.tucao-author-bar", e=>{
  153. let author=e.currentTarget;
  154. let changeBtn = author.querySelector("#changeBtn");
  155. if(changeBtn)changeBtn.style.display="none";
  156. });
  157. /*for(i=0;i<authors.length;i++){
  158. let author=authors[i];
  159. let changeBtn=document.createElement("a");
  160. changeBtn.href=`javascript:void(0);`;
  161. changeBtn.id="changeBtn";
  162. changeBtn.style.display="none";
  163. let authorId;
  164. if(isTucao){
  165. authorId=author.querySelector(".tucao-author").innerText;
  166. author.appendChild(changeBtn);
  167. }else{
  168. authorId=isTop?author.querySelector("strong").innerText:author.querySelector("strong").title.replace(/防伪码:/,"");
  169. author.insertBefore(changeBtn,author.querySelector("br"));
  170. }
  171. if(GM_getValue("jandanDis_"+authorId)){
  172. author.parentNode.classList.add("hide");
  173. changeBtn.innerHTML="显";
  174. }else{
  175. changeBtn.innerHTML="隐";
  176. }
  177. author.onmouseover=function(){
  178. changeBtn.style.display="block";
  179. };
  180. author.onmouseout=function(){
  181. changeBtn.style.display="none";
  182. };
  183. changeBtn.onclick=function(){
  184. var author_s,j,shown;
  185. if(author.parentNode.classList.contains("hide")){
  186. shown=false;
  187. GM_deleteValue("jandanDis_"+authorId);
  188. }else{
  189. shown=true;
  190. GM_setValue("jandanDis_"+authorId,true);
  191. }
  192. for(j=0;j<authors.length;j++){
  193. author_s=authors[j];
  194. if((isTucao && author_s.querySelector(".tucao-author").innerText==authorId) || !isTucao &&(
  195. (!isTop && author_s.querySelector("strong").title.replace(/防伪码:/,"")==authorId) ||
  196. (isTop && author_s.querySelector("strong").innerText==authorId))){
  197. //author_s.nextSibling.nextSibling.style.display=shown?"none":"block";
  198. if(shown){
  199. author_s.parentNode.classList.add("hide");
  200. author_s.querySelector("#changeBtn").innerHTML="显";
  201. }else{
  202. author_s.parentNode.classList.remove("hide");
  203. author_s.querySelector("#changeBtn").innerHTML="隐";
  204. }
  205. }
  206. }
  207. };
  208. }*/
  209. var left,top,src;
  210. var bigImg=document.createElement("img");
  211. bigImg.className="big_img";
  212. $("body").on("mouseover","img",e=>{
  213. let img=e.currentTarget;
  214. src=img.src.replace(/\b(!(custom|square))\b/,"").replace(/\b(custom|square)\b/,"medium").replace(/\.sinaimg\.cn\/thumb\d+/,".sinaimg.cn/large");
  215. src=isHttps?src.replace(/http\:\/\//,"https://"):src.replace(/https\:\/\//,"http://");
  216. bigImg.src=img.src;
  217. bigImg.src=src;
  218. left=e.clientX;
  219. top=e.clientY;
  220. document.body.appendChild(bigImg);
  221. setTimeout(()=>{
  222. bigImg.style.opacity=1;
  223. },500);
  224. relocBigImg(left, top);
  225. getImgWH(bigImg,function(w,h){
  226. relocBigImg(left, top, w, h);
  227. });
  228. bigImg.onload=function(){
  229. relocBigImg(left, top);
  230. };
  231. });
  232. $("body").on("mouseout","img",e=>{
  233. if(bigImg.parentNode){
  234. bigImg.style.opacity=0;
  235. bigImg.parentNode.removeChild(bigImg);
  236. }
  237. bigImg.removeAttribute("height");
  238. bigImg.removeAttribute("width");
  239. });
  240. $("body").on("mousemove","img",e=>{
  241. left=e.clientX;
  242. top=e.clientY;
  243. if(!bigImg.src || bigImg.src===""){
  244. img.onmouseover(e);
  245. }
  246. relocBigImg(left, top);
  247. });
  248. /*for(i=0;i<imgs.length;i++){
  249. let img=imgs[i];
  250. img.onmouseover=function(e){
  251. src=img.src.replace(/\b(!(custom|square))\b/,"").replace(/\b(custom|square)\b/,"medium").replace(/\.sinaimg\.cn\/thumb\d+/,".sinaimg.cn/large");
  252. src=isHttps?src.replace(/http\:\/\//,"https://"):src.replace(/https\:\/\//,"http://");
  253. bigImg.src=img.src;
  254. bigImg.src=src;
  255. left=e.clientX;
  256. top=e.clientY;
  257. document.body.appendChild(bigImg);
  258. setTimeout(()=>{
  259. bigImg.style.opacity=1;
  260. },500);
  261. relocBigImg(left, top);
  262. getImgWH(bigImg,function(w,h){
  263. relocBigImg(left, top, w, h);
  264. });
  265. bigImg.onload=function(){
  266. relocBigImg(left, top);
  267. };
  268. };
  269. img.onmouseout=function(e){
  270. if(bigImg.parentNode){
  271. bigImg.style.opacity=0;
  272. bigImg.parentNode.removeChild(bigImg);
  273. }
  274. bigImg.removeAttribute("height");
  275. bigImg.removeAttribute("width");
  276. };
  277. img.onmousemove=function(e){
  278. left=e.clientX;
  279. top=e.clientY;
  280. if(!bigImg.src || bigImg.src===""){
  281. img.onmouseover(e);
  282. }
  283. relocBigImg(left, top);
  284. };
  285. }*/
  286. $("p").on("mouseover","div.gif-mask",function(e){
  287. src=this.previousSibling.getAttribute("org_src").replace(/\b(!(custom|square))\b/,"").replace(/\b(custom|square)\b/,"medium").replace(/\.sinaimg\.cn\/(mw600|thumb\d+)/,".sinaimg.cn/large");
  288. src=isHttps?src.replace(/http\:\/\//,"https://"):src.replace(/https\:\/\//,"http://");
  289. bigImg.src=this.previousSibling.src;
  290. bigImg.src=src;
  291. document.body.appendChild(bigImg);
  292. setTimeout(()=>{
  293. bigImg.style.opacity=1;
  294. },500);
  295. getImgWH(bigImg,function(w,h){
  296. relocBigImg(left, top, w, h);
  297. });
  298. bigImg.onload=function(){
  299. relocBigImg(left, top);
  300. };
  301. });
  302. $("p").on("mouseout","div.gif-mask",function(e){
  303. if(bigImg.parentNode){
  304. bigImg.style.opacity=0;
  305. bigImg.parentNode.removeChild(bigImg);
  306. }
  307. bigImg.removeAttribute("height");
  308. bigImg.removeAttribute("width");
  309. });
  310. $("p").on("mousemove","div.gif-mask",function(e){
  311. if(e){
  312. left=e.clientX;
  313. top=e.clientY;
  314. }
  315. if(!bigImg.src || bigImg.src===""){
  316. this.onmouseover(e);
  317. }
  318. relocBigImg(left, top);
  319. });
  320. function relocBigImg(left, top, w, h){
  321. var imgWidth=w?w:bigImg.width;
  322. var imgHeight=h?h:bigImg.height;
  323. var type=imgHeight/imgWidth>document.documentElement.clientHeight/document.documentElement.clientWidth;
  324. if(type && imgHeight>document.documentElement.clientHeight){
  325. imgHeight=bigImg.height=document.documentElement.clientHeight;
  326. }
  327. if(!type && imgWidth>document.documentElement.clientWidth){
  328. imgWidth=bigImg.width=document.documentElement.clientWidth;
  329. }
  330. if(top-imgHeight<0){
  331. top=0;
  332. }else{
  333. top-=imgHeight;
  334. }
  335. if(left+imgWidth>document.documentElement.clientWidth){
  336. left=document.documentElement.clientWidth-imgWidth;
  337. }
  338. bigImg.style.left=left+10+"px";
  339. bigImg.style.top=top+"px";
  340. }
  341. GM_addStyle(`
  342. .row.hide,.tucao-row.hide{
  343. opacity: 0.1;
  344. }
  345. .row.hide div.text,.tucao-row.hide .tucao-content,.tucao-row.hide .tucao-image{
  346. display: none;
  347. }
  348. .row.hide:hover,.tucao-row.hide:hover{
  349. opacity: 0.5;
  350. }
  351. .tucao-author-bar #changeBtn{
  352. padding: 0 10px;
  353. }
  354. .big_img{
  355. pointer-events: none;
  356. position: fixed;
  357. z-index: 999;
  358. opacity: 0;
  359. transition: opacity .5s ease-in-out;
  360. -moz-transition: opacity .5s ease-in-out;
  361. -o-transition: opacity .5s ease-in-out;
  362. -webkit-transition: opacity .5s ease-in-out;
  363. }
  364. `);
  365. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址