|
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.7 |
| 11 | +// @version 1.3.8 |
12 | 12 | // @author Hoothin |
13 | 13 | // @mail rixixi@gmail.com |
14 | 14 | // @include http*://*/* |
|
371 | 371 | }); |
372 | 372 | } |
373 | 373 |
|
| 374 | + var sNodes=[]; |
| 375 | + if(!Array.prototype.indexOf) |
| 376 | + Array.prototype.indexOf = function(e){ |
| 377 | + for(var i=0;i<this.length;i++){ |
| 378 | + if(e===this[i]){ |
| 379 | + return i; |
| 380 | + } |
| 381 | + } |
| 382 | + return -1; |
| 383 | + }; |
374 | 384 | function getAllEnableUrl(target) { |
375 | 385 | if(GM_getValue('eoDisable_'+document.domain))return; |
376 | 386 | var rawnodes=(target?$(target).find(enableUrl):$(enableUrl)).get(),customnodes=[]; |
|
430 | 440 | for (i = 0; i < listLen; i++) { |
431 | 441 | curNode = nodes[i]; |
432 | 442 | if(curNode.classList.contains("whx-a"))continue; |
| 443 | + if(target){ |
| 444 | + if(sNodes.indexOf(curNode)!=-1)continue; |
| 445 | + sNodes.push(curNode); |
| 446 | + } |
433 | 447 | let href=curNode.href,rUrl=getRightUrl(href); |
434 | 448 | 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")'); |
435 | 449 | if(allUrl.toString().indexOf(rUrl)==-1)allUrl.push(rUrl); |
|
529 | 543 | }else if(location.href.indexOf("github.com/hoothin/UserScripts/tree/master/Easy%20offline") != -1){ |
530 | 544 | setting(); |
531 | 545 | }else if(!isDisk){ |
| 546 | + getAllEnableUrl(); |
532 | 547 | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; |
533 | 548 | var observer = new MutationObserver(function(records){ |
534 | 549 | records.map(function(record) { |
535 | | - if(record.addedNodes)setTimeout(function(){getAllEnableUrl(record.addedNodes);},501); |
| 550 | + if(record.addedNodes.length)setTimeout(function(){getAllEnableUrl(record.addedNodes);},501); |
536 | 551 | }); |
537 | 552 | }); |
538 | 553 | var option = { |
539 | 554 | 'childList': true, |
540 | 555 | 'subtree': true |
541 | 556 | }; |
542 | 557 | observer.observe(document.body, option); |
543 | | - getAllEnableUrl(); |
544 | 558 | } |
545 | 559 |
|
546 | 560 | function setting(){ |
|
0 commit comments