Sleazy Fork is available in English.

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

Ekde 2015/03/05. Vidu La ĝisdata versio.

  1. // ==UserScript==
  2. // @name 挊
  3. // @namespace 撸
  4. // @description 自动获取磁链接并自动离线下载
  5. // @include http://www.javzoo.com/*
  6. // @include http://www.avmask.com/*
  7. // @include http://pan.baidu.com/disk/home*
  8. // @version 1.02
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_setClipboard
  11. // ==/UserScript==
  12. if(location.host=="www.javzoo.com" || location.host=="www.avmask.com"){
  13. //if(!location.pathname.match("/cn")) location.pathname = "/cn";
  14. var gethashs = function(av_id,callback){
  15. var hash_list = [];
  16. var doc = document.implementation.createHTMLDocument("");
  17. GM_xmlhttpRequest({
  18. method: 'GET',
  19. url: "http://www.btspread.com/search/"+ av_id,
  20. onload: function(result){
  21. doc.documentElement.innerHTML = result.responseText;
  22. if(!doc.getElementsByTagName("tbody")[0]){return;}
  23. var eles = doc.getElementsByTagName("tbody")[0].getElementsByClassName("action");
  24. for(var i=0;i<eles.length;i++){
  25. var tmp = eles[i].firstChild.href;
  26. hash_list.push(tmp.substring(tmp.indexOf("hash/")+5));
  27. }
  28. callback(hash_list);
  29. },
  30. onerror: function (e) {
  31. console.log(e);
  32. }
  33. });
  34. };
  35. if(location.href.match("movie")){//介绍页面
  36. var av_id = document.getElementsByClassName("header")[0].nextElementSibling.innerHTML;//番号
  37. gethashs(av_id,function(hash_list){
  38. var html="<tr><th class='magnet-th'>HASH</th><th class='magnet-th'>操作</th><th class='magnet-th'>下载</th></tr>";
  39. for(var i=0;i<hash_list.length;i++){
  40. html += "<tr><td class='magnet-td'>%hash</td><td class='magnet-td'><a class='magnet-copy' href='javascript:void(0);' hash='%hash'>复制</a></td><td class='magnet-td'><a class='magnet-download' target='_blank' href='http://pan.baidu.com/disk/home?magnet=%hash'>离线下载</a></td></tr>".replace(/%hash/g,hash_list[i]);
  41. }
  42. var title = document.createElement("h4");
  43. title.innerHTML = "磁链接";
  44. var wrapper = document.createElement("div");
  45. wrapper.id="magnet-table";
  46. var table = document.createElement("table");
  47. table.innerHTML = html;
  48. wrapper.appendChild(table);
  49. var tmp = document.getElementById("movie-share");
  50. tmp.parentElement.insertBefore(wrapper,tmp.nextElementSibling);
  51. tmp.parentElement.insertBefore(title,tmp.nextElementSibling);
  52.  
  53. var style = document.createElement("style");
  54. style.innerHTML = "#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;}";
  55. document.head.appendChild(style);
  56. var elements = document.getElementsByClassName("magnet-copy");
  57. for(var k=0;k<elements.length;k++){
  58. elements[k].addEventListener("click",function(event){
  59. GM_setClipboard("magnet:?xt=urn:btih:" + event.target.getAttribute("hash"));//复制磁链接到剪切板
  60. },false);
  61. }
  62. });
  63. }
  64. }
  65. else if(location.host=="pan.baidu.com"){
  66. if(location.search.match("magnet")){
  67. var js = document.createElement("script");
  68. js.innerHTML = "("+ (function(){
  69. $(".icon-btn-download").click();
  70. setTimeout(function(){
  71. $("#_disk_id_24").click();
  72. setTimeout(function(){
  73. $("#_disk_id_12").click();
  74. $("#share-offline-link").val(location.search.replace("?magnet=","magnet:?xt=urn:btih:"));
  75. window.history.pushState({},0,"home");
  76. },500);
  77. },500);
  78. }).toString() + ")()";
  79. document.body.appendChild(js);
  80. }
  81. }