百度网盘SVIP高速解析直链的不限速下载助手-文武PanDownload

不限制速度的百度网盘SVIP解析高速直链的脚本助手,无视黑号,100%可用,下载速度最快可达10M+/s,支持 Gopeed(一键解析)、IDM、NDM 等多线程极速下载工具,支持 Microsoft Edge、Google Chrome、Firefox 等浏览器。

目前为 2024-12-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 百度网盘SVIP高速解析直链的不限速下载助手-文武PanDownload
  3. // @namespace https://github.com/dongyubin/Baidu-VIP
  4. // @version 4.0
  5. // @description 不限制速度的百度网盘SVIP解析高速直链的脚本助手,无视黑号,100%可用,下载速度最快可达10M+/s,支持 Gopeed(一键解析)、IDM、NDM 等多线程极速下载工具,支持 Microsoft Edge、Google Chrome、Firefox 等浏览器。
  6. // @author dongyubin
  7. // @homepage https://fk.wwkejishe.top/buy/23
  8. // @supportURL https://fk.wwkejishe.top/buy/23
  9. // @license MIT
  10. // @icon https://fk.wwkejishe.top/uploads/images/6e798005b00ce678782af4e6931f4374.png
  11. // @resource layuiCSS https://cdnjs.cloudflare.com/ajax/libs/layui/2.9.20/css/layui.min.css
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/layui/2.9.20/layui.min.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js
  14. // @match *://pan.baidu.com/*
  15. // @match *://yun.baidu.com/*
  16. // @match *://pan.baidu.com/disk/home*
  17. // @match *://yun.baidu.com/disk/home*
  18. // @match *://pan.baidu.com/disk/timeline*
  19. // @match *://yun.baidu.com/disk/timeline*
  20. // @match *://pan.baidu.com/disk/main*
  21. // @match *://yun.baidu.com/disk/main*
  22. // @match *://pan.baidu.com/disk/base*
  23. // @match *://yun.baidu.com/disk/base*
  24. // @match *://pan.baidu.com/s/*
  25. // @match *://yun.baidu.com/s/*
  26. // @match *://pan.baidu.com/aipan/*
  27. // @match *://yun.baidu.com/aipan/*
  28. // @match *://pan.baidu.com/share/*
  29. // @match *://yun.baidu.com/share/*
  30. // @match *://openapi.baidu.com/*
  31. // @connect aifenxiang.net.cn
  32. // @connect baidu.com
  33. // @connect *
  34. // @connect 127.0.0.1
  35. // @grant GM_cookie
  36. // @grant GM_addStyle
  37. // @grant GM_getResourceText
  38. // @grant GM_xmlhttpRequest
  39. // @grant GM_setClipboard
  40. // @grant GM_notification
  41. // @grant GM_info
  42. // @antifeature ads
  43. // @antifeature membership
  44. // @antifeature referral-link
  45. // ==/UserScript==
  46. (function () {
  47. 'use strict';
  48. const layuiCss = GM_getResourceText('layuiCSS');
  49. GM_addStyle(layuiCss + `
  50. .layui-icon-close:before {
  51. content: "x" !important;
  52. }
  53. `);
  54. const wwConfig = {
  55. mainUrl: 'https://aifenxiang.net.cn:8081',
  56. bdPassword: '1234',
  57. titleName: '文武PanDownload',
  58. goPeedTaskUrl: 'http://127.0.0.1:9999/api/v1/tasks',
  59. ua: 'netdisk;1.0.1',
  60. one_parse: {
  61. code: '1.0.3',
  62. version: '1.1.4'
  63. },
  64. wx_parse: {
  65. version: "1.0.9"
  66. }
  67. };
  68. layui.use(['layer'], async function () {
  69. var layer = layui.layer,
  70. $ = layui.$;
  71. var form = layui.form;
  72. if (location.href.startsWith('https://pan.baidu.com/s/')) {
  73. $('.x-button-box').prepend(
  74. '<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;">' +
  75. wwConfig.titleName +
  76. '</lable></span></a>'
  77. );
  78. } else {
  79. if ($('.tcuLAu').is('*')) {
  80. $('.tcuLAu').prepend(
  81. '<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;">' +
  82. wwConfig.titleName +
  83. '</lable></span></a></span>'
  84. );
  85. } else {
  86. $('.wp-s-agile-tool-bar__header.is-header-tool').prepend(
  87. '<div class="wp-s-agile-tool-bar__h-group"><button style=" margin-right: 10px;color: #fff;background-color: #ff436a;border:none;" id="downbtn_main" class="u-button nd-file-list-toolbar-action-item" ><i style="top:0;" class="iconfont icon-download"></i> <lable>' +
  88. wwConfig.titleName +
  89. '</lable></button></div>'
  90. );
  91. }
  92. }
  93. $('#downbtn_share').click(function () {
  94. swal({
  95. title: '提示',
  96. text: '请先保存到自己的网盘后,在网盘里解析下载!',
  97. icon: 'warning',
  98. });
  99. return false;
  100. });
  101. $('#downbtn_main').click(function () {
  102. let select = selectList();
  103. let selected = Object.keys(select);
  104. if (selected.length == 0) {
  105. swal({
  106. text: '请先选择一个文件',
  107. icon: 'warning',
  108. });
  109. return false;
  110. } else if (selected.length > 1) {
  111. swal({
  112. text: '目前仅支持单个文件解析',
  113. icon: 'warning',
  114. });
  115. return false;
  116. } else if (select[selected[0]].isdir == 1) {
  117. swal({
  118. text: '目前不支持文件夹解析',
  119. icon: 'warning',
  120. });
  121. return false;
  122. }
  123.  
  124. const openInfoLayer = layer.open({
  125. type: 1,
  126. area: ['550px', 'auto'],
  127. title: '提示',
  128. type: 1,
  129. shade: 0.6,
  130. shadeClose: true,
  131. anim: 0,
  132. content: `
  133. <div class="layui-tab layui-tab-brief" style="background-color: #f8f8f8; border-radius: 8px;">
  134. <ul class="layui-tab-title" style="background-color: #fff; border-bottom: 1px solid #e6e6e6;">
  135. <li class="layui-this">免费解析</li>
  136. <li>验证码解析</li>
  137. <li>稳定解析</li>
  138. <li>防止失联</li>
  139. </ul>
  140. <div class="layui-tab-content" style="padding: 20px;">
  141. <div class="layui-tab-item layui-show">
  142. <div class="layui-form" lay-filter="filter-test-layer" style="width:360px;margin: 16px auto 0; background-color: #fff; border-radius: 8px; padding: 20px;">
  143. <div class="demo-send-container">
  144. <div>
  145. <p>插件解析限制 <span class="piao">2</span> 次</p>
  146. <p style="font-weight:900;">
  147. ⚠️❗ 一定要先配置好 Gopeed 下载器的 User-Agent、端口、连接数: <a style="color:red;" target="_blank" href="https://flowus.cn/share/c68e3c55-67e5-460f-b937-7727e0378a34?code=BCRWJL">点击查看 Gopeed 配置教程说明</a>
  148. </p>
  149. <p>
  150. 不限次数 PC 网页稳定版: <a style="color:red;font-weight:900;" target="_blank" href="https://pandown.mlover.site/">点击前往</a>
  151. </p>
  152. <p>
  153. 部分校园网可能不支持解析
  154. </p>
  155. </div>
  156. <div class="layui-btn-container">
  157. <button style="margin-top:30px; border-radius: 8px;" id="gopeedSetBtn" class="layui-btn layui-btn-fluid layui-bg-red" lay-submit lay-filter="gopeed-set">1️⃣ Gopeed设置教程</button>
  158. <button style="margin-top:10px; border-radius: 8px;" id="copyUaBtn" class="layui-btn layui-btn-fluid layui-bg-orange" lay-submit lay-filter="copy-ua">2️⃣ 复制User-Agent</button>
  159. <button style="margin-left:0;margin-top:10px; border-radius: 8px;" id="parseBtn" class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-send">3️⃣ 发送到Gopeed</button>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <div class="layui-tab-item" style="background-color: #fff; border-radius: 8px; padding: 20px;text-align: center;">
  165. <div>
  166. <img src="https://cdn.wwkejishe.top/wp-cdn-02/2024/202411171346351.webp" style="width:240px;height:240px;">
  167. </div>
  168. <h2 class="h2" style="margin-top: 10px;">扫描上方二维码,获取验证码</h2>
  169. <h3>每天随机解析5-10次</h3>
  170. <div>
  171. <input type="text" name="captcha" id="captcha" value="" lay-verify="required" placeholder="请填写验证码" lay-reqtext="请填写验证码" autocomplete="off" class="layui-input" lay-affix="clear">
  172. </div>
  173. <button style="margin-left:0;margin-top:10px; border-radius: 8px;" id="parseWxBtn" class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-wx-send">发送到Gopeed</button>
  174. </div>
  175. <div class="layui-tab-item" style="background-color: #fff; border-radius: 8px; padding: 20px;">
  176. <p><span style="font-weight: 900;">`+ GM_info.script.name + `</span> 最新的脚本版本号为:<span style="font-weight: 900;">` + GM_info.script.version + `</span></p>
  177. <p>&nbsp;</p>
  178. <p><a href="https://fk.wwkejishe.top/buy/23" target="_blank" style="font-weight: 900;color: #409eff;">
  179. 购买月卡:不限次数、不限制文件大小、不限速</a></p>
  180. <p>
  181. <p>&nbsp;</p>
  182. <figure class='table-figure'>
  183. <table class="layui-table" style="border-collapse: separate;">
  184. <thead>
  185. <tr>
  186. <th style="background-color: #f8f8f8; border-bottom: 2px solid #e6e6e6; padding: 10px;">百度VIP</th>
  187. <th style="background-color: #f8f8f8; border-bottom: 2px solid #e6e6e6; padding: 10px;">百度SVIP</th>
  188. <th style="background-color: #f8f8f8; border-bottom: 2px solid #e6e6e6; padding: 10px;">
  189. <a href='https://fk.wwkejishe.top/buy/23' target='_blank' style='color: #007bff; text-decoration: none;'>Pandownload月卡</a>
  190. </th>
  191. </tr>
  192. </thead>
  193. <tbody>
  194. <tr>
  195. <td style="padding: 10px; border-bottom: 1px solid #e6e6e6;">¥25/月</td>
  196. <td style="padding: 10px; border-bottom: 1px solid #e6e6e6;">¥40/月</td>
  197. <td style="padding: 10px; border-bottom: 1px solid #e6e6e6;color: rgba(5,150,105,1)">¥9/月</td>
  198. </tr>
  199. <tr>
  200. <td style="padding: 10px; border-bottom: 1px solid #e6e6e6;">20G/月</td>
  201. <td style="padding: 10px; border-bottom: 1px solid #e6e6e6;">不限制</td>
  202. <td style="padding: 10px; border-bottom: 1px solid #e6e6e6;color: rgba(5,150,105,1)">不限制文件大小、不限制文件数量、高速下载</td>
  203. </tr>
  204. </tbody>
  205. </table>
  206. </figure>
  207. <p>&nbsp;</p>
  208. <p>
  209. <a href="http://vip.jiufei.com/lin/GI5LG4?refer=1661" target="_blank" style="color: #007bff; text-decoration: none;">点击购买(高质量)网盘会员</a>:¥3/4天,¥7.5/25天,¥22.8/年
  210. </p>
  211. <p>&nbsp;</p>
  212. <p>2023-2024 © Github By <a style="color:#007bff;" href="https://github.com/dongyubin/Baidu-VIP" target="_blank">@dongyubin</a></p>
  213. </div>
  214. <div class="layui-tab-item" style="background-color: #fff; border-radius: 8px; padding: 20px;text-align: center;">
  215. <div>
  216. <img src="https://cdn.wwkejishe.top/wp-cdn-02/2024/202411171346351.webp" style="width:240px;height:240px;">
  217. </div>
  218. <h2 class="h2" style="margin-top: 10px;">扫一扫,不失联</h2>
  219. <h3 class="h2" style="margin-top: 10px;">众所周知,脚本不可能每时每刻都能用。关注不迷路 ~</h3>
  220. </div>
  221. </div>
  222. </div>
  223. `,
  224. success: function () {
  225. // 对弹层中的表单进行初始化渲染
  226. form.render();
  227. // 表单提交事件
  228. form.on('submit(demo-send)', async function (data) {
  229. $('#parseBtn').html('<p>正在发送中,请稍后...</p>');
  230. let testDown = await testSendToGopeed();
  231. if (!testDown) {
  232. layer.close(openInfoLayer);
  233. gospeedDownload();
  234. $('#parseBtn').html('<p>发送到Gopeed</p>');
  235. return;
  236. }
  237. let one_url = wwConfig.mainUrl + '/wp/getCodeNum';
  238. share_one_baidu(openInfoLayer, one_url, wwConfig.one_parse.code, wwConfig.one_parse.version, 1);
  239. });
  240.  
  241. $('#parseWxBtn').on('click', async function () {
  242. let captchaStr = $('#captcha').val();
  243. if (captchaStr) {
  244. $('#parseWxBtn').html('<p>正在发送中,请稍后...</p>');
  245. let testDown = await testSendToGopeed();
  246. if (!testDown) {
  247. layer.close(openInfoLayer);
  248. gospeedDownload();
  249. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  250. return;
  251. }
  252. let one_url = wwConfig.mainUrl + '/wp/getPcCodeNum';
  253. share_one_baidu(openInfoLayer, one_url, captchaStr, wwConfig.wx_parse.version, 2);
  254. } else {
  255. layer.msg('请输入验证码');
  256. }
  257.  
  258. });
  259.  
  260. // 复制 User-Agent 按钮的事件处理
  261. $('#copyUaBtn').on('click', function () {
  262. copy_text(wwConfig.ua, 'User-Agent');
  263. });
  264. $('#gopeedSetBtn').on('click', function () {
  265. openUrl('https://flowus.cn/share/c68e3c55-67e5-460f-b937-7727e0378a34?code=BCRWJL');
  266. })
  267. },
  268. });
  269. });
  270. });
  271.  
  272. function gospeedDownload() {
  273. swal({
  274. title: "下载 Gopeed 加速器",
  275. text: '请先安装 Gopeed 并打开运行(点击按钮下载 Gopeed)。',
  276. icon: 'warning',
  277. type: "warning",
  278. confirmButtonText: '点击下载Gopeed',
  279. confirmButtonColor: "#dd6b55",
  280. }).then(function () {
  281. openUrl('https://pan.quark.cn/s/0b2e9c6e94b0');
  282. });
  283. }
  284.  
  285. function openUrl(url) {
  286. window.open(url);
  287. }
  288.  
  289. function selectList() {
  290. var select = {};
  291. var option = [];
  292.  
  293. try {
  294. option =
  295. require('system-core:context/context.js').instanceForSystem.list.getSelected();
  296. } catch (e) {
  297. option = document.querySelector('.wp-s-core-pan').__vue__.selectedList;
  298. }
  299. option.forEach((element) => {
  300. select[element.fs_id] = element;
  301. });
  302. return select;
  303. }
  304.  
  305. function init_parse(code) {
  306. switch (code) {
  307. case 1:
  308. layer.msg('解析中', {
  309. icon: 6,
  310. time: 3000,
  311. });
  312. setTimeout(() => {
  313. $('#parseBtn').html('<p>发送到Gopeed</p>');
  314. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  315. layer.alert('解析通道比较拥堵,请尝试快速下载!', {
  316. title: '提示',
  317. closeBtn: 0,
  318. btn: ['确定', '前往快速下载'],
  319. btn1: function (index) {
  320. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  321. layer.close(index);
  322. },
  323. btn2: function (index) {
  324. openUrl('https://fk.wwkejishe.top/buy/23');
  325. }
  326. });
  327. }, 3000);
  328. break;
  329. case 2:
  330. layer.alert(
  331. '验证码错误,一个验证码只能下载一个文件,请重新获取!',
  332. {
  333. title: '提示',
  334. closeBtn: 0
  335. }, function (index) {
  336. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  337. layer.close(index);
  338. }
  339. );
  340. break;
  341. case 3:
  342. layer.alert('今日下载次数已达上线,请明天再来下载,或者使用快速下载!', {
  343. title: '提示',
  344. closeBtn: 0,
  345. btn: ['确定', '前往快速下载'],
  346. btn1: function (index) {
  347. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  348. layer.close(index);
  349. },
  350. btn2: function (index) {
  351. openUrl('https://fk.wwkejishe.top/buy/23');
  352. }
  353. });
  354. break;
  355. case 4:
  356. layer.alert('解析失败,请升级插件或者使用网页稳定版地址!', {
  357. title: '提示',
  358. closeBtn: 0,
  359. btn: ['确定', '前往快速下载'],
  360. btn1: function (index) {
  361. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  362. layer.close(index);
  363. },
  364. btn2: function (index) {
  365. openUrl('https://fk.wwkejishe.top/buy/23');
  366. }
  367. })
  368. break;
  369. default:
  370. wwConfig.one_parse.version = 1;
  371. break;
  372. }
  373.  
  374. }
  375. function share_one_baidu(openInfoLayer, url, code, version, type) {
  376. let select = Object.keys(selectList());
  377. let bdstoken = '';
  378. let data_json = {};
  379. try {
  380. data_json = $('html')
  381. .html()
  382. .match(/(?<=locals\.mset\()(.*?)(?=\);)/)[0];
  383. data_json = JSON.parse(data_json);
  384. wwConfig.username = data_json.username;
  385. bdstoken = data_json.bdstoken;
  386. } catch (e) {
  387. data_json = $('html')
  388. .html()
  389. .match(/(?<=window\.locals\s=\s)(.*?)(?=;)/)[0];
  390. data_json = JSON.parse(data_json);
  391. wwConfig.username = data_json.userInfo.username;
  392. bdstoken = data_json.userInfo.bdstoken;
  393. }
  394.  
  395. wwConfig.data_json = data_json;
  396.  
  397. $.ajax({
  398. type: 'GET',
  399. url: 'https://pan.baidu.com/share/set',
  400. async: true,
  401. data: {
  402. bdstoken: bdstoken,
  403. period: 1,
  404. pwd: wwConfig.bdPassword,
  405. eflag_disable: true,
  406. channel_list: '%5B%5D',
  407. schannel: 4,
  408. fid_list: JSON.stringify(select),
  409. },
  410. dataType: 'json',
  411. success: function (res) {
  412. if (res.show_msg.indexOf('禁止') > -1) {
  413. swal({
  414. text: '该文件禁止分享',
  415. icon: 'error',
  416. });
  417. return false;
  418. } else {
  419. let shorturl = '';
  420. try {
  421. shorturl = res.link.split('/').pop();
  422. } catch (error) {
  423. swal({
  424. text: '初始化准备失败',
  425. icon: 'error',
  426. });
  427. return false;
  428. }
  429. fetch(url, {
  430. method: 'POST',
  431. headers: {
  432. 'Content-Type': 'application/json',
  433. },
  434. body: JSON.stringify({
  435. code: code,
  436. userKey: 'main',
  437. fsId: select[0],
  438. version: version,
  439. }),
  440. })
  441. .then((resp) => resp.json())
  442. .then((res) => {
  443. let laysermsg = layer.msg('正在解析中', {
  444. icon: 6,
  445. time: 10000,
  446. });
  447. if (res.code == 200) {
  448. wwConfig.code = code;
  449. if (res.data > 100 || (res.data.data == 100 & res.data.vip == 0)) {
  450. let download_url = '';
  451. switch (type) {
  452. case 1:
  453. download_url = wwConfig.mainUrl + '/wp/dlink';
  454. break;
  455. case 2:
  456. download_url = wwConfig.mainUrl + '/wp/fast/pc/dlink';
  457. break;
  458. }
  459. get_down_list(
  460. shorturl,
  461. wwConfig.bdPassword,
  462. openInfoLayer,
  463. res.data,
  464. laysermsg,
  465. download_url
  466. );
  467. }
  468. else if (res.data == 80 || res.data.data == 80) {
  469. init_parse(1);
  470. }
  471. else if (res.data == 60 || res.data.data == 60) {
  472. init_parse(1);
  473. }
  474. else if (res.data == 50 || res.data.data == 50) {
  475. init_parse(2);
  476. }
  477. else if (res.data.data == 100 || res.data.vip == 0) {
  478. init_parse(3);
  479. }
  480. else {
  481. init_parse(2);
  482. }
  483. } else if (res.code == 500) {
  484. layer.close(openInfoLayer);
  485. layer.close(laysermsg);
  486. init_parse(4);
  487. }
  488. });
  489. }
  490. },
  491. error: function (res) {
  492. swal({
  493. text: '初始化准备请求访问失败',
  494. icon: 'error',
  495. });
  496. },
  497. });
  498. }
  499.  
  500. function copy_text(text, msg) {
  501. navigator.clipboard.writeText(text).then(() => {
  502. layer.msg(msg + ' 已复制到剪贴板');
  503. }).catch(err => {
  504. layer.msg('复制失败,请手动复制:' + text);
  505. });
  506. }
  507.  
  508. async function get_down_list(shorturl, password, openInfoLayer, pwd, laysermsg, downloadUrl) {
  509. let ajax_data = {
  510. shorturl: shorturl,
  511. pwd: password,
  512. dir: 1,
  513. root: 1,
  514. userKey: 'main',
  515. };
  516.  
  517. fetch(wwConfig.mainUrl + '/wp/parseCopyLink', {
  518. method: 'POST',
  519. headers: {
  520. 'Content-Type': 'application/json',
  521. },
  522. body: JSON.stringify(ajax_data),
  523. })
  524. .then((resp) => resp.json())
  525. .then((res) => {
  526. if (res.code == 200) {
  527. const size = parseInt(res.data.data.list[0].size);
  528. if (size > 3221225472) {
  529. layer.close(openInfoLayer);
  530. layer.close(laysermsg);
  531. $('#parseBtn').html('<p>发送到Gopeed</p>');
  532. swal({
  533. text: '文件大于 3G,插件暂不支持下载,请前往 PC 网页版下载!',
  534. icon: 'warning',
  535. });
  536. return false;
  537. }
  538. const requestData = {
  539. fsId: res.data.data.list[0].fs_id,
  540. shareid: res.data.data.shareid,
  541. uk: res.data.data.uk,
  542. sekey: res.data.data.seckey,
  543. randsk: res.data.data.seckey,
  544. fs_ids: [res.data.data.list[0].fs_id],
  545. path: res.data.data.list[0].server_filename,
  546. size: res.data.data.list[0].size,
  547. surl: shorturl,
  548. url: `https://pan.baidu.com/s/${shorturl}`,
  549. userKey: 'main',
  550. pwd: password,
  551. dir: '/',
  552. };
  553. console.log(requestData);
  554. GM_xmlhttpRequest({
  555. method: 'POST',
  556. url: downloadUrl,
  557. headers: {
  558. 'Content-Type': 'application/json',
  559. },
  560. data: JSON.stringify(requestData),
  561. onload: function (response) {
  562. const responseData = JSON.parse(response.responseText);
  563. console.log(responseData);
  564. if (responseData.code !== 200) {
  565. layer.close(openInfoLayer);
  566. layer.close(laysermsg);
  567. // swal({
  568. // text: responseData.msg,
  569. // icon: 'warning',
  570. // });
  571. init_parse(4);
  572. } else {
  573. layer.close(laysermsg);
  574. $('#parseBtn').html('<p>发送到Gopeed</p>');
  575. if (responseData.data.vip) {
  576. wwConfig.url = responseData.data.data[0].url;
  577. wwConfig.ua = responseData.data.data[0].ua;
  578. } else {
  579. wwConfig.url = responseData.data.data.urls[0].url;
  580. }
  581. sendToGopeed(res.data.data.list[0]);
  582. }
  583. },
  584. onerror: function (response) {
  585. layer.close(openInfoLayer);
  586. layer.close(laysermsg);
  587. const errorMessage =
  588. JSON.parse(response.responseText).message || '网络错误';
  589. swal({
  590. text: '发送到Gopeed遇到问题了,请刷新重试即可!!',
  591. icon: 'warning',
  592. });
  593. },
  594. });
  595. } else {
  596. layer.close(openInfoLayer);
  597. layer.close(laysermsg);
  598. $('#parseBtn').html('<p>发送到Gopeed</p>');
  599. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  600. swal({
  601. text: '发送到Gopeed遇到问题了,请升级插件刷新重试即可!!',
  602. icon: 'warning',
  603. });
  604. }
  605. });
  606. }
  607. function testSendToGopeed() {
  608. return fetch(wwConfig.goPeedTaskUrl, {
  609. method: 'POST',
  610. headers: {
  611. 'Content-Type': 'application/json'
  612. },
  613. })
  614. .then((resp) => resp.json())
  615. .then((res) => {
  616. return true;
  617. }).catch(e => {
  618. return false;
  619. })
  620. }
  621. function sendToGopeed(item) {
  622. fetch(wwConfig.goPeedTaskUrl, {
  623. method: 'POST',
  624. headers: {
  625. 'Content-Type': 'application/json'
  626. },
  627. body: JSON.stringify({
  628. req:
  629. {
  630. url: wwConfig.url,
  631. extra: {
  632. header: {
  633. "User-Agent": wwConfig.ua,
  634. }
  635. }
  636. },
  637. opt: {
  638. extra: {
  639. connections: 256,
  640. }
  641. }
  642. }),
  643. }).then((resp) => resp.json())
  644. .then((res) => {
  645. layer.confirm(`请打开 Gopeed 查看 <span style="color:rgba(5,150,105,1);">${item.server_filename}</span> 是否开始下载?未下载成功,先设置IDM/NDM User-Agent:<code>` + wwConfig.ua + `</code>,再复制直链下载!`,
  646. {
  647. btn: ['已下载,关闭弹窗', '未下载,复制直链'],
  648. closeBtn: 0,
  649. }, function (index) {
  650. layer.close(index);
  651. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  652. }, function () {
  653. GM_setClipboard(wwConfig.url, "text");
  654. layer.msg(`${item.server_filename} 的直链复制成功!`);
  655. $('#parseWxBtn').html('<p>发送到Gopeed</p>');
  656. });
  657. }).catch(e => {
  658. })
  659. }
  660. setInterval(() => {
  661. GM_xmlhttpRequest({
  662. method: 'get',
  663. url: wwConfig.goPeedTaskUrl + '?status=running',
  664. headers: {
  665. 'Content-Type': 'application/json',
  666. },
  667. onload: function (response) {
  668. const responseData = JSON.parse(response.responseText);
  669. const result = responseData.data.filter(e =>
  670. e.status === "running"
  671. ).filter((e) => e.progress.speed < 1048576).map(e => e.id);
  672. const ids = result.map((e) => {
  673. return `id=${e}`
  674. }).join('&')
  675. if (ids && ids.length) {
  676. GM_xmlhttpRequest({
  677. method: 'put',
  678. url: `${wwConfig.goPeedTaskUrl}/pause?${ids}`,
  679. headers: {
  680. 'Content-Type': 'application/json',
  681. },
  682. onload: function (response) {
  683. GM_xmlhttpRequest({
  684. method: 'put',
  685. url: `${wwConfig.goPeedTaskUrl}/continue?${ids}`,
  686. headers: {
  687. 'Content-Type': 'application/json',
  688. },
  689. onload: function (response) {
  690. }
  691. })
  692. }
  693. })
  694. }
  695. }
  696. })
  697. }, 15000)
  698.  
  699. })();