|
8 | 8 | // @namespace http://tampermonkey.net/ |
9 | 9 | // @require https://cdn.jsdelivr.net/jquery/1.7.2/jquery.min.js |
10 | 10 | // @require https://cdn.jsdelivr.net/hi-base64/0.2.0/base64.min.js |
11 | | -// @version 1.3.13 |
| 11 | +// @version 1.3.15 |
12 | 12 | // @author Hoothin |
13 | 13 | // @mail rixixi@gmail.com |
14 | 14 | // @include http*://*/* |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 |
|
282 | | - var isCssSeted=false; |
| 282 | + var isInited=false; |
| 283 | + function init(){ |
| 284 | + if(isInited)return; |
| 285 | + isInited=true; |
| 286 | + $("body").append(parentDiv); |
| 287 | + setCss(); |
| 288 | + } |
| 289 | + |
283 | 290 | function setCss(){ |
284 | | - if(isCssSeted)return; |
285 | | - isCssSeted=true; |
286 | 291 | $('head').append(` |
287 | 292 | <style> |
288 | 293 | a.whx-a{ |
|
335 | 340 | let siteConfig=sitesArr[x]; |
336 | 341 | offNode.css("background-color","#"+siteConfig.bgColor).attr("title",i18n[siteConfig.name] ).attr("href", siteConfig.url).attr("name", siteConfig.name); |
337 | 342 | offNode.click(function(e){ |
338 | | - if(!siteConfig.directUrl){ |
| 343 | + if(siteConfig.directUrl){ |
| 344 | + offNode.attr('href', siteConfig.directUrl(offUrl)); |
| 345 | + }else{ |
339 | 346 | if(e.ctrlKey && e.shiftKey && siteConfig.canMul) |
340 | 347 | GM_setValue("eoUrl",allUrl); |
341 | 348 | else GM_setValue("eoUrl",offUrl); |
|
437 | 444 | } |
438 | 445 |
|
439 | 446 | if(nodes.length > 0){ |
440 | | - $("body").append(parentDiv); |
| 447 | + init(); |
441 | 448 | var codeList = []; |
442 | | - var listLen = 0; |
443 | | - listLen = nodes.length; |
444 | | - setCss(); |
| 449 | + var listLen = nodes.length; |
445 | 450 | if (listLen !== 0) { |
446 | 451 | for (i = 0; i < listLen; i++) { |
447 | 452 | curNode = nodes[i]; |
|
454 | 459 | let clone=$("<a></a>").attr("style",curNode.getAttribute("style")).attr("href",href).addClass('whx-a').css("background-color","#e1e1e1").css("background-image",'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAARVBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADc6ur3AAAAFnRSTlMAYM5vMOA/ENGegK2olI6G1b97Z0sXENA+jAAAAKFJREFUKM+FklkSxCAIRHFfss3K/Y86iQSDVqzpH7FfgQpCVfAmGx+gl9JI0qrxrcNLzooEbKUG4EKWdkCiDRV0N0RTrZ5wvdgTTgp4SzCAHxAPZkAM5GOJWuuT7FE5OVPOBFLTYb3Oc2YB5uJ8+G6pgkTGt74ntcCJHiwFLHw10Tdc93jlGXGvSRtsHNpuPs+/o1ODfxAtSL0f7HPC+L/9AF60G3QxO1UaAAAAAElFTkSuQmCC")'); |
455 | 460 | if(allUrl.toString().indexOf(href)==-1)allUrl.push(href); |
456 | 461 | clone.mouseover(function(e){ |
457 | | - offUrl=href; |
458 | | - parentDiv.css("display","block"); |
459 | 462 | var basePos=clone.offset(); |
460 | | - parentDiv.offset({top:basePos.top,left:basePos.left}); |
461 | | - let j=0; |
462 | | - for(var x=0;x<offNodes.length;x++){ |
463 | | - let node=offNodes[x]; |
464 | | - let siteConfig=sites[node.attr("name")]; |
465 | | - if(/^magnet/i.test(offUrl) && siteConfig.noMag){ |
466 | | - node.hide(); |
467 | | - }else if(/^ftp/i.test(offUrl) && siteConfig.noFtp){ |
468 | | - node.hide(); |
469 | | - }else if(/^ed2k:\/\//i.test(offUrl) && siteConfig.noEd2k){ |
470 | | - node.hide(); |
471 | | - }else{ |
472 | | - node.show(); |
473 | | - node.css("margin-top",-j*25+"px"); |
474 | | - j++; |
475 | | - if(siteConfig.directUrl){ |
476 | | - node.attr('href', siteConfig.directUrl(offUrl)); |
477 | | - } |
478 | | - } |
479 | | - } |
| 463 | + showDiskIcons(href,basePos.top,basePos.left); |
480 | 464 | e.stopPropagation(); |
481 | 465 | }); |
482 | 466 | $(curNode).after(clone); |
|
495 | 479 | } |
496 | 480 | } |
497 | 481 |
|
| 482 | + function showDiskIcons(url, top, left){ |
| 483 | + offUrl=url; |
| 484 | + parentDiv.css("display","block"); |
| 485 | + parentDiv.offset({top:top,left:left}); |
| 486 | + let j=0; |
| 487 | + for(var x=0;x<offNodes.length;x++){ |
| 488 | + let node=offNodes[x]; |
| 489 | + let siteConfig=sites[node.attr("name")]; |
| 490 | + if(/^magnet/i.test(offUrl) && siteConfig.noMag){ |
| 491 | + node.hide(); |
| 492 | + }else if(/^ftp/i.test(offUrl) && siteConfig.noFtp){ |
| 493 | + node.hide(); |
| 494 | + }else if(/^ed2k:\/\//i.test(offUrl) && siteConfig.noEd2k){ |
| 495 | + node.hide(); |
| 496 | + }else{ |
| 497 | + node.show(); |
| 498 | + node.css("margin-top",-j*25+"px"); |
| 499 | + j++; |
| 500 | + } |
| 501 | + } |
| 502 | + var minTop=$(document).scrollTop()+(j-1)*25; |
| 503 | + if(top<minTop){ |
| 504 | + parentDiv.offset({top:minTop,left:left}); |
| 505 | + } |
| 506 | + } |
| 507 | + |
498 | 508 | function getRightUrl(url){ |
499 | 509 | var newUrl = url; |
500 | 510 | if(/^magnet/.test(url)){ |
|
701 | 711 | } |
702 | 712 | } |
703 | 713 | if(/^(magnet|ed2k:\/\/\|file|https?:|ftp:)/.test(link)){ |
704 | | - if(!isCssSeted){ |
705 | | - $("body").append(parentDiv); |
706 | | - setCss(); |
707 | | - } |
708 | | - offUrl=link; |
709 | | - parentDiv.css("display","block"); |
710 | | - parentDiv.offset({top:mouseEve.pageY,left:mouseEve.pageX}); |
711 | | - let j=0; |
712 | | - for(var x=0;x<offNodes.length;x++){ |
713 | | - let node=offNodes[x]; |
714 | | - let siteConfig=sites[node.attr("name")]; |
715 | | - if(/^magnet/i.test(offUrl) && siteConfig.noMag){ |
716 | | - node.hide(); |
717 | | - }else if(/^ftp/i.test(offUrl) && siteConfig.noFtp){ |
718 | | - node.hide(); |
719 | | - }else if(/^ed2k:\/\//i.test(offUrl) && siteConfig.noEd2k){ |
720 | | - node.hide(); |
721 | | - }else{ |
722 | | - node.show(); |
723 | | - node.css("margin-top",-j*25+"px"); |
724 | | - j++; |
725 | | - if(siteConfig.directUrl){ |
726 | | - node.attr('href', siteConfig.directUrl(offUrl)); |
727 | | - } |
728 | | - } |
729 | | - } |
| 714 | + init(); |
| 715 | + showDiskIcons(getRightUrl(link),mouseEve.pageY-10,mouseEve.pageX-10); |
730 | 716 | } |
731 | 717 | } |
732 | 718 |
|
|
0 commit comments