Easy offline | 一键离线下载

在种子或视频链接旁添加按钮离线下载至网盘 | Easy stream torrents or videos from cloud storage

当前为 2016-08-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Easy offline | 一键离线下载
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 在种子或视频链接旁添加按钮离线下载至网盘 | Easy stream torrents or videos from cloud storage
  6. // @author Hoothin
  7. // @match http*://*/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @require http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js
  11. // ==/UserScript==
  12.  
  13. function include(Things,obj) {
  14. for (var i = Things.length - 1; i >= 0; i--) {
  15. if ($(Things[i]).attr('href')===$(obj).attr('href')){
  16. return true;
  17. }
  18. }
  19. }
  20.  
  21. function setCss(){
  22. $('head').append('<style>.color1{background-color:#3BEBFF}.color2{background-color:#F44336}.color3{background-color:#ffffff}.color4{background-color:#5e5eff}a.wxz-a{ background-repeat: no-repeat;background-position: center; display: inline-block;margin-left:5px;height: 20px;width: 20px;background-size: 20px;border-radius: 50%;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAB/UlEQVRIS6WUDVEDQQyFWwVQBRQFFAetAkABRQGggFYBOKAoABRwDgAFFAWAA953s+nkMtn+wM5kus0leXn52X5vu7MvsyPJSML9W/ImeS/3tVH6GzCm+n5ZgtdMAbuTPNQMaiBk/CgZbke0tVpKzgrDjlsGQvb3OwSPphdSLLwygvwXwGJ3gDwIJXr9B4Poemyl8yDU9GAHkOcShMZTnr3gix6gnoH8pUyHpdnEmUlukgTbshkIqOwBh9kns6ZkyngyxvHMS3D07M5XYtOyASQaMO8wszPU5SMJwEIOnJ7EzhO7ASBjyYv7GJ355Jn6OH6KaslMALmS3IYM4qzDLNudVXOLf8bmGpCZJDatkW7igCnpUhInCJPVqOqesZnXmODsp4f/WZbo/QDwH9aIPaotk7HE98QIRGecYGhTiN2PhCWGZTwzKahQ25Pa+OEIG3+wJUsSsyXE7rQYPTlj7ieSdro4temhL02SZQRmxK1vgHKHITs32rTxcWciHgyYzGElkc7GY0MG8e1iZygZv5x1UxZxWhYot3mF487UnpkIkr7CGE0lceka6fzOUJrsmfEgncQ8EzPKgOLO2ORkrYjMO+XyDtSSQNYj2CwkS8lnYRxfCXpAgkxq52RMvAFOvG1+AWMMgtMnkkjPJhBzsrmHIXemjYwRm7waRu8XzEByGl4Ir08AAAAASUVORK5CYII=");vertical-align: middle;}</style>');
  23. }
  24.  
  25. function getAllEnableUrl() {
  26. var rawnodes = $('a[href^="magnet"],[href$=".torrent"],[href$=".mp4"],[href$=".rar"],[href$=".7z"],[href$=".zip"],[href$=".rmvb"],[href$=".mkv"]').get();
  27. var nodes = [];
  28. var codeList = [];
  29. var listLen = 0;
  30. for (var i = 0; i <rawnodes.length; i++) {
  31. if(!include(nodes,rawnodes[i])){
  32. nodes.push(rawnodes[i]);
  33. }
  34. }
  35. //codeList = getAllMagnet(nodes);
  36. listLen = nodes.length;
  37. setCss();
  38. if (listLen !== 0) { //prase all magnet herf nodes into string
  39. for (i = 0; i < listLen; i++) {
  40. var curNode = nodes[i];
  41. var url = $(curNode)[0]["href"];
  42. $(curNode).after($(curNode).clone().addClass('wxz-a color4').empty().attr("target","_blank").attr("url",url).attr("title","submit to 115" ).attr("href", "http://115.com/?tab=offline&mode=wangpan").click(function (event) {GM_setValue("url",$(event.target).attr("url"));}));
  43. $(curNode).after($(curNode).clone().addClass('wxz-a color1').empty().attr("target","_blank").attr("url",url).attr("title","submit to Furk" ).attr("href", "https://www.furk.net/users/files/add").click(function (event) {GM_setValue("url",$(event.target).attr("url"));}));
  44. $(curNode).after($(curNode).clone().addClass('wxz-a color2').empty().attr("target","_blank").attr("url",url).attr("title","submit to Seedr" ).attr("href", "https://www.seedr.cc/files").click(function (event) {GM_setValue("url",$(event.target).attr("url"));}));
  45. $(curNode).after($(curNode).clone().addClass('wxz-a color3').empty().attr("target","_blank").attr("url",url).attr("title","submit to BaiduPan" ).attr("href", "http://pan.baidu.com/disk/home").click(function (event) {GM_setValue("url",$(event.target).attr("url"));}));
  46. }
  47. }
  48. $('.wxz-a').css('b','d');
  49. }
  50.  
  51. var i=0;
  52. var t=window.setInterval(function() {
  53. var curlink;
  54. if (location.href.indexOf("furk.net/users/files/add") != -1){
  55. window.clearInterval(t);
  56. curlink = GM_getValue('url');
  57. if(curlink){
  58. setTimeout(function() {
  59. $('#url').val(curlink);
  60. GM_setValue('url', '');
  61. $(":submit[value='Add download']").click();
  62. }, 500);
  63. }
  64. }else if(location.href.indexOf("seedr.cc/files") != -1){
  65. window.clearInterval(t);
  66. if($('#upload-button').display != "none"){
  67. curlink = GM_getValue('url');
  68. if(curlink){
  69. setTimeout(function() {
  70. $(':text[name="torrent"]').val(curlink);
  71. GM_setValue('url', '');
  72. $('#upload-button').click();
  73. }, 500);
  74. }
  75. }
  76. }else if(location.href.indexOf("pan.baidu.com/disk/home") != -1){
  77. window.clearInterval(t);
  78. curlink = GM_getValue('url');
  79. if(curlink){
  80. document.querySelector('.g-button[data-button-id=b13]').click();
  81. setTimeout(function() {
  82. document.querySelector('#_disk_id_2').click();
  83. setTimeout(function() {
  84. document.querySelector('#share-offline-link').value = curlink;
  85. document.querySelector('.g-button[data-button-id=b63]').click();
  86. }, 500);
  87. }, 1500);
  88. GM_setValue('url', '');
  89. }
  90. }else if(location.href.indexOf("115.com/?tab=offline&mode=wangpan") != -1){
  91. window.clearInterval(t);
  92. curlink = GM_getValue('url');
  93. if(curlink){
  94. var rsc = setInterval(function() {
  95. if (document.readyState == 'complete') {
  96. clearInterval(rsc);
  97. setTimeout(function() {
  98. Core['OFFL5Plug'].OpenLink();
  99. setTimeout(function() {
  100. $('#js_offline_new_add').val(curlink);
  101. }, 300);
  102. }, 1000);
  103. }
  104. }, 400);
  105. GM_setValue('url', '');
  106. }
  107. }else if((i===0 && $('a[href^="magnet"],[href$=".torrent"],[href$=".mp4"],[href$=".rar"],[href$=".7z"],[href$=".zip"],[href$=".rmvb"],[href$=".mkv"]').length>0)||i>20){
  108. window.clearInterval(t);
  109. getAllEnableUrl();
  110. }else{
  111. i++;
  112. }
  113. }, 500);