百度网盘不限速下载-🚀火箭加速🚀

一款百度网盘加速下载脚本,可长期稳定使用

От 12.11.2024. Виж последната версия.

  1. // ==UserScript==
  2. // @name 百度网盘不限速下载-🚀火箭加速🚀
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 一款百度网盘加速下载脚本,可长期稳定使用
  6. // @antifeature ads
  7. // @author You
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @license MIT
  10. // @icon https://nd-static.bdstatic.com/m-static/v20-main/home/img/icon-home-new.b4083345.png
  11. // @match *://pan.baidu.com/*
  12. // @match *://yun.baidu.com/*
  13. // @match *://pan.baidu.com/disk/home*
  14. // @match *://yun.baidu.com/disk/home*
  15. // @match *://pan.baidu.com/disk/main*
  16. // @match *://yun.baidu.com/disk/main*
  17. // @match *://pan.baidu.com/s/*
  18. // @match *://yun.baidu.com/s/*
  19. // @match *://pan.baidu.com/share/*
  20. // @match *://yun.baidu.com/share/*
  21. // @connect baidu.com
  22. // @connect aifenxiang.net.cn
  23. // @connect 127.0.0.1
  24. // @grant GM_cookie
  25. // @grant GM_addStyle
  26. // @grant GM_getResourceText
  27. // @grant GM_xmlhttpRequest
  28. // @require https://cdnjs.cloudflare.com/ajax/libs/layui/2.9.14/layui.min.js
  29. // @require https://unpkg.com/sweetalert/dist/sweetalert.min.js
  30. // @resource layuiCSS https://cdnjs.cloudflare.com/ajax/libs/layui/2.9.14/css/layui.css
  31. // ==/UserScript==
  32. (function () {
  33. 'use strict';
  34. const layuicss = GM_getResourceText('layuiCSS');
  35. GM_addStyle(layuicss);
  36. layui.use(['layer'], async function () {
  37. var layer = layui.layer,
  38. $ = layui.$;
  39. var form = layui.form;
  40. if (location.href.startsWith('https://pan.baidu.com/s/')) {
  41. $('.x-button-box').prepend(
  42. '<a class="g-button" id="downbtn_share" style="background-color: #6800ff;color: #fff;border:none;" href="javascript:;" ><span class="g-button-right"><em style="top:0;" class="icon icon-download" title=""></em><lable class="text" style="width: auto;">' +
  43. config.title_name +
  44. '</lable></span></a>'
  45. );
  46. } else {
  47. if ($('.tcuLAu').is('*')) {
  48. $('.tcuLAu').prepend(
  49. '<span class="g-dropdown-button"><a id="downbtn_main" style=" margin-right: 10px;color: #fff;background-color: #fc5531;border:none;" id="downbtn_main" class="g-button" ><span class="g-button-right"><em style="top:0;" class="icon icon-download" ></em><lable class="text" style="width: auto;">' +
  50. config.title_name +
  51. '</lable></span></a></span>'
  52. );
  53. } else {
  54. $('.wp-s-agile-tool-bar__header.is-header-tool').prepend(
  55. '<div class="wp-s-agile-tool-bar__h-group"><button style=" margin-right: 10px;color: #fff;background-color: #06a7ff;border:none;" id="downbtn_main" class="u-button nd-file-list-toolbar-action-item" ><i style="top:0;" class="iconfont icon-download"></i> <lable>' +
  56. config.title_name +
  57. '</lable></button></div>'
  58. );
  59. }
  60. }
  61.  
  62. $('#downbtn_share').click(function () {
  63. swal({
  64. title: '提示',
  65. text: '请先保存到自己的网盘后,从网盘里解析!',
  66. icon: 'warning',
  67. });
  68. return false;
  69. });
  70. $('#downbtn_main').click(function () {
  71. let select = selectList();
  72. let selected = Object.keys(select);
  73. if (selected.length == 0) {
  74. swal({
  75. text: '请先选择一个文件',
  76. icon: 'warning',
  77. });
  78. return false;
  79. } else if (selected.length > 1) {
  80. swal({
  81. text: '目前仅支持单个文件解析',
  82. icon: 'warning',
  83. });
  84. return false;
  85. } else if (select[selected[0]].isdir == 1) {
  86. swal({
  87. text: '目前不支持文件夹解析',
  88. icon: 'warning',
  89. });
  90. return false;
  91. }
  92.  
  93. const newDiv = document.createElement('div');
  94. let createDiv = `
  95. <div>
  96. <img src="https://bd.shzxkq.com/xcx.jpg" style="width:240px;height:240px;">
  97. </div>
  98. <div>
  99. <input style="border:1px solid #ccc; width:60%;height:40px;text-indent:20px;" type="text" autocomplete="off" placeholder="请输入验证码" id="wpCode"/>
  100. </div>
  101.  
  102. `;
  103. newDiv.innerHTML = createDiv;
  104.  
  105. const openLayer = layer.open({
  106. type: 1, // page 层类型
  107. area: ['450px', '300px'],
  108. title: '提示',
  109. shade: 0.6, // 遮罩透明度
  110. shadeClose: true, // 点击遮罩区域,关闭弹层
  111. anim: 0, // 0-6 的动画形式,-1 不开启
  112. content: `
  113. <div class="layui-form" lay-filter="filter-test-layer" style="width:360px;margin: 16px auto 0;">
  114. <div class="demo-login-container">
  115. <div style="margin-top:50px;">插件解析限制两次</div>
  116. <div>下载器一定要配置好Ua和端口: <a style="color:green;" target="_blank" href="https://docs.qq.com/doc/DWnlpY2pkclpuUEFX?no_promotion=1">点击查看配置说明</a></div>
  117. <div>不限次数pc网页稳定版: <a style="color:green;" target="_blank" href="https://www.aifenxiang.net.cn/">点击前往</a></div>
  118. <button style="margin-left:0;margin-top:50px;" id="parse" class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">解析</button>
  119. </div>
  120. </div>
  121. `,
  122. success: function () {
  123. // 对弹层中的表单进行初始化渲染
  124. form.render();
  125. // 表单提交事件
  126. form.on('submit(demo-login)', async function (data) {
  127. $('#parse').html('<p>正在解析中请稍后...</p>');
  128. //let field = data.field; // 获取表单字段值
  129. let canDown = await testDownLoad();
  130.  
  131. if (!canDown) {
  132. layer.close(openLayer);
  133. swal({
  134. text: '请先安装下载器并打开运行,下载地址:https://pan.quark.cn/s/b878b162bb5b',
  135. icon: 'warning',
  136. });
  137. $('#parse').html('<p>解析</p>');
  138. return;
  139. }
  140. share_one_baidu(openLayer, 1234);
  141. });
  142. },
  143. });
  144. });
  145. });
  146. function selectList() {
  147. var select = {};
  148. var option = [];
  149.  
  150. try {
  151. option =
  152. require('system-core:context/context.js').instanceForSystem.list.getSelected();
  153. } catch (e) {
  154. option = document.querySelector('.wp-s-core-pan').__vue__.selectedList;
  155. }
  156. option.forEach((element) => {
  157. select[element.fs_id] = element;
  158. });
  159. return select;
  160. }
  161. const config = {
  162. main_url: 'https://aifenxiang.net.cn:8081',
  163. //main_url: 'http://127.0.0.1:8081',
  164. bd_password: '1234',
  165. title_name: '火箭加速',
  166. };
  167. function share_one_baidu(openLayer, code) {
  168. let select = Object.keys(selectList());
  169. let bdstoken = '';
  170. let data_json = {};
  171. try {
  172. data_json = $('html')
  173. .html()
  174. .match(/(?<=locals\.mset\()(.*?)(?=\);)/)[0];
  175. data_json = JSON.parse(data_json);
  176. config.username = data_json.username;
  177. bdstoken = data_json.bdstoken;
  178. } catch (e) {
  179. data_json = $('html')
  180. .html()
  181. .match(/(?<=window\.locals\s=\s)(.*?)(?=;)/)[0];
  182. data_json = JSON.parse(data_json);
  183. config.username = data_json.userInfo.username;
  184. bdstoken = data_json.userInfo.bdstoken;
  185. }
  186.  
  187. config.data_json = data_json;
  188.  
  189. const param = {
  190. bdstoken: bdstoken,
  191. period: 1,
  192. pwd: config.bd_password,
  193. eflag_disable: true,
  194. channel_list: '%5B%5D',
  195. schannel: 4,
  196. fid_list: JSON.stringify(select),
  197. };
  198.  
  199. $.ajax({
  200. type: 'GET',
  201. url: 'https://pan.baidu.com/share/set',
  202. async: true,
  203. data: {
  204. bdstoken: bdstoken,
  205. period: 1,
  206. pwd: config.bd_password,
  207. eflag_disable: true,
  208. channel_list: '%5B%5D',
  209. schannel: 4,
  210. fid_list: JSON.stringify(select),
  211. },
  212. dataType: 'json',
  213. success: function (res) {
  214. if (res.show_msg.indexOf('禁止') > -1) {
  215. swal({
  216. text: '该文件禁止分享',
  217. icon: 'error',
  218. });
  219. return false;
  220. } else {
  221. let shorturl = '';
  222. try {
  223. shorturl = res.link.split('/').pop();
  224. } catch (error) {
  225. swal({
  226. text: '初始化准备失败',
  227. icon: 'error',
  228. });
  229. return false;
  230. }
  231. fetch(config.main_url + '/wp/getCodeNum', {
  232. method: 'POST',
  233. headers: {
  234. 'Content-Type': 'application/json',
  235. },
  236. body: JSON.stringify({
  237. code: code,
  238. userKey: 'main',
  239. fsId: select[0],
  240. version: '1.1.2',
  241. }),
  242. })
  243. .then((resp) => resp.json())
  244. .then((res) => {
  245. let laysermsg = layer.msg('正在解析中', {
  246. icon: 6,
  247. time: 10000, // 7秒后自动关闭
  248. });
  249. if (res.code == 200) {
  250. config.code = code;
  251. if (res.data > 100) {
  252. get_down_list(
  253. shorturl,
  254. config.bd_password,
  255. openLayer,
  256. res.data,
  257. laysermsg
  258. );
  259. } else if (res.data == 80) {
  260. layer.msg('解析中', {
  261. icon: 6,
  262. time: 3000, // 3秒后自动关闭
  263. });
  264. setTimeout(() => {
  265. $('#parse').html('<p>解析</p>');
  266. layer.alert('解析通道比较拥堵,请重试!', {
  267. title: '提示',
  268. });
  269. }, 3000);
  270. } else if (res.data == 60) {
  271. layer.msg('解析中', {
  272. icon: 6,
  273. time: 3000, // 3秒后自动关闭
  274. });
  275. setTimeout(() => {
  276. $('#parse').html('<p>解析</p>');
  277. layer.alert('解析次数已达上限,不限次数稳定版!地址:https://www.aifenxiang.net.cn', {
  278. title: '提示',
  279. });
  280. }, 3000);
  281. } else if (res.data == 50) {
  282. layer.alert(
  283. '验证码错误,一个验证码只能下载一个文件,请重新获取!',
  284. {
  285. title: '提示',
  286. }
  287. );
  288. } else {
  289. layer.alert(
  290. '验证码错误,一个验证码只能下载一个文件,请重新获取!',
  291. {
  292. title: '提示',
  293. }
  294. );
  295. }
  296. } else if (res.code == 500) {
  297. layer.close(openLayer);
  298. layer.close(laysermsg);
  299. swal({
  300. text: res.msg,
  301. icon: 'warning',
  302. });
  303. }
  304. });
  305. }
  306. },
  307. error: function (res) {
  308. swal({
  309. text: '初始化准备请求访问失败',
  310. icon: 'error',
  311. });
  312. },
  313. });
  314. }
  315.  
  316. async function get_down_list(shorturl, password, openLayer, pwd, laysermsg) {
  317. let ajax_data = {
  318. shorturl: shorturl,
  319. pwd: password,
  320. dir: 1,
  321. root: 1,
  322. userKey: 'main',
  323. };
  324.  
  325. fetch(config.main_url + '/wp/parseCopyLink', {
  326. method: 'POST',
  327. headers: {
  328. 'Content-Type': 'application/json',
  329. },
  330. body: JSON.stringify(ajax_data),
  331. })
  332. .then((resp) => resp.json())
  333. .then((res) => {
  334. if (res.code == 200) {
  335. const size = parseInt(res.data.data.list[0].size);
  336. if (size > 3221225472) {
  337. layer.close(openLayer);
  338. layer.close(laysermsg);
  339. $('#parse').html('<p>解析</p>');
  340. swal({
  341. text: '文件大于3G,插件暂不支持下载,请前往PC网页版下载!',
  342. icon: 'warning',
  343. });
  344. return false;
  345. }
  346. console.log(res);
  347. const requestData = {
  348. fsId: res.data.data.list[0].fs_id,
  349. shareid: res.data.data.shareid,
  350. uk: res.data.data.uk,
  351. sekey: res.data.data.seckey,
  352. randsk:res.data.data.seckey,
  353. fs_ids: [res.data.data.list[0].fs_id],
  354. path:res.data.data.list[0].server_filename,
  355. size:res.data.data.list[0].size,
  356. surl: shorturl,
  357. url: `https://pan.baidu.com/s/${shorturl}`,
  358. userKey: 'main',
  359. pwd: password,
  360. dir: '/',
  361. };
  362. console.log(requestData);
  363. GM_xmlhttpRequest({
  364. method: 'POST',
  365. url: config.main_url + '/wp/dlink',
  366. headers: {
  367. 'Content-Type': 'application/json',
  368. },
  369. data: JSON.stringify(requestData),
  370. onload: function (response) {
  371. const responseData = JSON.parse(response.responseText);
  372. console.log(responseData);
  373. if (responseData.code !== 200) {
  374. layer.close(openLayer);
  375. layer.close(laysermsg);
  376. swal({
  377. text: responseData.msg,
  378. icon: 'warning',
  379. });
  380. } else {
  381. layer.close(laysermsg);
  382. $('#parse').html('<p>解析</p>');
  383. if(responseData.data.vip){
  384. config.url = responseData.data.data[0].url;
  385. }else{
  386. config.url = responseData.data.data.urls[0].url;
  387. }
  388. sendToMotrix(res.data.data.list[0]);
  389. }
  390. },
  391. onerror: function (response) {
  392. layer.close(openLayer);
  393. layer.close(laysermsg);
  394. const errorMessage =
  395. JSON.parse(response.responseText).message || '网络错误';
  396. swal({
  397. text: '解析遇到问题了,请刷新重试即可!!',
  398. icon: 'warning',
  399. });
  400. },
  401. });
  402. } else {
  403. layer.close(openLayer);
  404. layer.close(laysermsg);
  405. $('#parse').html('<p>解析</p>');
  406. swal({
  407. text: '解析遇到问题了,请升级插件刷新重试即可!!',
  408. icon: 'warning',
  409. });
  410. }
  411. });
  412. }
  413.  
  414. function sendToMotrix(item) {
  415. fetch('http://127.0.0.1:9999/api/v1/tasks', {
  416. method: 'POST',
  417. headers: {
  418. 'Content-Type': 'application/json'
  419. },
  420. body: JSON.stringify({
  421. req:
  422. {
  423. url:config.url
  424. },
  425. opt:{
  426. extra:{
  427. connections:256,
  428. }
  429. }
  430. }),
  431. }).then((resp) => resp.json())
  432. .then((res) => {
  433. layer.alert(`${item.server_filename}开始下载,请打开下载器查看!`);
  434.  
  435. }).catch(e=>{
  436. })
  437. }
  438. setInterval(()=>{
  439.  
  440. GM_xmlhttpRequest({
  441. method: 'get',
  442. url: 'http://127.0.0.1:9999/api/v1/tasks?status=running',
  443. headers: {
  444. 'Content-Type': 'application/json',
  445. },
  446. onload: function (response) {
  447. const responseData = JSON.parse(response.responseText);
  448. const result = responseData.data.filter(e=>
  449. e.status === "running"
  450. ).filter((e)=>e.progress.speed < 1048576).map(e=>e.id);
  451. const ids = result.map((e)=>{
  452. return `id=${e}`
  453. }).join('&')
  454. if(ids && ids.length){
  455. GM_xmlhttpRequest({
  456. method: 'put',
  457. url: `http://127.0.0.1:9999/api/v1/tasks/pause?${ids}`,
  458. headers: {
  459. 'Content-Type': 'application/json',
  460. },
  461. onload: function (response) {
  462. GM_xmlhttpRequest({
  463. method: 'put',
  464. url: `http://127.0.0.1:9999/api/v1/tasks/continue?${ids}`,
  465. headers: {
  466. 'Content-Type': 'application/json',
  467. },
  468. onload: function (response) {
  469. }
  470. })
  471. }
  472. })
  473. }
  474. }
  475. })
  476. },15000)
  477. function testDownLoad() {
  478. return fetch('http://127.0.0.1:9999/api/v1/tasks', {
  479. method: 'POST',
  480. headers: {
  481. 'Content-Type': 'application/json'
  482. },
  483. })
  484. .then((resp) => resp.json())
  485. .then((res) => {
  486. return true;
  487. }).catch(e=>{
  488. return false;
  489. })
  490. }
  491.  
  492.  
  493. // Your code here...
  494. })();