Sleazy Fork is available in English.

自动获取磁链接并自动离线下载

Pada tanggal 07 Maret 2015. Lihat %(latest_version_link).

  1. // ==UserScript==
  2. // @name 挊
  3. // @namespace 撸
  4. // @description 自动获取磁链接并自动离线下载
  5. // @include http://www.javzoo.com/*
  6. // @include http://www.avmask.com/*
  7. // @include http://www.javlibrary.com/*
  8. // @include http://pan.baidu.com/disk/home
  9. // @include http://115.com/?tab=offline&mode=wangpan
  10. // @include http://cloud.letv.com/webdisk/home/index
  11. // @version 1.03
  12. // @grant GM_xmlhttpRequest
  13. // @grant GM_setClipboard
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // ==/UserScript==
  17. var av_id = "";
  18. var xhr = function(url,cb){
  19. GM_xmlhttpRequest({
  20. method: 'GET',
  21. url: url,
  22. onload: function(result){
  23. cb(result.responseText);
  24. },
  25. onerror: function (e) {
  26. console.log(e);
  27. }
  28. });
  29. };
  30. var exist_magnet = function(callback){
  31. var magnet = GM_getValue("magnet");
  32. GM_setValue("magnet","");
  33. if(magnet){
  34. callback(magnet);
  35. }
  36. };
  37. var insert_js = function(magnet,func){
  38. var js = document.createElement("script");
  39. js.innerHTML = "("+func.toString()+")('"+ magnet +"');";
  40. console.log(js);
  41. document.body.appendChild(js);
  42. };
  43. var hostmatch = function(url,callback){
  44. if(location.host == url){
  45. callback();
  46. }
  47. };
  48. var add_style = function(css){
  49. var style = document.createElement("style");
  50. style.innerHTML = css;
  51. document.head.appendChild(style);
  52. };
  53. var create_table = function(data){
  54. var table = document.createElement("table");
  55. var html="<tr><th class='magnet-th'>HASH</th><th class='magnet-th'>大小</th><th class='magnet-th'>操作</th><th class='magnet-th'>离线下载</th></tr>";
  56. for(var i=0;i<data.length;i++){
  57. html += "<tr hash='"+ data[i].hash +"'><td class='magnet-td'>"+ data[i].hash +"</td>";
  58. html += "<td class='magnet-td'>"+ data[i].size +"</td>";
  59. html += "<td class='magnet-td'><a class='magnet-copy' href='javascript:void(0);'>复制</a></td>";
  60. html += "<td class='magnet-td'><a class='magnet-download' target='_blank' href='http://pan.baidu.com/disk/home'>百度云</a> | <a class='magnet-download' target='_blank' href='http://115.com/?tab=offline&mode=wangpan'>115离线</a> | <a class='magnet-download' target='_blank' href='http://cloud.letv.com/webdisk/home/index'>乐视云盘</a></td>";//
  61. html += "</tr>";
  62. }
  63. table.innerHTML = html;
  64. return table;
  65.  
  66. };
  67.  
  68. var gethash = function(av_id,search_url,callback){
  69. xhr(search_url+av_id,function(html){
  70. var data=[];
  71. var doc = document.implementation.createHTMLDocument("");
  72. doc.documentElement.innerHTML = html;
  73. if(search_url == "http://www.btspread.com/search/"){
  74. var t = doc.getElementsByTagName("tbody")[0];
  75. if(!t){return;}
  76. else{
  77. var aElems = t.getElementsByClassName("action");
  78. var bElems = t.getElementsByClassName("files-size");
  79. var tmp;
  80. for(var i=0;i<aElems.length;i++){
  81. tmp = aElems[i].firstChild.href;
  82. data.push({"hash":tmp.substring(tmp.indexOf("hash/")+5),"size":bElems[i].textContent});
  83. }
  84. callback(data);
  85. }
  86. }
  87. });
  88. };
  89. var handle_copy = function(elements){
  90. for(var i=0;i<elements.length;i++){
  91. elements[i].addEventListener("click",function(event){
  92. GM_setClipboard("magnet:?xt=urn:btih:" + event.target.parentElement.parentElement.getAttribute("hash"));
  93. },false);
  94. }
  95. };
  96. var handle_download = function(elements){
  97. for(var i=0;i<elements.length;i++){
  98. elements[i].addEventListener("click",function(event){
  99. GM_setValue("magnet","magnet:?xt=urn:btih:"+event.target.parentElement.parentElement.getAttribute("hash"));
  100. },false);
  101. }
  102. };
  103. hostmatch("www.javzoo.com",function(){
  104. if(location.href.match("movie")){
  105. av_id = document.getElementsByClassName("header")[0].nextElementSibling.innerHTML;
  106. var search_url = "http://www.btspread.com/search/";
  107. gethash(av_id,search_url,function(data){
  108. add_style("#magnet-table table{margin:10px auto;border:1px solid #cad9ea;color:#666;}.magnet-th,.magnet-td{height:30px; border:1px solid #cad9ea;padding:0 1em 0;}.magnet-copy{color:#08c;}.magnet-download{color:#0003FF;}");
  109. var table = create_table(data);
  110. var title = document.createElement("h4");
  111. title.innerHTML = "磁链接";
  112. var wrapper = document.createElement("div");
  113. wrapper.id="magnet-table";
  114. wrapper.appendChild(table);
  115. var tmp = document.getElementById("movie-share");
  116. tmp.parentElement.insertBefore(wrapper,tmp.nextElementSibling);
  117. tmp.parentElement.insertBefore(title,tmp.nextElementSibling);
  118.  
  119. handle_copy(document.getElementsByClassName("magnet-copy"));
  120. handle_download(document.getElementsByClassName("magnet-download"));
  121. });
  122. }
  123. });
  124. hostmatch("www.avmask.com",function(){
  125. if(location.href.match("movie")){
  126. av_id = document.getElementsByClassName("header")[0].nextElementSibling.innerHTML;
  127. var search_url = "http://www.btspread.com/search/";
  128. gethash(av_id,search_url,function(data){
  129. add_style("#magnet-table table{margin:10px auto;border:1px solid #cad9ea;color:#666;}.magnet-th,.magnet-td{height:30px; border:1px solid #cad9ea;padding:0 1em 0;}.magnet-copy{color:#08c;}.magnet-download{color:#0003FF;}");
  130. var table = create_table(data);
  131. var title = document.createElement("h4");
  132. title.innerHTML = "磁链接";
  133. var wrapper = document.createElement("div");
  134. wrapper.id="magnet-table";
  135. wrapper.appendChild(table);
  136. var tmp = document.getElementById("movie-share");
  137. tmp.parentElement.insertBefore(wrapper,tmp.nextElementSibling);
  138. tmp.parentElement.insertBefore(title,tmp.nextElementSibling);
  139.  
  140. handle_copy(document.getElementsByClassName("magnet-copy"));
  141. handle_download(document.getElementsByClassName("magnet-download"));
  142. });
  143. }
  144. });
  145. hostmatch("www.javlibrary.com",function(){
  146. if(location.search.match("\\?v=")){
  147. av_id = document.getElementById("video_id").getElementsByClassName("text")[0].innerHTML;
  148. var search_url = "http://www.btspread.com/search/";
  149. gethash(av_id,search_url,function(data){
  150. add_style("#magnet-table table{margin:10px auto;border:1px solid #cad9ea;color:#666;text-align: center;}.magnet-th,.magnet-td{height:30px; border:1px solid #cad9ea;padding:0 1em 0;}.magnet-copy{color:#08c;}.magnet-download{color:#0003FF;}");
  151. var table = create_table(data);
  152. var title = document.createElement("h4");
  153. title.innerHTML = "磁链接";
  154. var wrapper = document.createElement("div");
  155. wrapper.id="magnet-table";
  156. wrapper.appendChild(table);
  157. var tmp = document.getElementById("video_favorite_edit");
  158. tmp.parentElement.insertBefore(wrapper,tmp.nextElementSibling);
  159. tmp.parentElement.insertBefore(title,tmp.nextElementSibling);
  160. handle_copy(document.getElementsByClassName("magnet-copy"));
  161. handle_download(document.getElementsByClassName("magnet-download"));
  162. });
  163. }
  164. });
  165. hostmatch("pan.baidu.com",function(){
  166. exist_magnet(function(magnet){
  167. insert_js(magnet,function(magnet){
  168. $(".icon-btn-download").click();
  169. setTimeout(function(){
  170. $("#_disk_id_24").click();
  171. setTimeout(function(){
  172. $("#_disk_id_12").click();
  173. $("#share-offline-link").val(magnet);
  174. },500);
  175. },500);
  176. });
  177. });
  178. });
  179. hostmatch("115.com",function(){
  180. exist_magnet(function(magnet){
  181. insert_js(magnet,function(magnet){
  182. setTimeout(function(){
  183. Core['OFFL5Plug'].OpenLink();
  184. setTimeout(function(){
  185. $("#js_offline_new_add").val(magnet);
  186. },0);
  187. },1000);
  188. });
  189. });
  190. });
  191. hostmatch("cloud.letv.com",function(){
  192. exist_magnet(function(magnet){
  193. insert_js(magnet,function(magnet){
  194. console.log(1);
  195. setTimeout(function(){
  196. console.log(2);
  197. $("#offline-btn").click();
  198. setTimeout(function(){
  199. console.log(3);
  200. $("#offline_clear_complete").prev().click();
  201. setTimeout(function(){
  202. $("#offline-add-link").val(magnet);
  203. },500);
  204. },1000);
  205. },3000);
  206. });
  207. });
  208. });