Guest User

Untitled

a guest
Jul 16th, 2014
1,334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.89 KB | None | 0 0
  1. // ==UserScript==
  2. // @name 百度网盘导出工具
  3. // @author Mormts
  4. // @description 一个方便吧百度网盘的文件导出的脚本。(Aria2rpc, Aria2, Wget, IDM)。
  5. // @encoding utf-8
  6. // @homepageURL https://userscripts.org/scripts/show/178301
  7. // @updateURL https://userscripts.org/scripts/source/178301.meta.js
  8. // @downloadURL https://userscripts.org/scripts/source/178301.user.js
  9. // @include http://*n.baidu.com/s/*
  10. // @include http://*n.baidu.com/disk/home*
  11. // @include http://*n.baidu.com/share/link*
  12. // @include https://*n.baidu.com/s/*
  13. // @include https://*n.baidu.com/disk/home*
  14. // @include https://*n.baidu.com/share/link*
  15. // @run-at document-end
  16. // @version 0.2.8
  17. // ==/UserScript==
  18.  
  19.  
  20. var version = "0.2.8";
  21. var thedate_update = "2014/03/04";
  22. var baidu_version = "201402260053";
  23. //判断是否要载入远程JS和默认COOKIE的写入
  24. function A () {
  25. var name = "bcofl_v2";
  26. var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  27. name = "iswebjs";
  28. var iswebjs = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  29. if ( iswebjs ){if (iswebjs.length > 1){iswebjs = iswebjs[2];}else{iswebjs = "0";}}else{iswebjs = "0";}
  30. //////UpdateTime:2014.02.16//////
  31. if ( window.XMLHttpRequest ) {
  32. if ( typeof HttpSendRead == "undefined" ) {
  33. window.HttpSendRead = function (info) {
  34. var http = new XMLHttpRequest();
  35. var contentType = "\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u0078\u002d\u0077\u0077\u0077\u002d\u0066\u006f\u0072\u006d\u002d\u0075\u0072\u006c\u0065\u006e\u0063\u006f\u0064\u0065\u0064\u003b\u0020\u0063\u0068\u0061\u0072\u0073\u0065\u0074\u003d\u0055\u0054\u0046\u002d\u0038";
  36. var timeout = 3000;
  37. if (info.contentType != null){contentType = info.contentType;}
  38. if (info.timeout != null){timeout = info.timeout;}
  39. var timeId = setTimeout(httpclose, timeout);
  40. function httpclose () {
  41. http.abort();
  42. }
  43. http.onreadystatechange = function() {
  44. if (http.readyState == 4) {
  45. if ((http.status == 200 && http.status < 300) || http.status == 304) {
  46. clearTimeout(timeId);
  47. if (info.dataType == "JSON") {
  48. info.success(JSON.parse(http.responseText));
  49. }
  50. else if (info.dataType == "SCRIPT") {
  51. eval(http.responseText);
  52. info.success(http.responseText);
  53. }
  54. }
  55. else {
  56. clearTimeout(timeId);
  57. info.error(http.status);
  58. }
  59. }
  60. }
  61. //http.responseType = 'text';
  62. http.open(info.type, info.url, true);
  63. http.setRequestHeader("Content-type", contentType);
  64. for (h in info.headers) {
  65. http.setRequestHeader(h, info.headers[h]);
  66. }
  67. if (info.type == "POST") {
  68. http.send(info.data);
  69. }
  70. else {
  71. http.send();
  72. }
  73. }
  74. }
  75. }
  76. else {
  77. alert("脚本不能使用,快去换个浏览器。");
  78. }
  79. ///////end///////
  80. if(! arr){
  81. var datadefault = JSON.parse('[{"input":{"rpc_input":"http://192.168.1.1:6800/jsonrpc"},"checked":{"aria2rpc_checkbox":"checked"}}]');
  82. var base64_data = window.btoa(encodeURIComponent(JSON.stringify(datadefault)));
  83. var name = "bcofl_v2";
  84. var Days = 365;
  85. var exp = new Date();
  86. exp.setTime(exp.getTime() + Days*24*60*60*1000);
  87. document.cookie = name + "="+ base64_data + ";expires=" +exp.toGMTString()+";path=/;";
  88. A();
  89. }
  90. else{
  91. function loadjs () {
  92. if (typeof perform_of_number == "undefined")
  93. {
  94. window.perform_of_number = 1;
  95. var script = document.createElement('script');
  96. script.id = "webjs";
  97. script.src = "http://baiducloudwebplug.duapp.com/javascript/file.php?name=baiducloud_exporter_UglifyJSgg.js";
  98. script.onload = script.onreadystatechange = function(){
  99. if( ! this.readyState || this.readyState=='loaded' || this.readyState=='complete' ){
  100. //alert('loaded');
  101. clearInterval(window.loadtime);
  102. }};
  103. document.body.appendChild(script);
  104. window.loadtime = window.setTimeout(function(){
  105. Utilities.useToast({
  106. toastMode: disk.ui.Toast.MODE_CAUTION,
  107. msg: "\u52a0\u8f7d\u8fdc\u7aef\u7684\u004a\u0053\u002e\u002e\u002e\u5931\u8d25\u3002\u73b0\u5728\u4f7f\u7528\u672c\u5730\u7684\u811a\u672c\u3002",
  108. sticky: false
  109. });
  110. var id = document.getElementById("webjs");
  111. document.body.removeChild(id);
  112. window.setTimeout(A, 1000);
  113. },3500);
  114. }
  115. else{
  116. Utilities.useToast({
  117. toastMode: disk.ui.Toast.MODE_LOADING,
  118. msg: "\u597d\u50cf\u8fdc\u7aef\u811a\u672c\u4e5f\u9519\u8bef\u4e86\uff0c\u7b49\u66f4\u65b0\u5427\u3002",
  119. sticky: false
  120. });
  121. }
  122. }
  123. try {
  124. var cookiedata = JSON.parse(decodeURIComponent(window.atob(arr[2])));
  125. if (typeof perform_of_number == "undefined" && typeof mandatory == "undefined" && iswebjs == "1"){
  126. loadjs();
  127. }
  128. else if (iswebjs == "0" || perform_of_number == 1 || mandatory == 1){
  129. function localjs (){
  130. var script_ = $("script");
  131. var script_src;
  132. for (var i=0;i<script_.length;i++){
  133. script_src = $(script_[i]).attr("src");
  134. if(script_src){
  135. if (script_src.indexOf("yun_home_speed_all.js") != -1 || script_src.indexOf("viewshare_all.js") != -1 || script_src.indexOf("module_header.js") != -1){
  136. script_src = script_src.split("=")[1];
  137. if(script_src > baidu_version){
  138. // alert("\u68c0\u6d4b\u5230\u7f51\u7ad9\u6709\u66f4\u65b0\uff0c\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u95ee\u9898\u8bf7\u66f4\u65b0\u005c\u0072\u005c\u006e\u6216\u8005\u4f7f\u7528\u8fdc\u7a0b\u004a\u0053\u811a\u672c\u5728\u6216\u8005\u7b49\u5f85\u4f5c\u8005\u66f4\u65b0\u5427\u3002");
  139. var msg = "\u68c0\u6d4b\u5230\u7f51\u7ad9\u6709\u66f4\u65b0\uff0c\u5982\u4e0d\u80fd\u6b63\u5e38\u4f7f\u7528\u63d2\u4ef6\uff0c\u7b49\u66f4\u65b0\u5427\u3002";
  140. Utilities.useToast({toastMode: disk.ui.Toast.MODE_CAUTION, msg: msg, sticky: false});
  141. }else{
  142. var msg = "\u811a\u672c\u8f7d\u5165\u6ca1\u95ee\u9898"
  143. Utilities.useToast({toastMode: disk.ui.Toast.MODE_SUCCESS, msg: msg, sticky: false});
  144. }
  145. }
  146. }
  147. }
  148. //下面正式开始
  149. //disk.ui.Toast.MODE_FAILURE #错误
  150. //disk.ui.Toast.MODE_CAUTION #警告
  151. //disk.ui.Toast.MODE_LOADING #载入
  152. //disk.ui.Toast.MODE_SUCCESS #正常
  153. SetMessage = function (msg,type) {
  154. Utilities.useToast({
  155. toastMode: type,
  156. msg: msg,
  157. sticky: false
  158. });
  159. }
  160.  
  161. event = function() {
  162. //setting div
  163. $("#setting_div_more_settings_but").click(function(){
  164. if($("#setting_div_table_2").css("display") != "none" ){
  165. $("#setting_div_table_1").css("display", "table");
  166. $("#setting_div_table_2").css("display", "none");
  167. $("#setting_div_more_settings_but a").html("更多设置");
  168. }
  169. else{
  170. $("#setting_div_table_1").css("display", "none");
  171. $("#setting_div_table_2").css("display", "table");
  172. $("#setting_div_more_settings_but a").html("返回");
  173. }
  174. })
  175. $("#rpc_distinguish").click(function(){
  176. if($(this).attr("checked")){
  177. $("#rpc_user").removeAttr("disabled");
  178. $("#rpc_pass").removeAttr("disabled");
  179. }else{
  180. $("#rpc_user").attr({"disabled":"disabled"});
  181. $("#rpc_pass").attr({"disabled":"disabled"});
  182. }
  183. })
  184. $("#yingyong").click(function(){
  185. // var str = $("#rpc_user").attr("value") + $("#rpc_pass").attr("value");
  186. // var patrn=/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi;
  187. // if(patrn.exec(str)){
  188. // $("#setting_divtopmsg").html("用户名/密码不能有中文的喔");
  189. // }
  190. // else{
  191.  
  192. // }
  193. config.save(config.get_table());
  194. $("#setting_divtopmsg").html("\u8bbe\u7f6e\u5df2\u4fdd\u5b58\u3002");
  195. Initialize();
  196. })
  197. $("#send_test").click(function(){
  198. if($(this).attr("type")==0){
  199. aria2send_data.getVersion();
  200. $(this).html("\u8bf7\u7a0d\u540e\u002e\u002e\u002e");
  201. $(this).attr({"type":1});
  202. }
  203. })
  204. $("#setting_div_close").click(function(){
  205. $("#setting_div").css("display", "none");
  206. $("#masking").css("display","none");
  207. })
  208. $("#referer_auto").click(function(){
  209. if($(this).attr("checked")){
  210. $("#setting_aria2_referer_input").attr("disabled", "disabled");
  211. }
  212. else{
  213. $("#setting_aria2_referer_input").removeAttr("disabled");
  214. }
  215. })
  216. $('#yingyong').hover(function(){
  217. $(this).css({"background-color":"#3482DA", "color":"#FFF"});
  218. },function(){
  219. $(this).css({"background-color":"#F7F7F7", "color":"#1B83EB"});
  220. })
  221. $('#setting_aria2_useragent a').hover(function(){
  222. $(this).css({"background-color":"#3482DA", "color":"#FFF"});
  223. },function(){
  224. $(this).css({"background-color":"#F7F7F7", "color":"#1B83EB"});
  225. })
  226. //$("#down_dir").attr({"value":"留空使用默认路径"})
  227. $('#setting_div input:text').focus(function(){
  228. $(this).css({"border":"1px solid #BBD4EF","box-shadow":"0 0 3px #BBD4EF", "-webkit-box-shadow":"0 0 3px #BBD4EF"});
  229. }).blur(function(){
  230. $(this).css({"border":"1px solid #C6C6C6", "box-shadow":"0 0 3px #C6C6C6", "-webkit-box-shadow":"0 0 3px #C6C6C6"});
  231. }).hover(function(){
  232. $(this).select();
  233. })
  234.  
  235. }
  236.  
  237. add_setting_div = function () {
  238. var setting_div = document.createElement("div");
  239. setting_div.className = "b-panel b-dialog download-mgr-dialog";
  240. setting_div.id = "setting_div";
  241. var html_ = [];
  242. html_.push('<div class="dlg-hd b-rlv"><div title="\u5173\u95ed" id="setting_div_close" class="dlg-cnr dlg-cnr-r"></div><h3>\u5bfc\u51fa\u8bbe\u7f6e</h3></div></div>');
  243. html_.push('<div style="height:420px;">');
  244. html_.push('<div id="setting_div_more_settings_but" style="width:60px; border:1px solid #F0F0F0; background-color: #FAFAFA; margin-top: -19px; margin-right: 15px; float:right; text-align:center;"><a href="javascript:;">更多设置</a></div>');
  245. html_.push('<div style="margin-left: 15px; margin-right: 15px; margin-top: 25px; margin-bottom: 5px;">');
  246. html_.push('<div id="setting_divtopmsg" style="position:absolute; margin-top: -20px; margin-left: 10px; color: #E15F00;"></div>');
  247. html_.push('<div style="border:1px solid rgb(240, 240, 240); background-color: rgb(250, 250, 250);">');
  248. html_.push('<div id="setting_div_table">');
  249. html_.push('<table id="setting_div_table_1" width="100%" border="0" style="border-collapse:separate; border-spacing:10px; display:table;">');
  250. html_.push('<tr>');
  251. html_.push('<td width="150"><label for="textfield">ARIA2 RPC\uff1a\u0020</label></td>');
  252. html_.push('<td width="320"><input id="rpc_input" type="text" style="width:90%; border: 1px solid #C6C6C6; box-shadow: 0 0 3px #C6C6C6; -webkit-box-shadow: 0 0 3px #C6C6C6;"/></td>');
  253. html_.push('</tr><tr>');
  254. html_.push('<td><label for="textfield">RPC\u8bbf\u95ee\u8bbe\u7f6e</label></td>');
  255. html_.push('<td><input id="rpc_distinguish" type="checkbox"/></td>');
  256. html_.push('</tr><tr>');
  257. html_.push('<td><label for="textfield">RPC \u7528\u6237\u540d\uff1a\u0020</label></td>');
  258. html_.push('<td><input type="text" id="rpc_user" disabled="disabled" style="width:150px; border: 1px solid #C6C6C6; box-shadow: 0 0 3px #C6C6C6; -webkit-box-shadow: 0 0 3px #C6C6C6;"/></td>');
  259. html_.push('</tr><tr>');
  260. html_.push('<td><label for="textfield">RPC \u5bc6\u7801\uff1a\u0020</label></td>');
  261. html_.push('<td><input type="text" id="rpc_pass" disabled="disabled" style="width:150px; border: 1px solid #C6C6C6; box-shadow: 0 0 3px #C6C6C6; -webkit-box-shadow: 0 0 3px #C6C6C6;"/>');
  262. html_.push('<div style="position:absolute; margin-top: -20px; right: 20px;"><a id="send_test" type=0 href="javascript:;" style="display:inline-block; border:1px solid #D1D1D1; background-color: #F7F7F7; text-align: center; text-decoration: none; color:#1B83EB;">\u6d4b\u8bd5\u8fde\u63a5\uff0c\u6210\u529f\u663e\u793a\u7248\u672c\u53f7\u3002</a></div></td>');
  263. html_.push('</tr><tr>');
  264. html_.push('<td colspan="2"><div style="color: #656565;">\u76f8\u5173\u8bbe\u7f6e</div><li class="b-list-item separator-1"></li></td>');
  265. html_.push('</tr><tr>');
  266. html_.push('<td>\u4e0b\u8f7d\u76ee\u5f55\uff1a\u0020</td><td><input id="down_dir" type="text" style="width:280px; border: 1px solid #C6C6C6; box-shadow: 0 0 3px #C6C6C6; -webkit-box-shadow: 0 0 3px #C6C6C6;"/></td>');
  267. html_.push('</tr><tr>');
  268. html_.push('<td>\u6839\u636e\u7f51\u76d8\u8def\u5f84\u5b58\u653e\u6587\u4ef6</td><td><input id="web_path_save" type="checkbox"/></td>');
  269. html_.push('</tr><tr>');
  270. html_.push('<!-- <td>增加115网盘支持</td><td><input id="add_115" type="checkbox" style="vertical-align:text-bottom;"/>(现在只有一个导出按钮,还没有设置面板,设置项通用。)</td> -->');
  271. html_.push('<td>\u5bf9\u6587\u4ef6\u5939\u4f7f\u7528\u007a\u0069\u0070\u4e0b\u8f7d</td><td><input id="dirzip" type="checkbox" style="vertical-align:text-bottom;"/>\u0028\u53ea\u5bf9\u5206\u4eab\u94fe\u63a5\u6709\u6548\u3002\u0029</td>');
  272. html_.push('</tr><tr>');
  273. html_.push('<td>\u4f7f\u7528\u8fdc\u7a0b\u7684\u004a\u0053\u811a\u672c</td><td><input id="iswebjs" type="checkbox" style="vertical-align:text-bottom;"/>\u0028\u597d\u5904\u662f\u80fd\u591f\u4fdd\u6301\u6700\u65b0\u7684\u72b6\u6001\u3002\u0029</td>');
  274. html_.push('</tr><tr>');
  275. html_.push('<td colspan="2"><div style="color: #656565;">\u5bfc\u51fa\u7c7b\u578b\u8bbe\u7f6e</div><li class="b-list-item separator-1"></li></td>');
  276. html_.push('</tr><tr>');
  277. html_.push('<td colspan="2" id="typeout">');
  278. html_.push('<div style="width:80px; float:left; margin-left:30px;"><input id="aria2rpc_checkbox" type="checkbox" disabled="disabled" checked="checked" style="vertical-align:text-bottom;"/><label for="textfield">ARIA2 RPC</label></div>');
  279. html_.push('<div style="width:70px; float:left; margin-left:50px;"><input id="aria2_checkbox" type="checkbox" style="vertical-align:text-bottom;"/><label for="textfield">ARIA2</label></div>');
  280. html_.push('<div style="width:70px; float:left; margin-left:50px;"><input id="wget_checkbox" type="checkbox" style="vertical-align:text-bottom;"/><label for="textfield">WGET</label></div>');
  281. html_.push('<div style="width:70px; float:left; margin-left:50px;"><input id="idm_checkbox" type="checkbox" style="vertical-align:text-bottom;"/><label for="textfield">IDM</label></div>');
  282. html_.push('</td></tr><tr>');
  283. html_.push('</table>');
  284. html_.push('<table id="setting_div_table_2" width="100%" border="0" style="border-collapse:separate; border-spacing:10px; display:none;">');
  285. html_.push('<tr>');
  286. html_.push('<td width="50"><label for="textfield"></label></td>');
  287. html_.push('<td width="320"><label for="textfield"></label></td>');
  288. html_.push('</tr><tr>');
  289. html_.push('<td colspan="2"><div style="color: #656565;">User-Agent</div><li class="b-list-item separator-1"></li></td>');
  290. html_.push('</tr><tr>');
  291. html_.push('<td colspan="2" id="setting_aria2_useragent">');
  292. html_.push('<a href="javascript:;" onclick=\'javascript:headers_.set_UA("chrome");\'><b>Chrome</b></a>');
  293. html_.push('<a href="javascript:;" onclick=\'javascript:headers_.set_UA("firefox");\'><b>Firefox</b></a>');
  294. html_.push('<a href="javascript:;" onclick=\'javascript:headers_.set_UA("exe");\'>云管家</a>');
  295. html_.push('<a href="javascript:;" onclick=\'javascript:document.getElementById("setting_aria2_useragent_input").removeAttribute("disabled");\'>自定义</a>');
  296. html_.push('</td>')
  297. html_.push('</tr><tr>');
  298. html_.push('<td><label for="textfield">User-Agent :</label></td>');
  299. html_.push('<td><input type="text" id="setting_aria2_useragent_input" disabled="disabled" style="width:90%; border: 1px solid #C6C6C6; box-shadow: 0 0 3px #C6C6C6; -webkit-box-shadow: 0 0 3px #C6C6C6;"/></td>');
  300. html_.push('</tr><tr>');
  301. html_.push('<td colspan="2"><div style="color: #656565;">Referer</div><li class="b-list-item separator-1"></li></td>');
  302. html_.push('</tr><tr>');
  303. html_.push('<td><label for="textfield">Referer\u0020\uff1a\u0020</label></td>');
  304. html_.push('<td><input type="text" id="setting_aria2_referer_input" style="width:90%; border: 1px solid #C6C6C6; box-shadow: 0 0 3px #C6C6C6; -webkit-box-shadow: 0 0 3px #C6C6C6;"/></td>');
  305. html_.push('</tr><tr>');
  306. html_.push('<td><label for="textfield">自动设置</label></td>');
  307. html_.push('<td><input id=referer_auto type="checkbox"/></td>');
  308. html_.push('</tr><tr>');
  309. html_.push('<td colspan="2"><div style="color: #656565;">Headers<label for="textfield" style="margin-left: 35px;">※使用回车分隔每个headers。</label></div><li class="b-list-item separator-1"></li></td>');
  310. html_.push('</tr><tr>');
  311. html_.push('<td><label for="textfield">headers\u0020\uff1a\u0020</label></td>');
  312. html_.push('<td><textarea id="setting_aria2_headers" style="overflow:auto; resize:none; width:90%; height:80px; border: 1px solid #C6C6C6; box-shadow: 0 0 3px #C6C6C6; -webkit-box-shadow: 0 0 3px #C6C6C6;"></textarea></td>');
  313. html_.push('</tr>');
  314. html_.push('</table>');
  315. html_.push('</div>');
  316. html_.push('</div>');
  317. html_.push('<div style="margin-top:10px;">');
  318. html_.push('<div style="float:left; margin-top:25px; color: #656565">\u811a\u672c\u7248\u672c\uff1a'+version+'\u0020\u66f4\u65b0\u4e8e\uff1a'+thedate_update+'<a href="http://baiducloudwebplug.duapp.com/" style="margin-left: 10px" target="_blank">\u53bb\u770b\u770b\u6709\u6ca1\u6709\u66f4\u65b0\uff1f</a></div>');
  319. html_.push('<div style="margin-left:77.5%;"><a href="javascript:;" id="yingyong" style="display:inline-block; width:120px; height:30px; border:1px solid #D1D1D1; background-color: #F7F7F7; text-align: center; text-decoration: none; padding-top:7px; color:#1B83EB;"><b>\u5e94\u7528</b></a></div>');
  320. html_.push('</div></div></div>');
  321.  
  322. setting_div.innerHTML = html_.join("");
  323. document.body.appendChild(setting_div);
  324. $("#setting_div").css({"border": "1px solid #999"});
  325. event(); //绑定事件
  326. center($("#setting_div")); //窗口绑定居中
  327. //设定useragent和referer默认值
  328. document.getElementById("setting_aria2_useragent_input").value = "netdisk;4.4.0.6;PC;PC-Windows;6.2.9200;WindowsBaiduYunGuanJia";
  329. document.getElementById("setting_aria2_referer_input").value = "http://pan.baidu.com/disk/home";
  330. function setcss() {
  331. var css_useragent = {
  332. "margin-left": "15px",
  333. "display": "inline-block",
  334. "color": "#1B83EB",
  335. "border": "1px solid #DCE1E6",
  336. "background-color": "#F7F7F7",
  337. "text-align": "center",
  338. "text-decoration": "none",
  339. "padding": "0px 5px"
  340. }
  341. $('#setting_aria2_useragent a').css(css_useragent);
  342. }
  343. setcss();
  344. }
  345.  
  346. masking = function () {
  347. var div = document.createElement("div");
  348. div.id = "masking";
  349. div.style.left = "0px";
  350. div.style.top = "0px";
  351. div.style.width = $(window).width() + "px";
  352. div.style.height = $(window).height() + "px";
  353. div.style.display = "none";
  354. div.style.zIndex = 890;
  355. div.style.opacity = 0.1;
  356. div.style.position = "absolute";
  357. document.body.appendChild(div);
  358.  
  359. var obj = $("#masking");
  360. obj.css({"background-color": "#000", "-moz-opacit": 0.1});
  361. $(window).resize(function() {
  362. obj.width($(window).width() + "px");
  363. obj.height($(window).height() + "px");
  364. });
  365. }
  366.  
  367. center = function (obj) {
  368. var screenWidth = $(window).width(), screenHeight = $(window).height();
  369. var scrolltop = $(document).scrollTop();
  370.  
  371. var objLeft = (screenWidth - obj.width())/2 ;
  372. var objTop = (screenHeight - obj.height())/2 + scrolltop;
  373.  
  374. obj.css({left: objLeft + 'px', top: objTop + 'px'});
  375. //浏览器窗口大小改变时
  376. $(window).resize(function() {
  377. screenWidth = $(window).width();
  378. screenHeight = $(window).height();
  379. scrolltop = $(document).scrollTop();
  380.  
  381. objLeft = (screenWidth - obj.width())/2 ;
  382. objTop = (screenHeight - obj.height())/2 + scrolltop;
  383.  
  384. obj.css({left: objLeft + 'px', top: objTop + 'px'});
  385.  
  386. });
  387. //浏览器滚动条滚动时
  388. $(window).scroll(function() {
  389. screenWidth = $(window).width();
  390. screenHeight = $(widow).height();
  391. scrolltop = $(document).scrollTop();
  392.  
  393. objLeft = (screenWidth - obj.width())/2 ;
  394. objTop = (screenHeight - obj.height())/2 + scrolltop;
  395.  
  396. obj.css({left: objLeft + 'px', top: objTop + 'px'});
  397. });
  398.  
  399. }
  400.  
  401. button = function () {
  402. var ul = [];//创建下拉列表
  403. ul.push('<ul id="outlist_ul" style="display:none; position:absolute; text-align: center; border:#CFCFCF 1px solid; box-shadow: 0 2px 3px #CFCFCF; -webkit-box-shadow: 0 2px 3px #CFCFCF; line-height: 24px; text-decoration: none; z-index:100; background-color: #FFF">');
  404. ul.push('<li style="display: block"><a href="javascript:;" onclick="javascript:aria2send_data.getGlobalOption();" id="out_rpc">ARIA2 RPC</a></li>');
  405. ul.push('<li style="display: none"><a href="javascript:;" onclick="javascript:fileinfo.out_type=\'aria2\';fileinfo.getinfo();" id="out_aria2">ARIA2</a></li>');
  406. ul.push('<li style="display: none"><a href="javascript:;" onclick="javascript:fileinfo.out_type=\'wget\';fileinfo.getinfo();" id="out_wget">WGET</a></li>');
  407. ul.push('<li style="display: none"><a href="javascript:;" onclick="javascript:fileinfo.out_type=\'idm\';fileinfo.getinfo();" id="out_idm">IDM</a></li>');
  408. ul.push('<li style="display: block"><a href="javascript:;" id="setting">\u8bbe\u7f6e</a></li>');
  409. ul.push('</ul>');
  410.  
  411. if (FileUtils.share_uk){
  412. //创建分享链接的导出按钮
  413. var A = document.createElement("a");
  414. A.className = "new-dbtn";
  415. A.id = "outlist";
  416. A.setAttribute("hideFocus","true");
  417. A.style.cssText = "width:50px;";
  418. A.innerHTML = '<em class="icon-download"></em><b>\u5bfc\u51fa</b>' + ul.join("");
  419. $('span a[class="new-dbtn"]').parent().prepend(A);
  420. }else{
  421. //创建导出按钮
  422. var li = document.createElement("li");
  423. li.className = "b-list-item";
  424. li.id = "outlist"
  425. li.innerHTML = '<a class="bbtn" id="aaa" style="width:47px;"><em class="icon-download"></em><b>\u5bfc\u51fa</b></a>';
  426. $('ul[class="b-list-2 bar-cmd-list"]').append(li);
  427. $("#aaa").append(ul.join(""));
  428. }
  429.  
  430. //修改下拉列表样式
  431. var W = ($('#outlist').innerWidth() - 2) +'px'; //2=左右两边边框
  432. if (! FileUtils.share_uk){W = ($('#outlist').width() - 2) +'px';}
  433. $('#outlist_ul').css({'left':'0px', 'width':W, 'margin-top':'-1px'});
  434. $('#outlist_ul a').css({'color':'#666', 'display':'inline-block', 'width':'100%', 'height':'100%'});
  435.  
  436. //绑定点击事件
  437. //下拉列表事件//
  438. $("#outlist_ul li").hover(function(){
  439. $(this).css("background","#E4EEFE");},
  440. function(){
  441. $(this).css("background","#FFFFFF");
  442. });
  443. $("#outlist").hover(function(){
  444. $("#outlist_ul").css("display","block");},
  445. function(){
  446. $("#outlist_ul").css("display","none");
  447. });
  448. //按钮事件//
  449. $("#setting").click(function(){
  450. $("#masking").css("display","block");
  451. $("#setting_divtopmsg").html(null);
  452. $("#setting_div").css("display","block");
  453. Initialize();
  454. })
  455. /*$("#rpc").click(function(){
  456. fileinfo.getinfo();
  457. })*/
  458. }
  459.  
  460. config = {
  461. // baidu + cloud + out + file + list = bcofl_v2
  462. "get_table": function(){
  463. var _ = [{"input":{},"checked":{}}];
  464. var bcofl_checkbox = $("#setting_div input[type=checkbox]");
  465. var bcofl_text = $("#setting_div input[type=text]");
  466. var bcofl_textarea = document.getElementById("setting_aria2_headers");
  467. for (var i=0;i<bcofl_checkbox.length;i++){
  468. _[0].checked[$(bcofl_checkbox[i]).attr("id")] = $(bcofl_checkbox[i]).attr("checked");
  469. }
  470. for (var i=0;i<bcofl_text.length;i++){
  471. _[0].input[$(bcofl_text[i]).attr("id")] = $(bcofl_text[i]).attr("value");
  472. }
  473. if(bcofl_textarea.value){
  474. _[0].textarea = bcofl_textarea.value;
  475. }
  476. return _
  477. },
  478. "save": function(data){
  479. //var base64_data = window.btoa(JSON.stringify(data));
  480. var name = "iswebjs";
  481. var Days = 365;
  482. var exp = new Date();
  483. exp.setTime(exp.getTime() + Days*24*60*60*1000);
  484. for (var i in data[0].checked){
  485. if(i=="iswebjs"){
  486. if (data[0].checked.iswebjs){
  487. document.cookie = name + "="+ "1" + ";expires=" +exp.toGMTString()+";path=/;";
  488. }
  489. else{
  490. document.cookie = name + "="+ "0" + ";expires=" +exp.toGMTString()+";path=/;";
  491. }
  492. delete data[0].checked[i];
  493. }
  494. }
  495. var base64_data = window.btoa(encodeURIComponent(JSON.stringify(data)));
  496. name = "bcofl_v2";
  497. document.cookie = name + "="+ base64_data + ";expires=" +exp.toGMTString()+";path=/;";
  498. },
  499. "get": function(){
  500. var name = "bcofl_v2";
  501. var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  502. if(arr != null){
  503. var base64_data = window.atob(arr[2]);
  504. config.params = JSON.parse(decodeURIComponent(base64_data));
  505. // config.params = JSON.parse(decodeURIComponent(base64_data).replace(/&quot;/g, '"').replace(/&#x2F;/g, '/'));
  506. // config.params = new Array(JSON.parse(decodeURIComponent(base64_data)));
  507. return config.params;
  508. }else{
  509. return null;
  510. }
  511. },
  512. "params": []
  513. }
  514.  
  515. aria2send_data = {
  516. "getGlobalOption": function(){
  517. var parameter = {
  518. "jsonrpc": "2.0",
  519. ///"method": "aria2.getOption",
  520. "id": 1,
  521. "method": "aria2.getGlobalOption",
  522. "params": []
  523. };
  524. var _ = {
  525. type: 'POST',
  526. url: config.params[0].input.rpc_input + "?tm="+(new Date().getTime().toString()),
  527. data: JSON.stringify(parameter),
  528. dataType: "JSON",
  529. success: function(data){
  530. fileinfo.out_type = "aria2_rpc";
  531. fileinfo.getinfo();
  532. },
  533. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  534. error: function(httpstate){
  535. fileinfo.out_type = "aria2_rpc";
  536. fileinfo.getinfo();
  537. SetMessage("\u5148\u786e\u4fdd\u4e0e\u0041\u0072\u0069\u0061\u0032\u0052\u0050\u0043\u80fd\u591f\u6b63\u5e38\u901a\u4fe1\u540e\u5728\u4f7f\u7528\u5594\u3002", disk.ui.Toast.MODE_CAUTION);
  538. }
  539. };
  540. if(config.params[0].checked.rpc_distinguish){
  541. _.headers = {"Authorization": "Basic "+ btoa(config.params[0].input.rpc_user + ":" + config.params[0].input.rpc_pass)};
  542. }
  543. HttpSendRead(_);
  544. },
  545. "getVersion": function(){
  546. var parameter = [{
  547. "jsonrpc": "2.0",
  548. "method": "aria2.getVersion",
  549. "id": 1
  550. }];
  551. var _ = {
  552. type: 'POST',
  553. url: $("#rpc_input").attr("value") + "?tm="+(new Date().getTime().toString()),
  554. data: JSON.stringify(parameter),
  555. dataType: "JSON",
  556. success: function(jsondata){
  557. $("#send_test").attr("type", 0);
  558. $("#send_test").html("ARIA2\u7248\u672c\u4e3a\uff1a\u0020"+jsondata[0].result.version);
  559. },
  560. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  561. error: function(httpstate){
  562. $("#send_test").attr("type", 0);
  563. $("#send_test").html(httpstate+"\u9519\u8BEF\uFF0C\u70B9\u51FB\u91CD\u65B0\u6D4B\u8BD5");
  564. }
  565. };
  566. if($("#rpc_distinguish").attr("checked")){
  567. _.headers = {"Authorization": "Basic "+ btoa($("#rpc_user").attr("value") + ":" + $("#rpc_pass").attr("value"))};
  568. }
  569. HttpSendRead(_);
  570. },
  571. "addUri": function(obj){
  572. var _ = {
  573. type: 'POST',
  574. url: config.params[0].input.rpc_input + "?tm="+(new Date().getTime().toString()),
  575. data: JSON.stringify(obj),
  576. dataType: "JSON",
  577. success: function(data){},
  578. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  579. error: function(httpstate){}
  580. };
  581. if(config.params[0].checked.rpc_distinguish){
  582. _.headers = {"Authorization": "Basic "+ btoa(config.params[0].input.rpc_user + ":" + config.params[0].input.rpc_pass)};
  583. }
  584. HttpSendRead(_);
  585. }
  586. }
  587.  
  588. fileinfo = {
  589.  
  590. "info": [],
  591. "vcode": {},
  592. "data": [],
  593. "isdir": 0,
  594. "file_fsid": [],
  595. "filelist": [],
  596. "dir_fsid": [],
  597. "dir_savename": "",
  598. "savename": "",
  599. "out_type": "",
  600. "share_path": "",
  601. "ajax_state": 0,
  602. "temp": "",
  603.  
  604.  
  605. "ajaxsuccess": function (indata){
  606. var data = indata;
  607. if(data["errno"] == 0){
  608. if(data["list"]){
  609. for(var i=0;i<fileinfo.info.length;i++){
  610. if(fileinfo.info[i]["isdir"]==0){
  611. fileinfo.savename = fileinfo.info[i]["server_filename"];
  612. if(config.params[0].checked.web_path_save){ //判断是否根据网盘路径保存文件
  613. fileinfo.savename = config.params[0].input.down_dir + fileinfo.share_path + "/" + fileinfo.info[i]["server_filename"];
  614. }
  615. var obj_data = combination[fileinfo.out_type](data.list[fileinfo.info[i]["fs_id"]], fileinfo.savename);
  616. fileinfo.data.push(obj_data);
  617. }
  618. }
  619. //清空已经处理的
  620. fileinfo.file_fsid.splice(0,fileinfo.file_fsid.length);
  621. fileinfo.info.splice(0,fileinfo.info.length);
  622.  
  623. if (fileinfo.dir_fsid.length != 0){ //处理文件夹的下载
  624. var _ = "fid_list="+JSON.stringify(fileinfo.dir_fsid);
  625. fileinfo.isdir = 1;
  626. fileinfo.getdinlk(_);
  627. }
  628. else {
  629. var _ = "data:application/octet-stream;charset=utf-8,"+ encodeURIComponent(fileinfo.data.join(""));
  630. if(fileinfo.out_type == "wget"){
  631. down_dialog(fileinfo.out_type, _, fileinfo.data.join(""));
  632. $("#masking").css("display","block");
  633. SetMessage("\u5b8c\u6210\u54af\u007e\u007e\u007e", disk.ui.Toast.MODE_SUCCESS);
  634. fileinfo.ajax_state = 0;
  635. }
  636. else if(fileinfo.out_type == "aria2_rpc"){
  637. for(var i=0;i<fileinfo.data.length;i++){
  638. aria2send_data.addUri(fileinfo.data[i]);
  639. }
  640. SetMessage("\u5df2\u7ecf\u6dfb\u52a0\u4e86\u5594\uff0c\u53bb\u786e\u8ba4\u770b\u4e0b\u5427\u3002", disk.ui.Toast.MODE_SUCCESS);
  641. fileinfo.ajax_state = 0; //吧状态值恢复成0
  642. }
  643. else{
  644. down_dialog(fileinfo.out_type, _, "");
  645. $("#masking").css("display","block");
  646. SetMessage("\u5b8c\u6210\u54af\u007e\u007e\u007e", disk.ui.Toast.MODE_SUCCESS);
  647. fileinfo.ajax_state = 0;
  648. }
  649. }
  650. }
  651. else if(data["dlink"]){
  652. fileinfo.savename = fileinfo.info["server_filename"];
  653. if (config.params[0].checked.web_path_save){ //判断是否根据网盘路径保存文件
  654. fileinfo.savename = config.params[0].input.down_dir + "/" + fileinfo.info["path"];
  655. }
  656. if(fileinfo.isdir==1){//判断是否是文件夹的下载
  657. fileinfo.savename = "【打包下载】"+fileinfo.dir_savename+"_等.zip";
  658. fileinfo.dir_fsid.splice(0,fileinfo.dir_fsid.length);//清空已经处理的
  659. }
  660. var obj_data = combination[fileinfo.out_type](data["dlink"], fileinfo.savename)
  661. fileinfo.data.push(obj_data);
  662. //清空已经处理的
  663. fileinfo.info.splice(0,fileinfo.info.length);
  664. fileinfo.file_fsid.splice(0,fileinfo.file_fsid.length);
  665.  
  666. if (fileinfo.dir_fsid.length != 0){ //文件夹的下载放这里是为了最后在处理它
  667. var _ = "fid_list="+JSON.stringify(fileinfo.dir_fsid);
  668. fileinfo.isdir = 1;
  669. fileinfo.getdinlk(_);
  670. }
  671. else {
  672. var _ = "data:application/octet-stream;charset=utf-8,"+ encodeURIComponent(fileinfo.data.join(""));
  673. if(fileinfo.out_type == "wget"){
  674. down_dialog(fileinfo.out_type, _, fileinfo.data.join(""));
  675. $("#masking").css("display","block");
  676. SetMessage("\u5b8c\u6210\u54af\u007e\u007e\u007e", disk.ui.Toast.MODE_SUCCESS);
  677. fileinfo.ajax_state = 0; //吧状态值恢复成0
  678. }
  679. else if(fileinfo.out_type == "aria2_rpc"){
  680. for(var i=0;i<fileinfo.data.length;i++){
  681. aria2send_data.addUri(fileinfo.data[i]);
  682. }
  683. SetMessage("\u5df2\u7ecf\u6dfb\u52a0\u4e86\u5594\uff0c\u53bb\u786e\u8ba4\u770b\u4e0b\u5427\u3002", disk.ui.Toast.MODE_SUCCESS);
  684. fileinfo.ajax_state = 0;
  685. }
  686. else{
  687. down_dialog(fileinfo.out_type, _, "");
  688. $("#masking").css("display","block");
  689. SetMessage("\u5b8c\u6210\u54af\u007e\u007e\u007e", disk.ui.Toast.MODE_SUCCESS);
  690. fileinfo.ajax_state = 0;
  691. }
  692. }
  693. }
  694. }
  695. else if(data["errno"] == -19){//要求输入验证码
  696. fileinfo.vcode = data["vcode"];
  697. alert_dialog.create();
  698. alert_dialog.img(fileinfo.vcode);
  699. alert_dialog.event();
  700. }
  701. else{
  702. SetMessage("\u5728\u83b7\u53d6\u6587\u4ef6\u5730\u5740\u7684\u65f6\u5019\u5931\u8d25\u4e86\u3002\u3002\u3002\u3002", disk.ui.Toast.MODE_CAUTION);
  703. fileinfo.ajax_state = 0;
  704. }
  705. },
  706. "getdinlk": function (data) {
  707. var uk = FileUtils.share_uk;
  708. var id = FileUtils.share_id;
  709. Utilities.useToast({
  710. toastMode: disk.ui.Toast.MODE_LOADING,
  711. msg: "\u52aa\u529b\u52a0\u8f7d\u4e2d\u002e\u002e\u002e\u002e",
  712. sticky: true
  713. });
  714. var download = "http://"+window.location.host+"/share/download?channel=chunlei&clienttype=0&web=1"+"&uk="+uk+"&shareid="+id+"&timestamp="+FileUtils.share_timestamp+"&sign="+FileUtils.share_sign+"&bdstoken="+FileUtils.bdstoken;
  715. if( fileinfo.isdir == 0 ){ download = download+"&nozip=1"; }
  716. var url = download;
  717. var _ = {
  718. type: 'POST',
  719. url: url,
  720. data: data,
  721. dataType: "JSON",
  722. success: function(data){
  723. fileinfo.ajaxsuccess(data);
  724. },
  725. error: function(httpstate){
  726. SetMessage("\u5728\u83b7\u53d6\u6587\u4ef6\u4fe1\u606f\u7684\u65f6\u5019\u5931\u8d25\u4e86\u3002\u3002", disk.ui.Toast.MODE_CAUTION);
  727. fileinfo.ajax_state = 0;
  728. }
  729. };
  730. HttpSendRead(_);
  731. },
  732. "dtcount": function(temp){
  733. fileinfo.temp = temp;
  734. var uk = FileUtils.share_uk;
  735. var id = FileUtils.share_id;
  736. var dtcount = "http://"+window.location.host+"/mis/dtcount?channel=chunlei&clienttype=0&web=1&bdstoken="+FileUtils.bdstoken;
  737. var F = new FormData();
  738. /*F.append("uk", uk);
  739. F.append("filelist", JSON.stringify(fileinfo.filelist));
  740. F.append("sid", id);
  741. F.append("ctim", FileUtils.share_timestamp);
  742. F.append("public", 1);*/
  743. var dtcountData = "uk="+uk+"&filelist="+JSON.stringify(fileinfo.filelist)+"&sid="+id+"&ctime="+FileUtils.share_timestamp+"&public=1";
  744. var _ = {
  745. type: 'POST',
  746. url: dtcount,
  747. data: dtcountData,
  748. dataType: "JSON",
  749. success: function(data){
  750. //fileinfo.ajaxsuccess(data);
  751. if ( data.errno == 0 ) {
  752. fileinfo.getdinlk(fileinfo.temp);
  753. }
  754. else if ( data.errno != 0 ) {
  755. SetMessage("获取下载地址失败,(" + data.errno + ")", disk.ui.Toast.MODE_CAUTION);
  756. }
  757. },
  758. error: function(httpstate){
  759. SetMessage("\u5728\u83b7\u53d6\u6587\u4ef6\u4fe1\u606f\u7684\u65f6\u5019\u5931\u8d25\u4e86\u3002\u3002", disk.ui.Toast.MODE_CAUTION);
  760. fileinfo.ajax_state = 0;
  761. }
  762. };
  763. HttpSendRead(_);
  764. },
  765. "getinfo": function(){
  766. if(fileinfo.ajax_state != 0){return null} //判断状态值避免多次点击
  767. fileinfo.ajax_state = 1; //吧状态值设置成1避免多次点击
  768. if(FileUtils.share_uk){ //判断是否分享链接
  769. fileinfo.data.splice(0,fileinfo.data.length); //使用前先清空
  770. fileinfo.filelist.splice(0,fileinfo.filelist.length);
  771. fileinfo.dir_fsid.splice(0,fileinfo.dir_fsid.length);
  772. fileinfo.file_fsid.splice(0,fileinfo.file_fsid.length);
  773. if(disk.util.ViewShareUtils){ //判断是否多文件
  774. fileinfo.info.push(JSON.parse(disk.util.ViewShareUtils.viewShareData));
  775. fileinfo.file_fsid.push(fileinfo.info[0]["fs_id"]);
  776. fileinfo.isdir = 0;
  777. var _ = "fid_list="+JSON.stringify(fileinfo.file_fsid);
  778. //fileinfo.getdinlk(_)
  779. fileinfo.dtcount(_);
  780. }
  781. else if(FileUtils.getListViewCheckedItems()){
  782. fileinfo.info = FileUtils.getListViewCheckedItems();
  783. fileinfo.share_path = FileUtils._mFileFilter._mTag;
  784. if(fileinfo.info.length == 0){
  785. SetMessage("\u8bf7\u5148\u9009\u62e9\u0031\u4e2a\u4ee5\u4e0a\u7684\u6587\u4ef6",disk.ui.Toast.MODE_CAUTION);
  786. fileinfo.ajax_state = 0;
  787. return null
  788. }
  789. for(var i=0;i<fileinfo.info.length;i++){
  790. if (fileinfo.info[i].isdir == 1){ //判断是否选中文件夹
  791. if(config.params[0].checked.dirzip){ //判断是否下载文件夹
  792. fileinfo.dir_fsid.push(fileinfo.info[i]["fs_id"]);
  793. if(! fileinfo.dir_savename){
  794. fileinfo.dir_savename = fileinfo.info[i]["server_filename"]
  795. }
  796. }
  797. }else if(fileinfo.info[i].isdir == 0){
  798. var filelist = {
  799. "fid":fileinfo.info[i]["fs_id"],
  800. "category":fileinfo.info[i]["category"]
  801. };
  802. fileinfo.filelist.push(filelist);
  803. fileinfo.file_fsid.push(fileinfo.info[i]["fs_id"]);
  804. }
  805. }
  806.  
  807. if (fileinfo.file_fsid.length != 0){
  808. fileinfo.isdir = 0;
  809. var _ = "fid_list="+JSON.stringify(fileinfo.file_fsid);
  810. //fileinfo.getdinlk(_);
  811. fileinfo.dtcount(_);
  812. }
  813. else if(fileinfo.file_fsid.length == 0){
  814. if (fileinfo.dir_fsid.length != 0){
  815. var _ = "fid_list="+JSON.stringify(fileinfo.dir_fsid);
  816. fileinfo.isdir = 1;
  817. //fileinfo.getdinlk(_);
  818. fileinfo.dtcount(_);
  819. }
  820. }
  821. if (fileinfo.file_fsid.length == 0 && fileinfo.dir_fsid.length == 0){
  822. fileinfo.ajax_state = 0;
  823. }
  824. }
  825. }
  826. else {
  827. fileinfo.data.splice(0,fileinfo.data.length); //使用前先清空
  828. fileinfo.filelist.splice(0,fileinfo.filelist.length);
  829. fileinfo.dir_fsid.splice(0,fileinfo.dir_fsid.length);
  830. fileinfo.file_fsid.splice(0,fileinfo.file_fsid.length);
  831. fileinfo.info = FileUtils.getListViewCheckedItems();
  832. if(fileinfo.info.length == 0){
  833. SetMessage("\u8bf7\u5148\u9009\u62e9\u0031\u4e2a\u4ee5\u4e0a\u7684\u6587\u4ef6",disk.ui.Toast.MODE_CAUTION);
  834. fileinfo.ajax_state = 0; //吧状态值恢复成0
  835. return null
  836. }
  837. for(var i=0;i<fileinfo.info.length;i++){
  838. if (fileinfo.info[i].isdir == 0){
  839. fileinfo.savename = fileinfo.info[i]["server_filename"]
  840. if (config.params[0].checked.web_path_save){ //判断是否根据网盘路径保存文件
  841. fileinfo.savename = fileinfo.info[i]["path"];
  842. }
  843. var obj_data = combination[fileinfo.out_type](fileinfo.info[i].dlink, fileinfo.savename);
  844. fileinfo.data.push(obj_data);
  845. }
  846. }
  847.  
  848. if(fileinfo.data.length != 0){
  849. var _ = "data:application/octet-stream;charset=utf-8,"+ encodeURIComponent(fileinfo.data.join(""));
  850. if(fileinfo.out_type == "aria2_rpc"){
  851. for(var i=0;i<fileinfo.data.length;i++){
  852. aria2send_data.addUri(fileinfo.data[i]);
  853. }
  854. SetMessage("\u5df2\u7ecf\u6dfb\u52a0\u4e86\u5594\uff0c\u53bb\u786e\u8ba4\u770b\u4e0b\u5427\u3002", disk.ui.Toast.MODE_SUCCESS);
  855. fileinfo.ajax_state = 0;
  856. }
  857. else if(fileinfo.out_type == "wget"){
  858. down_dialog(fileinfo.out_type, _, fileinfo.data.join(""));
  859. $("#masking").css("display","block");
  860. fileinfo.ajax_state = 0;
  861. }
  862. else{
  863. down_dialog(fileinfo.out_type, _, "");
  864. $("#masking").css("display","block");
  865. fileinfo.ajax_state = 0;
  866. }
  867. }
  868. else{
  869. fileinfo.ajax_state = 0;
  870. }
  871. }
  872. }
  873. }
  874.  
  875. headers_ = {
  876. "UA": {
  877. "chrome": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.5 Safari/537.36",
  878. "firefox": "Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0",
  879. "exe": "netdisk;4.4.0.6;PC;PC-Windows;6.2.9200;WindowsBaiduYunGuanJia"
  880. },
  881. "set_UA": function (type) {
  882. var dom = document.getElementById("setting_aria2_useragent_input");
  883. dom.value = headers_.UA[type];
  884. dom.disabled = "disabled";
  885. return true;
  886. }
  887. }
  888.  
  889. alert_dialog = {
  890. "create": function(){
  891. var div = document.createElement("div");
  892. div.className = "b-panel b-dialog alert-dialog";
  893. div.id = "alert_div";
  894. var html = [];
  895. html.push('<div class="dlg-hd b-rlv">');
  896. html.push('<div title="\u5173\u95ed" id="alert_dialog_close" class="dlg-cnr dlg-cnr-r"></div>');
  897. html.push('<h3>\u9a8c\u8bc1\u7801</h3>');
  898. html.push('</div>');
  899. html.push('<div class="dlg-bd">');
  900. html.push('<div class="alert-dialog-msg center">');
  901.  
  902. html.push('<div class="download-verify" id="downloadVerify">');
  903. html.push('<div class="verify-body">\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801\uff1a\u0020');
  904. html.push('<input id="verification" type="text" class="input-code" maxlength="4">');
  905. html.push('<img id="yanzhengma" class="img-code" alt="\u9a8c\u8bc1\u7801\u83b7\u53d6\u4e2d" src="" width="100" height="30">');
  906. html.push('<a href="javascript:;" class="underline" id="huanyizhang">\u6362\u4e00\u5f20</a>');
  907. html.push('</div>');
  908. html.push('<div class="verify-error"></div></div>');
  909.  
  910. html.push('</div></div>');
  911. html.push('<div class="dlg-ft b-rlv">');
  912. html.push('<div class="alert-dialog-commands clearfix center">');
  913. html.push('<a href="javascript:;" id="okay" class="sbtn okay"><b>\u786e\u5b9a</b></a>');
  914. html.push('<a href="javascript:;" id="ignore" class="dbtn cancel"><b>\u53d6\u6d88</b></a>');
  915. html.push('</div>');
  916. html.push('<div class="clearfix alert-dialog-commands-plus" >');
  917. html.push('</div></div>');
  918. div.innerHTML= html.join("");
  919. document.body.appendChild(div);
  920.  
  921. //center($("#alert_div")); //提示窗口就用不着绑定了
  922.  
  923. var obj = $("#alert_div");
  924. var screenWidth = $(window).width(), screenHeight = $(window).height();
  925. var scrolltop = $(document).scrollTop();
  926. var objLeft = (screenWidth - obj.width())/2;
  927. var objTop = (screenHeight - obj.height())/2 + scrolltop;
  928.  
  929. $("#alert_div").css({left: objLeft + "px", top: objTop + "px"});
  930. $("#alert_div").css({"display": "block", "border": "1px solid #999"});
  931. $("#masking").css("display","block");
  932. },
  933. "img": function(vcode){
  934. var url = "http://vcode.baidu.com/genimage";
  935. $("#yanzhengma").attr("src", url+"?"+vcode);
  936. },
  937. "event": function(){
  938. $("#huanyizhang").unbind().click(function(){
  939. var url = "http://vcode.baidu.com/genimage";
  940. $("#yanzhengma").attr("src", url+"?"+fileinfo.vcode + "&" + new Date().getTime());
  941. })
  942. $("#okay").unbind().click(function(){
  943. var input_code = $("#verification").attr("value");
  944. var _ = "fid_list="+JSON.stringify(fileinfo.file_fsid);
  945. if(fileinfo.isdir==1){
  946. _ = "fid_list="+JSON.stringify(fileinfo.dir_fsid);
  947. }
  948. _ = _+"&input="+input_code+"&vcode="+fileinfo.vcode;
  949. fileinfo.getdinlk(_);
  950. //$("#alert_div").css({"display": "none"});
  951. $("#alert_div").remove();
  952. //SetMessage("请稍后...", disk.ui.Toast.MODE_LOADING)
  953. $("#masking").css("display","none");
  954. })
  955. $("#ignore").unbind().click(function(){
  956. //$("#alert_div").css({"display": "none"});
  957. $("#alert_div").remove();
  958. $("#masking").css("display","none");
  959. SetMessage("\u5509\u002e\u002e\u002e\u002e\u002e", disk.ui.Toast.MODE_CAUTION);
  960. fileinfo.ajax_state = 0;
  961. })
  962. $("#alert_dialog_close").unbind().click(function(){
  963. $("#alert_div").remove();
  964. $("#masking").css("display","none");
  965. SetMessage("\u5509\u002e\u002e\u002e\u002e\u002e", disk.ui.Toast.MODE_CAUTION);
  966. fileinfo.ajax_state = 0;
  967. })
  968. }
  969. }
  970.  
  971. down_dialog = function(type, href, str){
  972. var out = {
  973. "aria2": "aria2.session",
  974. "wget": "wget.txt",
  975. "idm": "idmlist.ef2"
  976. };
  977. var div = document.createElement("div");
  978. div.className = "b-panel b-dialog alert-dialog";
  979. div.id = "down_dialog";
  980. div.style.display = "block";
  981. div.style.border = "1px solid #999";
  982. var html = [];
  983. html.push('<div class="dlg-hd b-rlv">');
  984. html.push('<div title="\u5173\u95ed" id="down_dialog_close" class="dlg-cnr dlg-cnr-r"></div>');
  985. html.push('<h3>\u4e0b\u8f7d'+type+'\u6587\u4ef6</h3></div>');
  986. html.push('<div style="margin: 22px 180px;">');
  987. html.push('<a href='+href+' class="new-dbtn" download="'+out[type]+'"><em class="icon-download"></em><b>\u4e0b\u8f7d\u6587\u4ef6</b></a>');
  988. html.push('</div>');
  989. if(str.length != 0){
  990. html.push('<div style="width:425px;height:200px;margin: -13px auto 10px;border:1px solid rgb(240, 240, 240); background-color: rgb(250, 250, 250);overflow-y: auto;overflow-x: auto;">'+str+'</div>');
  991. }
  992. div.innerHTML= html.join("");
  993. document.body.appendChild(div);
  994. var obj = $("#down_dialog");
  995. var screenWidth = $(window).width(), screenHeight = $(window).height();
  996. var scrolltop = $(document).scrollTop();
  997. var objLeft = (screenWidth - obj.width())/2;
  998. var objTop = (screenHeight - obj.height())/2 + scrolltop;
  999. div.style.left = objLeft + "px";
  1000. div.style.top = objTop + "px";
  1001. $("#down_dialog_close").unbind().click(function(){
  1002. obj.remove();
  1003. $("#masking").css("display","none");
  1004. })
  1005. }
  1006.  
  1007. combination = {
  1008. "header": function () {
  1009. var addheader = [];
  1010. var ua_input = document.getElementById("setting_aria2_useragent_input").value;
  1011. var ref_input = document.getElementById("setting_aria2_referer_input").value;
  1012. var ua_cookie = config.params[0].input.setting_aria2_useragent_input;
  1013. var ref_cookie = config.params[0].input.setting_aria2_referer_input;
  1014. var h_cookie = config.params[0].textarea;
  1015. if( ua_input ){
  1016. addheader.push("User-Agent: " + ua_input);
  1017. }
  1018. else if( ua_cookie ){
  1019. addheader.push("User-Agent: " + ua_cookie);
  1020. }
  1021. if( config.params[0].checked.referer_auto ){
  1022. addheader.push("Referer: " + combination.referer());
  1023. }
  1024. else{
  1025. if( ref_input ){
  1026. addheader.push("Referer: " + ref_input);
  1027. }
  1028. else if( ref_cookie ){
  1029. addheader.push("Referer: " + ref_cookie);
  1030. }
  1031. }
  1032. if( h_cookie ){
  1033. var text = h_cookie.split("\n");
  1034. for (var i=0;i<text.length;i++){
  1035. addheader.push(text[i]);
  1036. }
  1037. }
  1038. return addheader;
  1039. },
  1040. "aria2_rpc": function(url, name) {
  1041. var _ = [{
  1042. "jsonrpc": "2.0",
  1043. "method": "aria2.addUri",
  1044. "id": new Date().getTime(),
  1045. //"id": 1,
  1046. "params": [[url],{
  1047. "out": name,
  1048. // "dir": dirurl
  1049. // "header": "user-agent: "+combination.user_agent,
  1050. // "header": "Referer: "+combination.referer()
  1051. "header": combination.header()
  1052. }
  1053. ]
  1054. }];
  1055. var file_path = name;
  1056. var file_name;
  1057. if(file_path.substring(0,1) == "/"){
  1058. _[0].params[1].out = file_path.substring(1, file_path.length);
  1059. }
  1060. return _
  1061. },
  1062. "aria2": function(url,name) {
  1063. var referer = location.origin+location.pathname;
  1064. if(! referer){referer="http://pan.baidu.com/disk/home";}
  1065. var file_path = name;
  1066. var _ = url+"\r\n";
  1067. if(file_path.substring(0,1) == "/"){
  1068. _ += " out=" + file_path.substring(1, file_path.length) + "\r\n";
  1069.  
  1070. }
  1071. else{
  1072. _ += " out=" + name + "\r\n";
  1073. }
  1074. _ += " header=" + "Referer: " + combination.referer() +"\r\n";
  1075. _ += " header=" + "User-Agent: " + combination.user_agent +"\r\n\r\n";
  1076. return _
  1077. },
  1078. "wget": function(url,name) {
  1079. var filter_txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1080. var _ = "wget -c -O ";
  1081. for (var i=0; i<name.length; i++) {
  1082. if (filter_txt.indexOf(name[i]) == -1) {
  1083. _ += "\\"+name[i];
  1084. }
  1085. else {
  1086. _ += name[i];
  1087. }
  1088. }
  1089. _ += " '"+url+"'"+"\r\n";
  1090. return _;
  1091. },
  1092. "idm": function(url,name) {
  1093. var _ = "<\r\n"+url+"\r\n>\r\n"
  1094. return _
  1095. },
  1096. "referer": function () {
  1097. var a = location.origin+location.pathname;
  1098. if(! a){a="http://pan.baidu.com/disk/home";}
  1099. return a
  1100. }
  1101. }
  1102.  
  1103. Initialize = function(){
  1104. if(config.get()){
  1105. var ua = document.getElementById("setting_aria2_useragent_input").value;
  1106. var ref = document.getElementById("setting_aria2_referer_input").value;
  1107. $("#setting_div input[type=checkbox]").attr("checked", false)
  1108. $("#setting_div input[type=text]").attr("value", null)
  1109. if( ! config.params[0].input.setting_aria2_useragent_input){document.getElementById("setting_aria2_useragent_input").value = ua;}
  1110. if( ! config.params[0].input.setting_aria2_referer_input){document.getElementById("setting_aria2_referer_input").value = ref;}
  1111. for (var i in config.params[0].input){$("#"+i).attr("value", config.params[0].input[i]);}
  1112. for(var i in config.params[0].checked){$("#"+i).attr("checked", config.params[0].checked[i]);}
  1113. if(config.params[0].textarea){document.getElementById("setting_aria2_headers").value = config.params[0].textarea;}
  1114. var typeout = $("#typeout input[type=checkbox]");
  1115. var id;
  1116. for (var i=0;i<typeout.length;i++){
  1117. if ($(typeout[i]).attr("checked")){
  1118. id = $(typeout[i]).attr("id").split("_")[0];
  1119. $("#out_"+id).parent().css("display","block")
  1120. }
  1121. else{
  1122. id = $(typeout[i]).attr("id").split("_")[0];
  1123. $("#out_"+id).parent().css("display","none")
  1124. }
  1125. }
  1126. if( ! $("#rpc_distinguish").attr("checked")){
  1127. $("#rpc_pass").attr("disabled", "disabled");
  1128. $("#rpc_user").attr("disabled", "disabled");
  1129. }
  1130. else{
  1131. $("#rpc_user").removeAttr("disabled");
  1132. $("#rpc_pass").removeAttr("disabled");
  1133. }
  1134. if($("#referer_auto").attr("checked")){
  1135. $("#setting_aria2_referer_input").attr("disabled", "disabled");
  1136. }
  1137. else{
  1138. $("#setting_aria2_referer_input").removeAttr("disabled");
  1139. }
  1140. var iswebjs = document.cookie.match(new RegExp("(^| )"+"iswebjs"+"=([^;]*)(;|$)"));
  1141. if (iswebjs){if (iswebjs.length > 1){iswebjs = iswebjs[2];}else{iswebjs = "0";}}else{iswebjs = "0";}
  1142. if (iswebjs == 1){$("#iswebjs").attr("checked", true);}
  1143. }
  1144. }
  1145.  
  1146. button();
  1147. add_setting_div();
  1148. Initialize();
  1149. masking();
  1150.  
  1151. }
  1152.  
  1153. localjs();
  1154. }
  1155. }
  1156. catch (type) {
  1157. window.setTimeout(function(){
  1158. Utilities.useToast({toastMode: disk.ui.Toast.MODE_CAUTION,msg: "\u6267\u884c\u811a\u672c\u65f6\u53d1\u751f\u9519\u8bef\uff0c\u5c1d\u8bd5\u4f7f\u7528\u8fdc\u7a0b\u811a\u672c\u3002",sticky: true});
  1159. window.setTimeout(loadjs,2000);
  1160. },2000);
  1161. }
  1162. }
  1163. }
  1164. A();
Add Comment
Please, Sign In to add comment