|
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.1.0 |
| 11 | +// @version 1.1.1 |
12 | 12 | // @author Hoothin |
13 | 13 | // @mail rixixi@gmail.com |
14 | 14 | // @include http*://*/* |
|
337 | 337 | } |
338 | 338 |
|
339 | 339 | var i=0; |
340 | | - var t=window.setInterval(function() { |
341 | | - var curlink; |
342 | | - if (location.href.indexOf("github.com/hoothin/UserScripts/tree/master/Easy%20offline") != -1){ |
343 | | - window.clearInterval(t); |
344 | | - $('head').append(` |
| 340 | + var curlink=GM_getValue('eoUrl'); |
| 341 | + var isDisk=/furk\.net|seedr\.cc|pan\.baidu\.com\/disk|115\.com|pcloud\.com/.test(location.href); |
| 342 | + if(isDisk){ |
| 343 | + if(curlink){ |
| 344 | + diskFun(); |
| 345 | + GM_deleteValue('eoUrl'); |
| 346 | + } |
| 347 | + }else if(location.href.indexOf("pan.baidu.com/wap/home") != -1){ |
| 348 | + if(curlink)location.href="https://pan.baidu.com/disk/home"; |
| 349 | + }else if (location.href.indexOf("github.com/hoothin/UserScripts/tree/master/Easy%20offline") != -1){ |
| 350 | + setting(); |
| 351 | + }else{ |
| 352 | + var t=window.setInterval(function() { |
| 353 | + if(i > 2 || ((i++) === 0 && $(enableUrl).length > 0)){ |
| 354 | + window.clearInterval(t); |
| 355 | + getAllEnableUrl(); |
| 356 | + } |
| 357 | + }, 500); |
| 358 | + } |
| 359 | + |
| 360 | + function setting(){ |
| 361 | + $('head').append(` |
345 | 362 | <style> |
346 | 363 | .whx-btn{ |
347 | 364 | background-color:#3892ed; |
|
351 | 368 | background-color:#83c1ff; |
352 | 369 | } |
353 | 370 | </style>`); |
354 | | - var configContent=document.createElement("div"); |
355 | | - document.body.appendChild(configContent); |
356 | | - configContent.outerHTML=` |
| 371 | + var configContent=document.createElement("div"); |
| 372 | + document.body.appendChild(configContent); |
| 373 | + configContent.outerHTML=` |
357 | 374 | <div id="configContent" style="display: none;"> |
358 | 375 | <div style="width:300px;height:300px;position:fixed;left:50%;top:50%;margin-top:-150px;margin-left:-150px;z-index:100000;background-color:#ffffff;border:1px solid #afb3b6;border-radius:10px;opacity:0.95;filter:alpha(opacity=95);box-shadow:5px 5px 20px 0px #000;"> |
359 | 376 | <div style="text-align:center;font-size: 12px;margin-top: 28px;">自定义需要启用一键下载的链接正则,一行一条</div> |
|
366 | 383 | </div> |
367 | 384 | </div> |
368 | 385 | </div>`; |
369 | | - var configInput=document.querySelector("#configInput"); |
370 | | - var configQuit=document.querySelector("#configQuit"); |
371 | | - var configSave=document.querySelector("#configSave"); |
372 | | - var showTypeCheck=document.querySelector("#showType"); |
373 | | - var icons=$("#icons"); |
374 | | - for(var x = 0; x < Object.keys(sites).length; x++){ |
375 | | - let siteConfig=sites[x]; |
376 | | - let icon=$("<div style='height:25px;width:25px;float:left;border-radius:50%;background-position:center;background-repeat:no-repeat;background-size:20px;margin-left:15px;cursor:pointer'></div>"); |
377 | | - icon.css("background-color","#"+siteConfig.bgColor).attr("title",i18n.disable+i18n[siteConfig.name] ); |
378 | | - if(GM_getValue("eoHide"+siteConfig.name)){ |
379 | | - icon.css("opacity","0.2"); |
380 | | - icon.attr("title",i18n.enable+i18n[siteConfig.name] ); |
381 | | - } |
382 | | - if(siteConfig.bgImg)icon.css("background-image","url(\""+siteConfig.bgImg+"\")"); |
383 | | - icon.on("click", function(){ |
384 | | - var eoHide=GM_getValue("eoHide"+siteConfig.name); |
385 | | - GM_setValue("eoHide"+siteConfig.name, !eoHide); |
386 | | - icon.css("opacity",eoHide?"1":"0.2"); |
387 | | - icon.attr("title",(eoHide?i18n.disable:i18n.enable)+i18n[siteConfig.name] ); |
388 | | - }); |
389 | | - icons.append(icon); |
| 386 | + var configInput=document.querySelector("#configInput"); |
| 387 | + var configQuit=document.querySelector("#configQuit"); |
| 388 | + var configSave=document.querySelector("#configSave"); |
| 389 | + var showTypeCheck=document.querySelector("#showType"); |
| 390 | + var icons=$("#icons"); |
| 391 | + for(var x = 0; x < Object.keys(sites).length; x++){ |
| 392 | + let siteConfig=sites[x]; |
| 393 | + let icon=$("<div style='height:25px;width:25px;float:left;border-radius:50%;background-position:center;background-repeat:no-repeat;background-size:20px;margin-left:15px;cursor:pointer'></div>"); |
| 394 | + icon.css("background-color","#"+siteConfig.bgColor).attr("title",i18n.disable+i18n[siteConfig.name] ); |
| 395 | + if(GM_getValue("eoHide"+siteConfig.name)){ |
| 396 | + icon.css("opacity","0.2"); |
| 397 | + icon.attr("title",i18n.enable+i18n[siteConfig.name] ); |
390 | 398 | } |
391 | | - configContent=document.querySelector("#configContent"); |
392 | | - configContent.style.display="block"; |
393 | | - if(GM_getValue("eoReg"))$(configInput).val(GM_getValue("eoReg").join("\n")); |
394 | | - if(GM_getValue("showType"))showTypeCheck.checked=true; |
395 | | - $(configQuit).click(function (event) {configContent.style.display="none";}); |
396 | | - $(configSave).click(function (event) { |
397 | | - var regStr=$(configInput).val(); |
| 399 | + if(siteConfig.bgImg)icon.css("background-image","url(\""+siteConfig.bgImg+"\")"); |
| 400 | + icon.on("click", function(){ |
| 401 | + var eoHide=GM_getValue("eoHide"+siteConfig.name); |
| 402 | + GM_setValue("eoHide"+siteConfig.name, !eoHide); |
| 403 | + icon.css("opacity",eoHide?"1":"0.2"); |
| 404 | + icon.attr("title",(eoHide?i18n.disable:i18n.enable)+i18n[siteConfig.name] ); |
| 405 | + }); |
| 406 | + icons.append(icon); |
| 407 | + } |
| 408 | + configContent=document.querySelector("#configContent"); |
| 409 | + configContent.style.display="block"; |
| 410 | + if(GM_getValue("eoReg"))$(configInput).val(GM_getValue("eoReg").join("\n")); |
| 411 | + if(GM_getValue("showType"))showTypeCheck.checked=true; |
| 412 | + $(configQuit).click(function (event) {configContent.style.display="none";}); |
| 413 | + $(configSave).click(function (event) { |
| 414 | + var regStr=$(configInput).val(); |
| 415 | + if(!/^\s*$/.test(regStr)){ |
398 | 416 | var regStrs=regStr.split("\n"); |
399 | 417 | for(var reg of regStrs){ |
400 | 418 | try{ |
|
405 | 423 | } |
406 | 424 | } |
407 | 425 | GM_setValue("eoReg",regStrs); |
408 | | - GM_setValue("showType", showTypeCheck.checked); |
409 | | - alert("设置成功"); |
410 | | - }); |
411 | | - }else if (location.href.indexOf("furk.net/users/files/add") != -1){ |
412 | | - window.clearInterval(t); |
413 | | - curlink = GM_getValue('eoUrl'); |
414 | | - if(curlink){ |
415 | | - setTimeout(function() { |
416 | | - $('#url').val(curlink); |
417 | | - GM_deleteValue('eoUrl'); |
418 | | - $(":submit[value='Add download']").click(); |
419 | | - }, 500); |
420 | 426 | } |
| 427 | + GM_setValue("showType", showTypeCheck.checked); |
| 428 | + alert("设置成功"); |
| 429 | + }); |
| 430 | + } |
| 431 | + |
| 432 | + function diskFun(){ |
| 433 | + if (location.href.indexOf("furk.net/users/files/add") != -1){ |
| 434 | + setTimeout(function() { |
| 435 | + $('#url').val(curlink); |
| 436 | + $(":submit[value='Add download']").click(); |
| 437 | + }, 500); |
421 | 438 | }else if(location.href.indexOf("seedr.cc/files") != -1){ |
422 | | - if($('#upload-button').css("display") != "none"){ |
423 | | - window.clearInterval(t); |
424 | | - curlink = GM_getValue('eoUrl'); |
425 | | - if(curlink){ |
| 439 | + var sdi = setInterval(function() { |
| 440 | + if($('#upload-button').css("display") != "none"){ |
| 441 | + window.clearInterval(sdi); |
426 | 442 | setTimeout(function() { |
427 | 443 | $(':text[name="torrent"]').val(curlink); |
428 | | - GM_deleteValue('eoUrl'); |
429 | 444 | $('#upload-button').click(); |
430 | 445 | }, 500); |
431 | 446 | } |
432 | | - } |
| 447 | + },500); |
433 | 448 | }else if(location.href.indexOf("pan.baidu.com/disk/home") != -1){ |
434 | | - window.clearInterval(t); |
435 | | - curlink = GM_getValue('eoUrl'); |
436 | | - if(curlink){ |
437 | | - document.querySelector('.g-button[data-button-id=b13]').click(); |
438 | | - var bsi = setInterval(function() { |
439 | | - var newTaskBtn = document.querySelector('#_disk_id_2'); |
440 | | - if(newTaskBtn){ |
441 | | - clearInterval(bsi); |
442 | | - newTaskBtn.click(); |
443 | | - var bsl = setInterval(function() { |
444 | | - var offLink=document.querySelector('#share-offline-link'); |
445 | | - if(offLink){ |
446 | | - clearInterval(bsl); |
447 | | - offLink.value = curlink; |
448 | | - document.querySelectorAll('#newoffline-dialog>.dialog-footer>.g-button')[1].click(); |
449 | | - if(/^magnet|torrent$/.test(curlink)) |
450 | | - var i=0, bsb = setInterval(function(){ |
451 | | - var btList=document.querySelector('#offlinebtlist-dialog'); |
452 | | - if(++i>50 || (btList && btList.style.display!="none")){ |
453 | | - clearInterval(bsb); |
454 | | - btList.querySelectorAll('.dialog-footer>.g-button')[1].click(); |
455 | | - } |
456 | | - }, 200); |
457 | | - } |
458 | | - }, 500); |
459 | | - } |
460 | | - }, 500); |
461 | | - GM_deleteValue('eoUrl'); |
462 | | - } |
| 449 | + document.querySelector('.g-button[data-button-id=b13]').click(); |
| 450 | + var bsi = setInterval(function() { |
| 451 | + var newTaskBtn = document.querySelector('#_disk_id_2'); |
| 452 | + if(newTaskBtn){ |
| 453 | + clearInterval(bsi); |
| 454 | + newTaskBtn.click(); |
| 455 | + var bsl = setInterval(function() { |
| 456 | + var offLink=document.querySelector('#share-offline-link'); |
| 457 | + if(offLink){ |
| 458 | + clearInterval(bsl); |
| 459 | + offLink.value = curlink; |
| 460 | + document.querySelectorAll('#newoffline-dialog>.dialog-footer>.g-button')[1].click(); |
| 461 | + if(/^magnet|torrent$/.test(curlink)) |
| 462 | + var i=0, bsb = setInterval(function(){ |
| 463 | + var btList=document.querySelector('#offlinebtlist-dialog'); |
| 464 | + if(++i>50 || (btList && btList.style.display!="none")){ |
| 465 | + clearInterval(bsb); |
| 466 | + btList.querySelectorAll('.dialog-footer>.g-button')[1].click(); |
| 467 | + } |
| 468 | + }, 200); |
| 469 | + } |
| 470 | + }, 500); |
| 471 | + } |
| 472 | + }, 500); |
463 | 473 | }else if(location.href.indexOf("115.com/?tab=offline&mode=wangpan") != -1){ |
464 | | - window.clearInterval(t); |
465 | | - curlink = GM_getValue('eoUrl'); |
466 | | - if(curlink){ |
467 | | - var rsc = setInterval(function() { |
468 | | - if (document.readyState == 'complete') { |
469 | | - clearInterval(rsc); |
| 474 | + var rsc = setInterval(function() { |
| 475 | + if (document.readyState == 'complete') { |
| 476 | + clearInterval(rsc); |
| 477 | + setTimeout(function() { |
| 478 | + Core['OFFL5Plug'].OpenLink(); |
470 | 479 | setTimeout(function() { |
471 | | - Core['OFFL5Plug'].OpenLink(); |
472 | | - setTimeout(function() { |
473 | | - $('#js_offline_new_add').val(curlink); |
474 | | - }, 300); |
475 | | - }, 1000); |
476 | | - } |
477 | | - }, 400); |
478 | | - GM_deleteValue('eoUrl'); |
479 | | - } |
| 480 | + $('#js_offline_new_add').val(curlink); |
| 481 | + }, 300); |
| 482 | + }, 1000); |
| 483 | + } |
| 484 | + }, 300); |
480 | 485 | }else if(location.href.indexOf("my.pcloud.com") != -1){ |
481 | | - window.clearInterval(t); |
482 | | - curlink = GM_getValue('eoUrl'); |
483 | | - if(curlink){ |
484 | | - var psc = setInterval(function() { |
485 | | - var upBtn = document.querySelector('div.upload_button'); |
486 | | - if (upBtn) { |
487 | | - clearInterval(psc); |
488 | | - upBtn.click(); |
489 | | - document.querySelector('span.remoteupload-ctrl').click(); |
490 | | - var remotearea=document.querySelector('textarea.remotearea'); |
491 | | - remotearea.value=curlink; |
492 | | - remotearea.nextSibling.click(); |
493 | | - } |
494 | | - }, 500); |
495 | | - GM_deleteValue('eoUrl'); |
496 | | - } |
497 | | - }else if(i > 2 || ((i++) === 0 && $(enableUrl).length > 0)){ |
498 | | - window.clearInterval(t); |
499 | | - getAllEnableUrl(); |
| 486 | + var psc = setInterval(function() { |
| 487 | + var upBtn = document.querySelector('div.upload_button'); |
| 488 | + if (upBtn) { |
| 489 | + clearInterval(psc); |
| 490 | + upBtn.click(); |
| 491 | + document.querySelector('span.remoteupload-ctrl').click(); |
| 492 | + var remotearea=document.querySelector('textarea.remotearea'); |
| 493 | + remotearea.value=curlink; |
| 494 | + remotearea.nextSibling.click(); |
| 495 | + } |
| 496 | + }, 500); |
500 | 497 | } |
501 | | - }, 500); |
502 | | - if(/pan\.baidu\.com\/wap\/home/.test(location.href) && GM_getValue('eoUrl')){ |
503 | | - location.href="https://pan.baidu.com/disk/home"; |
504 | 498 | } |
| 499 | + |
505 | 500 | function toggleIcon(){ |
506 | 501 | $('.whx-a').toggle(500); |
507 | 502 | if(GM_getValue('eoDisable_'+document.domain)){ |
|
0 commit comments