BaiDuYun_Multi_Offline

Add multiple download feature to Baidu Yun offine download.

  1. // ==UserScript==
  2. // @id 9adb84aba536@scriptish
  3. // @name BaiDuYun_Multi_Offline
  4. // @version 2014.6.27.1
  5. // @namespace 9adb84aba536@scriptish
  6. // @include http://pan.baidu.com/disk/*
  7. // @include http://yun.baidu.com/disk/*
  8. // @grant GM_addStyle
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_log
  11. // @grant unsafeWindow
  12. // @run-at document-end
  13. // @author zklhp
  14. // @description Add multiple download feature to Baidu Yun offine download.
  15. // ==/UserScript==
  16.  
  17. var urls = [];
  18. var success = []; // true: success, false: fail.
  19. var div_content = "";
  20. var i = 0;
  21. var fontred = '<font color="red">';
  22. var fontgreen = '<font color="green">';
  23. var fontclose = '</font>';
  24.  
  25. function send_urls()
  26. {
  27. setTimeout(function () {
  28. var data_to_send = "method=add_task&app_id=250528&source_url=";
  29. data_to_send += encodeURIComponent(urls[i]);
  30. data_to_send += "&save_path=";
  31. data_to_send += encodeURIComponent(document.querySelector('input#Path').value);
  32. GM_xmlhttpRequest({
  33. method: 'POST',
  34. url: "http://pan.baidu.com/rest/2.0/services/cloud_dl?bdstoken=" + unsafeWindow.yunData.MYBDSTOKEN + "&bdstoken=" + unsafeWindow.yunData.MYBDSTOKEN + "&channel=chunlei&clienttype=0&web=1&app_id=250528",
  35. synchronous: false,
  36. data: data_to_send,
  37. headers:
  38. {
  39. "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
  40. },
  41. onload: function (response) {
  42. // GM_log([
  43. // response.status,
  44. // response.statusText,
  45. // response.readyState,
  46. // response.responseHeaders,
  47. // response.responseText,
  48. // response.finalUrl
  49. // ].join("\n"));
  50. if (response.status == '200')
  51. {
  52. success[i] = true;
  53. }
  54. else
  55. {
  56. success[i] = false;
  57. }
  58. var tmp = "";
  59. var k = 0
  60. for (k = 0; k <= i; k++)
  61. {
  62. if (success[k])
  63. {
  64. tmp += fontgreen;
  65. }
  66. else
  67. {
  68. tmp += fontred;
  69. }
  70. tmp += urls[k];
  71. tmp += fontclose;
  72. tmp += '<br>';
  73. }
  74. for (k = i + 1; k < urls.length; k++)
  75. {
  76. tmp += urls[k];
  77. tmp += '<br>';
  78. }
  79. document.querySelector('div#Float_edit').innerHTML = "";
  80. document.querySelector('div#Float_edit').innerHTML = tmp;
  81. i++;
  82. if (i < urls.length)
  83. {
  84. send_urls();
  85. }
  86. else
  87. {
  88. alert("\u5B8C\u6210");
  89. // document.body.removeChild(document.querySelector('div#Main_frame'));
  90. }
  91. }
  92. });
  93.  
  94. }, 50);
  95. }
  96.  
  97. function add()
  98. {
  99. urls = [];
  100. success = [];
  101. i = 0;
  102. div_content = document.querySelector('div#Float_edit').innerHTML;
  103. //remove <strong></strong><font color="red"><font color="green"></font>
  104. div_content.replace(/\<.*strong.*\>/g, "");
  105. div_content.replace(/\<.*font.*\>/g, "");
  106. document.querySelector('div#Float_edit').innerHTML = div_content;
  107. urls = div_content.split('<br>');
  108. send_urls();
  109. }
  110.  
  111.  
  112. function show_add_div()
  113. {
  114. var div = document.createElement('div');
  115. div.id = 'Main_frame';
  116. div.innerHTML = '<div id="Main_float">'
  117. +'<div id="Float_edit" contentEditable="true">'
  118. +'</div></div>'
  119. +'<div id="Setting"><span>\u8DEF\u5F84\u5E94\u8BE5\u662F\u5FC5\u987B\u5B58\u5728<input id="Path" type="text" onkeydown="if(event.keyCode==13) return false;"></input></span></div>'
  120. +'<div id="Button"><span id="YesBtn" class="fff">\u5F00\u59CB</span><span id="NoBtn" class="fff">\u53D6\u6D88</span></div></div>';
  121. document.querySelector('body').appendChild(div);
  122. var div_css = '\
  123. #Main_float\
  124. {\
  125. margin:auto;\
  126. width:90%;\
  127. height:90%;\
  128. background:#F9EED0;\
  129. border:solid #DFDFDF 10px;\
  130. }\
  131. #Float_edit\
  132. {\
  133. margin:auto;\
  134. border:none !important;\
  135. overflow:auto;\
  136. width: 100%;\
  137. height: 100%;\
  138. font-size:25px;\
  139. text-align:left;\
  140. color:black;\
  141. }\
  142. #Main_frame\
  143. {\
  144. text-align:center;\
  145. position: fixed;\
  146. bottom: 25%;\
  147. left: 25%;\
  148. width: 50%;\
  149. height: 50%;\
  150. z-index: 10086;\
  151. background: lavender !important;\
  152. opacity:.9;\
  153. }\
  154. #Button\
  155. {\
  156. margin:auto;\
  157. height:50px;\
  158. display:block;\
  159. cursor:pointer;\
  160. background: lavender !important;\
  161. }\
  162. #Button span\
  163. {\
  164. position:relative;\
  165. top:10%;\
  166. margin-right:10px;\
  167. font-size:30px;\
  168. border:1px solid grey;\
  169. width:50px;\
  170. height:50px;\
  171. }\
  172. #Setting\
  173. {\
  174. margin:auto;\
  175. height:40px;\
  176. display:block;\
  177. cursor:pointer;\
  178. background: lavender !important;\
  179. }\
  180. #Setting span\
  181. {\
  182. position:relative;\
  183. top:10px;\
  184. font-size:20px;\
  185. width:40px;\
  186. height:40px;\
  187. }\
  188. #Setting input\
  189. {\
  190. color:green;\
  191. font-size:20px;\
  192. left:20px;\
  193. }';
  194. GM_addStyle(div_css);
  195. document.querySelector('span#NoBtn.fff').onmousedown = function () {document.body.removeChild(document.querySelector('div#Main_frame'));};
  196. document.querySelector('span#YesBtn.fff').onmousedown = function () {add();};
  197. document.querySelector('input#Path').value = "/";
  198. }
  199. (function (){
  200. var q_sel = document.querySelector('div.bar.global-clearfix');
  201. var ele_to_add = document.createElement('a');
  202. ele_to_add.className = "icon-btn-download";
  203. ele_to_add.text = "\u6279\u91CF\u4E0B\u8F7D";
  204. ele_to_add.onmousedown = show_add_div;
  205. q_sel.appendChild(ele_to_add);
  206. }) ();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址