Greasy Fork 支持简体中文。

文武Download-高速下载直链的百度云盘SVIP助手

提取百度网盘单文件高速直链、便捷使用的脚本助手,支持 Gopeed 多线程下载工具。向广大网友免费交流学习使用,探索使用脚本的乐趣!

目前為 2024-12-04 提交的版本,檢視 最新版本

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