百度网盘分享(版本1)

百度网盘批量分享, 每个勾勾都生成一个分享链接, 可以自定义访问密码

  1. // ==UserScript==
  2. // @name 百度网盘分享(版本1)
  3. // @author 林岑影
  4. // @website http://www.cyxiaowu.com
  5. // @description 百度网盘批量分享, 每个勾勾都生成一个分享链接, 可以自定义访问密码
  6. // @namespace
  7. // @icon http://disk.yun.uc.cn/favicon.ico
  8. // @license GPL version 3
  9. // @encoding utf-8
  10. // @date 13/08/2015
  11. // @modified 08/12/2015
  12. // @include http://pan.baidu.com/disk/*
  13. // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
  14. // @grant unsafeWindow
  15. // @grant GM_setClipboard
  16. // @run-at document-end
  17. // @version 1.5.1
  18. // ==/UserScript==
  19.  
  20. (function(window){
  21. var baidushares = function(){
  22. this.pass = localStorage.getItem('qs_psss') || "8888"; //密码
  23. this.timeout = 10000; //间隔时间 (毫秒)
  24. this.linktype = localStorage.getItem('qs_linktype') || "link"; //输出链接格式: ubb = ubb代码 | link = 链接 | html = html代码
  25. this.index = 0;
  26. this.arrId = [];
  27. this.arrName = [];
  28. this.setTime = null;
  29. this.setSec = null;
  30. this.stbtn = '<a node-type="btn-quicksharest" data-key="quicksharest" class="icon-btn-download" style="display: inline-block;"><span class="ico"></span><span class="btn-val">分享设置</span></a>';
  31. this.btn = '<a node-type="btn-quickshare" data-key="quickshare" class="btn share-btn" style="display: inline-block;"><span class="ico"></span><span class="btn-val">快速分享</span></a>';
  32. };
  33. baidushares.prototype = {
  34. init: function(){
  35. var that = this;
  36. $(".module-list-toolbar").find('[data-key="download"]').after(that.btn);
  37. $(".module-toolbar").find('[node-type="btn-offline-download"]').after(that.stbtn);
  38. $(".module-toolbar").find('[data-key="quicksharest"]').on("click", function(){
  39. that.setting();
  40. });
  41. $(".module-list-toolbar").find('[data-key="quickshare"]').on("click", function(){
  42. if (that.setTime) {
  43. alert("当前有队列在分享中, 请等待完成后再试!");
  44. return false;
  45. }
  46. that.arrId = [];
  47. that.arrName = [];
  48. that.index = 0;
  49. var dom = $(".module-list-view").css("display") == "none" ? $(".module-grid-view") : $(".module-list-view");
  50. dom.find('[node-type="list"]').children(".item-active").each(function(){
  51. dataid = $(this).data("id");
  52. dataname = $(this).find('[node-type="name"]').attr("title");
  53. that.arrId.push(dataid);
  54. that.arrName.push(dataname);
  55. });
  56. var length = that.arrId.length
  57. that.dialog();
  58. that.resetCount(length);
  59. that.post();
  60. });
  61. $("body").on("click", '#qs_setting', function(){
  62. var qs_pass = $("#qs_pass").val(),
  63. qs_linktype = $("#qs_linktype").val();
  64. var reg = /^([a-zA-Z0-9]{4,4})$/;
  65. if(!reg.test(qs_pass)){
  66. $("#qs_pass").val(that.pass);
  67. alert("请输入正确的密码。");
  68. return false;
  69. } else {
  70. localStorage.setItem("qs_psss", qs_pass);
  71. localStorage.setItem("qs_linktype", qs_linktype);
  72. that.pass = qs_pass;
  73. that.linktype = qs_linktype;
  74. $(this).parents(".b-dialog").remove();
  75. }
  76. });
  77. },
  78. post: function(){
  79. var that = this,
  80. index = this.index;
  81. var id = this.arrId[index],
  82. name = this.arrName[index],
  83. text = "",
  84. request = $.ajax({
  85. url: "/share/set?channel=chunlei&clienttype=0&web=1&bdstoken=" + yunData.MYBDSTOKEN + "&app_id=25052",
  86. method: "POST",
  87. data: {
  88. fid_list : "["+id+"]",
  89. schannel: 4,
  90. channel_list: "[]",
  91. pwd: that.pass
  92. },
  93. dataType: "json"
  94. });
  95. request.done(function(json) {
  96. if (json.errno == 0) {
  97. if (that.linktype == "ubb") {
  98. text = "[url="+json.shorturl+"]百度网盘下载: "+name+"[/url] 提取密码:"+that.pass;
  99. } else if (that.linktype == "html") {
  100. text = "<a href='"+json.shorturl+"'>百度网盘下载: "+name+"</a> 提取密码:"+that.pass;
  101. } else {
  102. text = json.shorturl +" 提取密码:"+that.pass;
  103. }
  104. } else {
  105. text = name+" 分享失败, 错误代码: "+json.errno;
  106. }
  107. var old = $("#shareresult").val();
  108. if (old=="") {
  109. old = text;
  110. } else {
  111. old = old+"\r\n"+text;
  112. }
  113. $("#shareresult").val(old);
  114. that.count();
  115. that.index++;
  116. if (that.index >= that.arrId.length) {
  117. window.clearTimeout(that.setTime);
  118. window.clearInterval(that.setSec);
  119. that.setTime = null;
  120. that.setSec = null;
  121. } else {
  122. that.setTime = setTimeout(function(){
  123. that.post();
  124. }, that.timeout);
  125. that.setSec = setInterval(function(){
  126. var sec = parseInt($("#sec").text());
  127. sec--;
  128. if (sec>0) {
  129. $("#sec").text(sec);
  130. } else {
  131. window.clearInterval(that.setSec);
  132. that.setSec = null;
  133. $("#sec").text(parseInt(that.timeout / 1000));
  134. }
  135. }, 1000);
  136. }
  137. });
  138. },
  139. resetCount: function(len){
  140. $("#ok").text("0");
  141. $("#all").text(len);
  142. $("#no").text(len);
  143. },
  144. count: function(){
  145. var ok = parseInt($("#ok").text()) + 1;
  146. var all = parseInt($("#all").text());
  147. var no = all - ok;
  148. $("#ok").text(ok);
  149. $("#no").text(no);
  150. },
  151. dialog: function() {
  152. if ($("#share-box").length > 0) {
  153. return false;
  154. }
  155. var that = this,
  156. html = "",
  157. w = 576,
  158. h = 514,
  159. ww = $(window).width(),
  160. hh = $(window).height();
  161. var l = (ww - w) / 2,
  162. t = (hh - h) / 2;
  163. html+='<div id="share-box" class="b-panel b-dialog box-shadow4 bdr-rnd-3 add-yun-device-dialog common-dialog" style="display: block; left: '+l+'px; top: '+t+'px;">';
  164. html+=' <div class="dlg-hd b-rlv"><span class="dlg-cnr dlg-cnr-l"></span>';
  165. html+=' <a href="javascript:void(0);" title="关闭" id="closeQuickShareDailog" class="dlg-cnr dlg-cnr-r"></a>';
  166. html+=' <h3><em></em>分享结果</h3>';
  167. html+=' </div>';
  168. html+=' <div class="dlg-bd global-clearfix __dlgBd" style="visibility: visible;">';
  169. html+=' <div class="add-yun-device-list">';
  170. html+=' <p style="margin-bottom: 10px;">共 <b id="all">0</b> 条, 已完成 <b id="ok">0</b> 条, 剩余 <b id="no">0</b> 条 <b id="sec">'+ parseInt(that.timeout / 1000) +'</b>s</p>';
  171. html+=' <textarea style="width:100%; height:400px;" id="shareresult"></textarea>';
  172. html+=' </div>';
  173. html+=' </div>';
  174. html+='</div>';
  175. $("body").append(html).find("#closeQuickShareDailog").click(function(){
  176. window.clearTimeout(that.setTime);
  177. that.setTime = null;
  178. window.clearInterval(that.setSec);
  179. that.setSec = null;
  180. $(this).parents(".b-dialog").remove();
  181. });
  182. },
  183. setting: function() {
  184. var that = this,
  185. html = "",
  186. w = 576,
  187. h = 218,
  188. ww = $(window).width(),
  189. hh = $(window).height();
  190. var l = (ww - w) / 2,
  191. t = (hh - h) / 2,
  192. length = this.arrId.length;
  193. html+='<div id="setting-box" class="b-panel b-dialog box-shadow4 bdr-rnd-3 add-yun-device-dialog common-dialog" style="display: block; left: '+l+'px; top: '+t+'px;">';
  194. html+=' <div class="dlg-hd b-rlv"><span class="dlg-cnr dlg-cnr-l"></span>';
  195. html+=' <a href="javascript:void(0);" title="关闭" id="closeQuickShareSettingDailog" class="dlg-cnr dlg-cnr-r"></a>';
  196. html+=' <h3><em></em>设置</h3>';
  197. html+=' </div>';
  198. html+=' <div class="dlg-bd global-clearfix __dlgBd" style="visibility: visible;">';
  199. html+=' <div class="add-yun-device-list">';
  200. html+=' <table border="0" cellpadding="5" cellspacing="0">';
  201. html+=' <tr><td style="padding:10px;">链接类型: </td><td style="padding:10px;"><select id="qs_linktype"><option value="ubb">ubb代码</option><option value="html">html代码</option><option value="link">链接</option></select></td></tr>';
  202. html+=' <tr><td style="padding:10px;">分享密码: </td><td style="padding:10px;"><input id="qs_pass" class="input-text" type="text" maxlength="4" pattern="/([a-zA-Z0-9]{4,4})/" value="'+ that.pass +'" required /></td></tr>';
  203. html+=' <tr><td style="padding:10px;">&nbsp;</td><td style="padding:10px;"><a id="qs_setting" class="sbtn create-public"><b>设置</b></a></td></tr>';
  204. html+=' </table>';
  205. html+=' </div>';
  206. html+=' </div>';
  207. html+='</div>';
  208. $("#setting-box").remove();
  209. $("body").append(html).find("#closeQuickShareSettingDailog").click(function(){
  210. $(this).parents(".b-dialog").remove();
  211. });
  212. $("#qs_linktype").val(that.linktype);
  213. }
  214. };
  215. var bs = new baidushares();
  216. bs.init();
  217. }(window));

QingJ © 2025

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