(改)网盘直链下载助手

一个基于 JavaScript 的网盘文件下载地址获取工具,支持 百度网盘/阿里云盘/天翼云盘/迅雷云盘/夸克网盘/移动网盘 六大网盘 | 基于【网盘直链下载助手】修改自6.2.7版本 | 开源 - 自用 - 去广 | 改界面 - 添功能 - 修Bug | 不仅能够精简网盘界面 还支持修改网盘界面主题颜色!

当前为 2024-08-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name (改)网盘直链下载助手
  3. // @namespace https://github.com/syhyz1990/baiduyun
  4. // @version 1.0.9.2
  5. // @author Hmjz100、油小猴
  6. // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4Ij48cGF0aCBkPSJNMTAzLjYgMTA3LjRjMy41LTIuMiA4LjktNi4xIDEzLjgtMTIuNXM3LjMtMTIuNSA4LjUtMTYuNWMuNS0xLjcgMi4yLTcuNSAyLjItMTQuNyAwLTEwLjEtMy4zLTI1LjEtMTUuNC0zNi44LTE0LjUtMTQtMzIuMS0xNC4zLTM1LjctMTQuMy04IDAtMTUuNyAxLjktMjIuNiA1LjJDNDQgMjMgMzUuNyAzMS40IDMwLjggNDEuN2MtMS4zIDIuOC00IDQuNy03LjEgNS00IC4zLTcuNSA0LjQtOC45IDkuNi0uNSAxLjktMS42IDMuNS0zLjEgNC43QzQuNCA2Ni44IDAgNzUuNyAwIDg1YzAgNi44IDIuMyAxMy4xIDYuMSAxOC4yIDUuNSA3LjQgMTQuMiAxMi4yIDI0IDEyLjJoNDcuMWM0LjQgMCAxMS0uNSAxOC4zLTMuNSAzLjItMS40IDUuOS0zIDguMS00LjV6IiBmaWxsPSIjQTA5OUYwIi8+PHBhdGggZD0iTTExOS44IDY0LjNjLjEtMTcuMS0xMC40LTI4LTEyLjUtMzAuMUM5NSAyMi4xIDc5LjkgMjEuOCA3Ni45IDIxLjhjLTE3LjYgMC0zMy4zIDEwLjUtMzkuOSAyNi43LS42IDEuMy0xLjggMi4zLTMuNCAyLjNoLS40Yy01LjggMC0xMC42IDQuOC0xMC42IDEwLjd2LjVjMCAxLjQtLjggMi42LTEuOSAzLjNDMTMuNCA2OSA4LjggNzYuOCA4LjggODVjMCAxMi4yIDkuOSAyMi4zIDIyLjIgMjIuM2g0NS4yYzMuNi0uMSAxNy42LS45IDI5LjYtMTIgMi45LTIuOCAxMy45LTEzLjcgMTQtMzF6IiBmaWxsPSIjNTc0QUI4Ii8+PHBhdGggZD0iTTExMC44IDU3LjRsLjIgMy4zYzAgMS4zLTEuMSAyLjQtMi4zIDIuNC0xLjMgMC0yLjMtMS4xLTIuMy0yLjRsLS4xLTIuOHYtLjNjMC0xLjIuOS0yLjIgMi4xLTIuM2guM2MuNyAwIDEuMy4zIDEuNy43LS4yLjEuMy41LjQgMS40em0tMy4zLTEwLjNjMCAxLjItMSAyLjMtMi4yIDIuM2gtLjFjLS44IDAtMS42LS41LTItMS4yLTQuNi04LjMtMTMuMy0xMy41LTIyLjgtMTMuNS0xLjIgMC0yLjMtMS0yLjMtMi4ydi0uMWMwLTEuMiAxLTIuMyAyLjItMi4zaC4xYTMwLjM3IDMwLjM3IDAgMCAxIDE1LjggNC40YzQuNiAyLjggOC40IDYuOCAxMS4xIDExLjUuMS4zLjIuNy4yIDEuMXpNODguMyA3My44TDczLjUgOTMuMmMtMS41IDEuOS0zLjUgMy4xLTUuNyAzLjVoLS4yYy0uNC4xLS44LjEtMS4yLjEtLjYgMC0xLjEtLjEtMS42LS4yLTIuMi0uNC00LjItMS43LTUuNi0zLjVMNDQuMyA3My45Yy0yLTIuNi0yLjUtNS40LTEuNC03LjcuMS0uMS4xLS4yLjItLjIgMS4yLTIgMy41LTMuMiA2LjQtMy4yaDYuNnYtNS43YzAtNi44IDQuNy0xMiAxMC45LTEyIDQuOCAwIDguNSAyLjYgMTAuMyA3LjIuNSAxLjMtLjIgMi43LTEuNSAzLjJzLTIuOC0uMS0zLjMtMS40Yy0xLjEtMi43LTIuOS00LTUuNS00LTMuNSAwLTYgMy02IDd2OC4xYzAgLjUtLjIgMS0uNiAxLjQtLjYuNy0xLjcgMS4xLTIuNiAxLjFoLTguNGMtMS4zIDAtMiAuNC0yLjEuNy0uMi40IDAgMS4zLjkgMi40TDYzLjEgOTBjLjkgMS4yIDIuMSAxLjggMy4zIDEuOHMyLjMtLjYgMy4xLTEuN2wxNC44LTE5LjNjLjktMS4xIDEuMS0yIC45LTIuNC0uMi0uMy0uOS0uNy0yLjEtLjdoLTcuNmMtLjkgMC0xLjctLjUtMi4xLTEuMi0uMy0uNC0uNC0uOC0uNC0xLjMgMC0xLjQgMS4xLTIuNSAyLjUtMi41aDcuNmMzLjEgMCA1LjUgMS4zIDYuNiAzLjVsLjMuN2MuNyAyLjEuMSA0LjYtMS43IDYuOXoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=
  7. // @description 一个基于 JavaScript 的网盘文件下载地址获取工具,支持 百度网盘/阿里云盘/天翼云盘/迅雷云盘/夸克网盘/移动网盘 六大网盘 | 基于【网盘直链下载助手】修改自6.2.7版本 | 开源 - 自用 - 去广 | 改界面 - 添功能 - 修Bug | 不仅能够精简网盘界面 还支持修改网盘界面主题颜色!
  8. // @license AGPL-3.0-or-later
  9. // @homepage https://github.com/hmjz100/Online-disk-direct-link-download-assistant/
  10. // @supportURL https://github.com/hmjz100/Online-disk-direct-link-download-assistant/issues
  11. // @compatible Chrome
  12. // @compatible Edge
  13. // @compatible Firefox
  14. // @compatible Safari
  15. // @compatible Opera
  16. // @require https://unpkg.com/jquery@3.6.0/dist/jquery.min.js
  17. // @require https://unpkg.com/sweetalert2@11/dist/sweetalert2.min.js
  18. // @require https://unpkg.com/js-md5@0.7.3/build/md5.min.js
  19. // @resource Swal https://unpkg.com/sweetalert2@11/dist/sweetalert2.min.css
  20. // @resource SwalDark https://unpkg.com/@sweetalert2/theme-dark@5.0.15/dark.min.css
  21. // @match *://pan.baidu.com/disk/home*
  22. // @match *://yun.baidu.com/disk/home*
  23. // @match *://pan.baidu.com/disk/timeline*
  24. // @match *://yun.baidu.com/disk/timeline*
  25. // @match *://pan.baidu.com/disk/main*
  26. // @match *://yun.baidu.com/disk/main*
  27. // @match *://pan.baidu.com/youth/pan/main*
  28. // @match *://yun.baidu.com/youth/pan/main*
  29. // @match *://pan.baidu.com/disk/base*
  30. // @match *://yun.baidu.com/disk/base*
  31. // @match *://pan.baidu.com/s/*
  32. // @match *://pan.baidu.com/aipan/*
  33. // @match *://yun.baidu.com/s/*
  34. // @match *://yun.baidu.com/aipan/*
  35. // @match *://pan.baidu.com/share/*
  36. // @match *://yun.baidu.com/share/*
  37. // @match *://openapi.baidu.com/*
  38. // @match *://www.aliyundrive.com/s/*
  39. // @match *://www.aliyundrive.com/drive*
  40. // @match *://www.alipan.com/s/*
  41. // @match *://www.alipan.com/drive*
  42. // @match *://cloud.189.cn/web/*
  43. // @match *://pan.xunlei.com/*
  44. // @match *://pan.quark.cn/*
  45. // @match *://yun.139.com/*
  46. // @match *://caiyun.139.com/*
  47. // @match *://*.youxiaohou.com/*
  48. // @connect baidu.com
  49. // @connect baidupcs.com
  50. // @connect aliyundrive.com
  51. // @connect aliyundrive.net
  52. // @connect alipan.com
  53. // @connect alicloudccp.com
  54. // @connect 189.cn
  55. // @connect xunlei.com
  56. // @connect quark.cn
  57. // @connect youxiaohou.com
  58. // @connect greasyfork.org
  59. // @connect gcore.jsdelivr.net
  60. // @connect localhost
  61. // @connect *
  62. // @run-at document-idle
  63. // @grant unsafeWindow
  64. // @grant window.close
  65. // @grant GM_xmlhttpRequest
  66. // @grant GM_setClipboard
  67. // @grant GM_setValue
  68. // @grant GM_getValue
  69. // @grant GM_deleteValue
  70. // @grant GM_openInTab
  71. // @grant GM_info
  72. // @grant GM_registerMenuCommand
  73. // @grant GM_cookie
  74. // @grant GM_getResourceText
  75. // ==/UserScript==
  76.  
  77. (function Panlinker() {
  78. 'use strict';
  79.  
  80. /*
  81. 防止代码因其他原因被执行多次
  82. 这段代码出自 Via轻插件,作者谷花泰
  83. */
  84. const key = encodeURIComponent('(改)网盘直链下载助手:主代码');
  85. if (window[key]) return;
  86. window[key] = true;
  87.  
  88. /*
  89. 网盘直链下载助手
  90. 以下代码均改自 网盘直链下载助手,作者油小猴
  91. */
  92. /* 全局参数 */
  93. let pt = '', selectList = [], params = {}, mode = '', width = '', pan = {}, color = '',
  94. doc = $(document), progress = {}, request = {}, ins = {}, idm = {}, colored = false,
  95. scriptInfo = GM_info.script,
  96. realauthor = scriptInfo.author,
  97. realname = scriptInfo.name,
  98. realversion = scriptInfo.version,
  99. manageHandler = GM_info.scriptHandler,
  100. manageVersion = GM_info.version;
  101.  
  102.  
  103. /* 设置选项 */
  104. // Shell类型(用于curl下载)
  105. let terminalType = {
  106. wc: "Microsoft Windows 命令提示符",
  107. wp: "Microsoft Windows PowerShell",
  108. lt: "Linux 终端",
  109. ls: "Linux Shell",
  110. mt: "Apple MacOS 终端",
  111. };
  112.  
  113. // 使用油小猴服务器
  114. let monkeyServer = {
  115. v1: "使用 [用油小猴服务器 V1 接口]",
  116. v2: "使用 [用油小猴服务器 V2 接口]",
  117. no: "不使用 [用 jsdelivr 连接本项目 Github 仓库]"
  118. };
  119.  
  120. // 更换 百度网盘新界面/阿里云盘/迅雷云盘/移动云盘 主题颜色
  121. let assistantTheme = {
  122. yes: "更换主题颜色",
  123. no: "不更换主题颜色"
  124. };
  125.  
  126. /* Sweet Alert 2 */
  127. // 自定义元素 Class 名(于 showMainDialog() 中)
  128. let customClass = {
  129. popup: 'pl-popup',
  130. header: 'pl-header',
  131. title: 'pl-title',
  132. closeButton: 'pl-close',
  133. content: 'pl-content',
  134. input: 'pl-input',
  135. footer: 'pl-footer'
  136. };
  137.  
  138. // Toast 提示配置
  139. let toast = Swal.mixin({
  140. toast: true,
  141. position: 'top-end',
  142. showConfirmButton: false,
  143. timer: 3500,
  144. timerProgressBar: true,
  145. showCloseButton: true,
  146. didOpen: function (toast) {
  147. toast.addEventListener('mouseenter', Swal.stopTimer);
  148. toast.addEventListener('mouseleave', Swal.resumeTimer);
  149. }
  150. });
  151.  
  152. // Toast 简易调用
  153. let message = {
  154. success: function (text) {
  155. toast.fire({ title: text, icon: 'success' });
  156. },
  157. error: function (text) {
  158. toast.fire({ title: text, icon: 'error' });
  159. },
  160. warning: function (text) {
  161. toast.fire({ title: text, icon: 'warning' });
  162. },
  163. info: function (text) {
  164. toast.fire({ title: text, icon: 'info' });
  165. },
  166. question: function (text) {
  167. toast.fire({ title: text, icon: 'question' });
  168. }
  169. };
  170.  
  171. /* 基础函数 */
  172. let base = {
  173. // 创建 GreaseMonkey 菜单
  174. registerMenuCommand() {
  175. GM_registerMenuCommand('⚙️ 设置', function () {
  176. base.showSetting();
  177. });
  178. GM_registerMenuCommand('📃 更新', function () {
  179. base.showUpdateLog();
  180. });
  181. GM_registerMenuCommand('🛠️ 调试', function () {
  182. base.showDebug();
  183. });
  184. },
  185.  
  186. // 取消注册
  187. unRegisterInit(value) {
  188. console.log("【(改)网盘直链下载助手】\n正在注入设置项目...");
  189. message.warning("正在注入设置项目...");
  190. base.setValue('setting_init_code', value);
  191. base.setValue('license', value);
  192. history.go(0)
  193. },
  194.  
  195. /*-- 对象类型判断
  196. 示例:
  197. isType([]) // 输出"array"
  198. isType(123) // 输出"number"
  199. isType(null) // 输出"null"
  200. isType(new Date()) // 输出"date"
  201. */
  202. isType(obj) {
  203. return Object.prototype.toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase();
  204. },
  205.  
  206.  
  207. // 获取本地保存的数值(仅用于 Greasemonkey)
  208. getValue(name) {
  209. return GM_getValue(name);
  210. },
  211.  
  212. // 增改本地保存的数值(仅用于 Greasemonkey)
  213. setValue(name, value) {
  214. GM_setValue(name, value);
  215. },
  216.  
  217. // 删除本地保存的数值(仅用于 Greasemonkey)
  218. deleteValue(name) {
  219. GM_deleteValue(name);
  220. },
  221.  
  222. // 获取本地保存的数值
  223. getStorage(key) {
  224. try {
  225. return JSON.parse(localStorage.getItem(key));
  226. } catch (e) {
  227. return localStorage.getItem(key);
  228. }
  229. },
  230.  
  231. // 修改本地保存的数值
  232. setStorage(key, value) {
  233. if (this.isType(value) === 'object' || this.isType(value) === 'array') {
  234. return localStorage.setItem(key, JSON.stringify(value));
  235. }
  236. return localStorage.setItem(key, value);
  237. },
  238.  
  239. // 设置剪贴板
  240. setClipboard(text) {
  241. GM_setClipboard(text, 'text');
  242. },
  243.  
  244. // 加密成base64(先转换成URL编码)
  245. encode(str) {
  246. return btoa(unescape(encodeURIComponent(str)));
  247. },
  248.  
  249. // 从base64解密
  250. decode(str) {
  251. return decodeURIComponent(escape(atob(str)));
  252. },
  253.  
  254. // 数字补零
  255. repairTimer(i) {
  256. if (i >= 0 && i <= 9) {
  257. return "0" + i;
  258. } else {
  259. return i;
  260. }
  261. },
  262.  
  263. // 接受文件名并返回大写扩展名
  264. getExtension(name) {
  265. const reg = /(?!\.)\w+$/;
  266. if (reg.test(name)) {
  267. let match = name.match(reg);
  268. return match[0].toUpperCase();
  269. }
  270. return '';
  271. },
  272.  
  273. // 文件大小转换(以字节为单位)
  274. sizeFormat(value) {
  275. if (value === +value) {
  276. let unit = ["字节(B)", "千字节(KB)", "兆字节(MB)", "吉字节(GB)", "太字节(TB)", "拍字节(PB)", "艾字节(EB)", "泽字节(ZB)", "尧字节(YB)"];
  277. if (value === 0) {
  278. return "0字节(B)";
  279. } else {
  280. let index = Math.floor(Math.log(value) / Math.log(1024));
  281. let size = value / Math.pow(1024, index);
  282. size = size.toFixed(1);
  283. return size + unit[index];
  284. }
  285. }
  286. return '';
  287. },
  288.  
  289. // 根据数组中的每个文件名进行排序,使用 localeCompare 方法来比较中文字符串的顺序。
  290. sortByName(arr) {
  291. const handle = function () {
  292. return (a, b) => {
  293. const p1 = a.filename ? a.filename : a.server_filename;
  294. const p2 = b.filename ? b.filename : b.server_filename;
  295. return p1.localeCompare(p2, "zh-CN");
  296. };
  297. };
  298. arr.sort(handle());
  299. },
  300.  
  301. // 替换特殊字符为下划线
  302. fixFilename(name) {
  303. let replace = /[!?&|`"'*\/:<>\\]/g
  304. return name.replace(replace, '_');
  305. },
  306.  
  307. // 传递 Document Cookie
  308. getCookie(name) {
  309. let cname = name + "=";
  310. let ca = document.cookie.split(';');
  311. for (let i = 0; i < ca.length; i++) {
  312. let c = ca[i].trim();
  313. if (c.indexOf(cname) == 0) return c.substring(cname.length, c.length);
  314. }
  315. return "";
  316. },
  317.  
  318. // 接受Blob对象和文件名,然后创建临时链接指向blob对象,之后创建a标签指向临时链接和设置文件名,最后模拟点击a标签实现下载和释放临时链接
  319. blobDownload(blob, filename) {
  320. if (blob instanceof Blob) {
  321. const url = URL.createObjectURL(blob);
  322. const a = document.createElement('a');
  323. a.href = url;
  324. a.download = filename;
  325. a.click();
  326. URL.revokeObjectURL(url);
  327. }
  328. },
  329.  
  330. /* 请求 */
  331. // 使用 Post 发送请求
  332. post(url, data, headers, type, maxRetries = 3, currentRetry = 0) {
  333. if (this.isType(data) === 'object') {
  334. data = JSON.stringify(data);
  335. }
  336. return new Promise((resolve, reject) => {
  337. const sendRequest = function () {
  338. GM_xmlhttpRequest({
  339. method: "POST", url, headers, data,
  340. responseType: type || 'json',
  341. onload: function (res) {
  342. // 尝试格式化请求结果以方便调试
  343. if (res.response) {
  344. try {
  345. res.decodedResponse = JSON.parse(res.response);
  346. } catch (e) { }
  347. try {
  348. res.decodedResponse = JSON.parse(base.decode(res.response));
  349. } catch (e) { }
  350. }
  351. if (res.responseText) {
  352. try {
  353. res.decodedResponseText = JSON.parse(res.responseText);
  354. } catch (e) { }
  355. try {
  356. res.decodedResponseText = JSON.parse(base.decode(res.responseText));
  357. } catch (e) { }
  358. }
  359. console.log('【(改)网盘直链下载助手】Post\n请求地址:' + url + '\n请求头部:' + JSON.stringify(headers) + '\n请求数据:' + JSON.stringify(data) + '\n请求结果:', res);
  360. type === 'blob' ? resolve(res) : resolve(res.response || res.responseText);
  361. },
  362. onerror: function (err) {
  363. if (currentRetry < maxRetries) {
  364. currentRetry++;
  365. console.error(`【(改)网盘直链下载助手】Post\n请求出现错误,可能是网络问题\n5秒后将重试 (错误次数:${currentRetry}/${maxRetries})...`, err);
  366. setTimeout(function () {
  367. console.log(`【(改)网盘直链下载助手】Post\n重新尝试请求...`);
  368. sendRequest(); // 重新发送请求
  369. }, 5000)
  370. } else {
  371. reject('【(改)网盘直链下载助手】Post\n请求出现错误,可能是网络问题\n无法继续请求,达到最大错误次数。', err); // 达到最大重试次数,拒绝 Promise
  372. }
  373. },
  374. });
  375. };
  376. sendRequest(); // 初始请求
  377. });
  378. },
  379.  
  380. // 使用 Get 发送请求
  381. get(url, headers, type, extra, maxRetries = 3, currentRetry = 0) {
  382. return new Promise((resolve, reject) => {
  383. const sendRequest = function () {
  384. let requestObj = GM_xmlhttpRequest({
  385. method: "GET", url, headers,
  386. responseType: type || 'json',
  387. onload: function (res) {
  388. if (res.status === 204) {
  389. console.log('【(改)网盘直链下载助手】Get\n\x1B[31m该请求已被某个下载工具捕获。\x1B[0m\n请求地址:' + url + '\n请求头部:' + JSON.stringify(headers) + '\n请求结果:', res);
  390. requestObj.abort();
  391. idm[extra.index] = true;
  392. }
  393. if (type === 'blob') {
  394. console.log('【(改)网盘直链下载助手】Get Blob\n请求地址:' + url + '\n请求头部:' + JSON.stringify(headers) + '\n请求结果:', res);
  395. res.status === 200 && base.blobDownload(res.response, extra.filename);
  396. resolve(res);
  397. } else {
  398. // 尝试格式化请求结果以方便调试
  399. if (res.response) {
  400. try {
  401. res.decodedResponse = JSON.parse(res.response);
  402. } catch (e) { }
  403. try {
  404. res.decodedResponse = JSON.parse(base.decode(res.response));
  405. } catch (e) { }
  406. }
  407. if (res.responseText) {
  408. try {
  409. res.decodedResponseText = JSON.parse(res.responseText);
  410. } catch (e) { }
  411. try {
  412. res.decodedResponseText = JSON.parse(base.decode(res.responseText));
  413. } catch (e) { }
  414. }
  415. console.log('【(改)网盘直链下载助手】Get\n请求地址:' + url + '\n请求头部:' + JSON.stringify(headers) + '\n请求结果:', res);
  416. resolve(res.response || res.responseText);
  417. }
  418. },
  419. onprogress: function (res) {
  420. if (extra && extra.filename && extra.index) {
  421. res.total > 0 ? progress[extra.index] = (res.loaded * 100 / res.total).toFixed(2) : progress[extra.index] = 0.00;
  422. }
  423. },
  424. onloadstart() {
  425. console.log('【(改)网盘直链下载助手】Get\n请求地址:' + url + '\n请求头部:' + JSON.stringify(headers));
  426. extra && extra.filename && extra.index && (request[extra.index] = requestObj);
  427. },
  428. onerror: function (err) {
  429. if (currentRetry < maxRetries) {
  430. currentRetry++;
  431. console.error(`【(改)网盘直链下载助手】Get\n请求出现错误,可能是网络问题\n5秒后将重试 (错误次数:${currentRetry}/${maxRetries})...`, err);
  432. setTimeout(function () {
  433. console.log(`【(改)网盘直链下载助手】Get\n重新尝试请求...`);
  434. sendRequest(); // 重新发送请求
  435. }, 5000)
  436. } else {
  437. reject('【(改)网盘直链下载助手】Get\n请求出现错误,可能是网络问题\n无法继续请求,达到最大错误次数。', err); // 达到最大重试次数,拒绝 Promise
  438. }
  439. },
  440. });
  441. };
  442.  
  443. sendRequest(); // 初始请求
  444. });
  445. },
  446.  
  447. // 使用 Get 发送请求获取跳转后的链接
  448. getFinalUrl(url, headers, maxRetries = 3, currentRetry = 0) {
  449. return new Promise((resolve, reject) => {
  450. const sendRequest = function () {
  451. let requestObj = GM_xmlhttpRequest({
  452. method: "GET", url, headers,
  453. onload: function (res) {
  454. console.log('【(改)网盘直链下载助手】Get FinalUrl\n请求地址:' + url + '\n请求头部:' + JSON.stringify(headers) + '\n返回结果:', res);
  455. resolve(res.finalUrl)
  456. },
  457. onerror: function (err) {
  458. if (currentRetry < maxRetries) {
  459. currentRetry++;
  460. console.error(`【(改)网盘直链下载助手】Get FinalUrl\n请求出现错误,可能是网络问题\n5秒后将重试 (错误次数:${currentRetry}/${maxRetries})...`);
  461. setTimeout(function () {
  462. console.log(`【(改)网盘直链下载助手】Get FinalUrl\n重新尝试请求...`);
  463. sendRequest(); // 重新发送请求
  464. }, 5000)
  465. } else {
  466. reject('【(改)网盘直链下载助手】Get FinalUrl\n请求出现错误,可能是网络问题\n无法继续请求,达到最大错误次数。', err); // 达到最大重试次数,拒绝 Promise
  467. }
  468. },
  469. });
  470. };
  471.  
  472. sendRequest(); // 初始请求
  473. });
  474. },
  475.  
  476. // RPC测试
  477. async rpcTest(domain, port, path, token) {
  478. return new Promise((resolve, reject) => {
  479. let rpc = { domain, port, path, token };
  480. let url = `${rpc.domain}:${rpc.port}${rpc.path}`;
  481. let rpcData = {
  482. id: new Date().getTime(),
  483. jsonrpc: '2.0',
  484. method: 'system.listMethods',
  485. params: [`token:${rpc.token}`],
  486. };
  487. GM_xmlhttpRequest({
  488. method: "POST", url, headers: {}, data: JSON.stringify(rpcData),
  489. responseType: 'json',
  490. onload: function (res) {
  491. console.log('【(改)网盘直链下载助手】Post RPCTest\n请求地址:' + url + '\n请求结果:', res);
  492. if (res.response) {
  493. resolve("success");
  494. } else {
  495. resolve("fail");
  496. }
  497. },
  498. onerror: function (err) {
  499. console.error('【(改)网盘直链下载助手】Post RPCTest\n请求失败', err);
  500. resolve("fail");
  501. },
  502. });
  503. });
  504. },
  505.  
  506. // 将对象转换为 URL 加密
  507. stringify(obj) {
  508. let str = '';
  509. for (var key in obj) {
  510. if (obj.hasOwnProperty(key)) {
  511. var value = obj[key];
  512. if (Array.isArray(value)) {
  513. for (var i = 0; i < value.length; i++) {
  514. str += encodeURIComponent(key) + '=' + encodeURIComponent(value[i]) + '&';
  515. }
  516. } else {
  517. str += encodeURIComponent(key) + '=' + encodeURIComponent(value) + '&';
  518. }
  519. }
  520. }
  521. return str.slice(0, -1); // 去掉末尾的 "&"
  522. },
  523.  
  524. // 动态添加样式
  525. addStyle(id, tag, css, element, position) {
  526. tag = tag || 'style';
  527. element = element || 'body';
  528. let styleDom = document.getElementById(id);
  529. if (styleDom) styleDom.remove();
  530. let style = document.createElement(tag);
  531. style.rel = 'stylesheet';
  532. style.id = id;
  533. tag === 'style' ? style.innerHTML = css : style.href = css;
  534. if (position === "before") {
  535. $(element).prepend($(style));
  536. } else {
  537. $(element).append($(style));
  538. }
  539. },
  540.  
  541. hexToRgba(hex) {
  542. // 去掉 # 号
  543. hex = hex.replace(/^#/, '');
  544. // 如果是四位十六进制颜色值,转换为八位
  545. if (hex.length === 4) {
  546. hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
  547. }
  548. // 解析 RGB 分量
  549. var r = parseInt(hex.substring(0, 2), 16);
  550. var g = parseInt(hex.substring(2, 4), 16);
  551. var b = parseInt(hex.substring(4, 6), 16);
  552. var a = '';
  553. // 如果是八位十六进制颜色值,解析 alpha 通道
  554. if (hex.length === 8) {
  555. var a = 1;
  556. a = parseInt(hex.substring(6, 8), 16) / 255; // 将 alpha 值转换为 0 到 1 之间的小数
  557. a = ',' + a
  558. }
  559. // 返回 rgba 格式字符串
  560. return r + ', ' + g + ', ' + b + a;
  561. },
  562.  
  563. replaceColors(cssText, baseURI, type, colorMap) {
  564. if (!cssText) return '';
  565. var colorList = ['#09AAFF', '#cc3235', '#518c17', '#ed944b', '#f969a5', '#bca280', '#574AB8', '#b673ab', '#1d2327', '#18a497', '#637dff', '#0d53ff', '#3181f9', '#f8d800', '#0396ff', '#32ccbc', '#f6416c', '#2271b1', '#59524c', '#ff679a', '#f44236', '#fec107', '#8bc24a', '#2594ed', '#9c28b1']
  566. colorList.forEach(function (oldColor) {
  567. cssText = cssText.replace(new RegExp(base.hexToRgba(oldColor), 'ig'), base.hexToRgba(color));
  568. cssText = cssText.replace(new RegExp(oldColor, 'ig'), color);
  569. });
  570. if (type === 'other') {
  571. // 遍历颜色映射数组,将旧颜色替换为新颜色,并添加过渡效果
  572. colorMap.forEach(function (colorPair) {
  573. var oldColor = colorPair[0];
  574. var newColor = colorPair[1];
  575. // 判断新颜色是否为 color
  576. cssText = cssText.replace(new RegExp(oldColor, 'ig'), newColor);
  577. });
  578. return cssText;
  579. }
  580. if (colorMap) {
  581. // 遍历颜色映射数组,将旧颜色替换为新颜色,并添加过渡效果
  582. colorMap.forEach(function (colorPair) {
  583. var oldColor = colorPair[0];
  584. var newColor = colorPair[1];
  585. // 判断新颜色是否为 color
  586. if (oldColor.includes("#")) {
  587. cssText = cssText.replace(new RegExp(oldColor + '(.*?)}', 'ig'), newColor + '$1; ' + 'transition: all 0.1s ease;}');
  588. } else {
  589. cssText = cssText.replace(new RegExp(oldColor, 'ig'), newColor);
  590. }
  591. });
  592. };
  593. if (baseURI) {
  594. // 替换相对路径资源为绝对路径
  595. cssText = cssText.replace(/url\((?!['"]?(?:data|https?):)['"]?([^'"\)]*)['"]?\)/ig, function (match, p1) {
  596. // 如果URL是相对路径,则将其转换为绝对路径
  597. var absoluteURL = new URL(p1, baseURI).href;
  598. return 'url(' + absoluteURL + ')';
  599. });
  600. };
  601. return cssText;
  602. },
  603.  
  604. setColors(colorMap, type) {
  605. let cssText
  606. document.querySelectorAll('link[rel="stylesheet"]').forEach(function (tag) {
  607. if (!tag.parentElement) return;
  608. // 对于link标签,异步获取其CSS内容
  609. fetch(tag.href)
  610. .then(response => response.text())
  611. .then(responseText => {
  612. let id = 'Panlinker-ColorUI-' + tag.href
  613. // 替换颜色并添加样式
  614. cssText = base.replaceColors(responseText, tag.href, type, colorMap);
  615. if (responseText === base.replaceColors(responseText, '', type, colorMap)) return;
  616. let newStyle = document.createElement('style');
  617. newStyle.id = id;
  618. newStyle.textContent = responseText;
  619. if (location.pathname.includes("youth/pan")) {
  620. base.addStyle(id, 'style', cssText, 'body', "before");
  621. tag.remove()
  622. } else {
  623. base.addStyle(id, 'style', cssText, tag.parentElement.tagName || 'body');
  624. }
  625. console.log(`【(改)网盘直链下载助手】UI\n修改 <link> 元素 <style> 元素 样式\n元素:`, tag, `\n样式:`, newStyle);
  626. });
  627. })
  628. document.querySelectorAll('[id^="Panlinker-ColorUI-"]').forEach(function (tag) {
  629. if (!tag.parentElement) return;
  630. let id = tag.id;
  631. let parent = tag.parentElement;
  632. let element = parent.tagName || 'head';
  633. // 替换颜色并添加样式
  634. if (
  635. tag.innerText === base.replaceColors(tag.innerText, '', type, colorMap)
  636. ) return;
  637. cssText = base.replaceColors(tag.innerText, '', type, colorMap);
  638. let newStyle = document.createElement('style');
  639. newStyle.id = id;
  640. newStyle.textContent = cssText;
  641. base.addStyle(id, 'style', cssText, element);
  642. console.log(`【(改)网盘直链下载助手】UI\n修改 Panlinker-ColorUI <style> 元素 样式\n元素:`, tag, `\n样式:`, newStyle);
  643. });
  644. let count = 0;
  645. if (!colored) {
  646. document.querySelectorAll('style').forEach(function (tag) {
  647. if (!tag.parentElement) return;
  648. let id = tag.id;
  649. let parent = tag.parentElement;
  650. let element = parent.tagName || 'head';
  651. // 替换颜色并添加样式
  652. if (
  653. id.includes('Panlinker-UI') ||
  654. id.includes('Panlinker-ColorUI') ||
  655. id.includes('Panlinker-SweetAlert2') ||
  656. id.includes('swal-pub') ||
  657. tag.innerText === base.replaceColors(tag.innerText, '', type, colorMap)
  658. ) return;
  659. id = id ? id : `Panlinker-ColorUI-${count++}`
  660. cssText = base.replaceColors(tag.innerText, '', type, colorMap);
  661. let newStyle = document.createElement('style');
  662. newStyle.id = id;
  663. newStyle.textContent = cssText;
  664. base.addStyle(id, 'style', cssText, element);
  665. console.log(`【(改)网盘直链下载助手】UI\n修改 <style> 元素 样式\n元素:`, tag, `\n样式:`, newStyle);
  666. });
  667. colored = true;
  668. }
  669. },
  670.  
  671. // 延迟
  672. sleep(time) {
  673. return new Promise(resolve => setTimeout(resolve, time));
  674. },
  675.  
  676. // 获取大版本
  677. getMajorVersion(version) {
  678. const [major] = (version || '').split('.');
  679. return /^\d+$/.test(major) ? major : null;
  680. },
  681.  
  682. // 查找 React 组件实例
  683. findReact(dom, traverseUp = 0) {
  684. const key = Object.keys(dom).find(key => {
  685. return key.startsWith("__reactFiber$")
  686. || key.startsWith("__reactInternalInstance$");
  687. });
  688. const domFiber = dom[key];
  689. if (domFiber == null) return null;
  690.  
  691. if (domFiber._currentElement) {
  692. let compFiber = domFiber._currentElement._owner;
  693. for (let i = 0; i < traverseUp; i++) {
  694. compFiber = compFiber._currentElement._owner;
  695. }
  696. return compFiber._instance;
  697. }
  698.  
  699. const GetCompFiber = fiber => {
  700. let parentFiber = fiber.return;
  701. while (typeof parentFiber.type == "string") {
  702. parentFiber = parentFiber.return;
  703. }
  704. return parentFiber;
  705. };
  706. let compFiber = GetCompFiber(domFiber);
  707. for (let i = 0; i < traverseUp; i++) {
  708. compFiber = GetCompFiber(compFiber);
  709. }
  710. return compFiber.stateNode || compFiber;
  711. },
  712.  
  713. // 初始化设置项目
  714. initDefaultConfig() {
  715. let value = [
  716. // RPC 设置
  717. {
  718. name: 'setting_rpc_domain',
  719. value: 'http://localhost'
  720. }, {
  721. name: 'setting_rpc_port',
  722. value: '16800'
  723. }, {
  724. name: 'setting_rpc_path',
  725. value: '/jsonrpc'
  726. }, {
  727. name: 'setting_rpc_token',
  728. value: ''
  729. }, {
  730. name: 'setting_rpc_dir',
  731. value: 'D:\\Downloads\\'
  732. },
  733. // 杂项
  734. {
  735. name: 'setting_terminal_type',
  736. value: 'wc'
  737. }, {
  738. name: 'setting_theme_color',
  739. value: '#574AB8'
  740. }, {
  741. name: 'setting_init_code',
  742. value: ''
  743. }, {
  744. name: 'license',
  745. value: ''
  746. },
  747. // 额外
  748. {
  749. name: 'setting_youxiaohou_server',
  750. value: 'v2'
  751. }, {
  752. name: 'setting_baidu_theme',
  753. value: 'no'
  754. }, {
  755. name: 'setting_ali_theme',
  756. value: 'no'
  757. }, {
  758. name: 'setting_xunlei_theme',
  759. value: 'no'
  760. }, {
  761. name: 'setting_quark_theme',
  762. value: 'no'
  763. }, {
  764. name: 'setting_yidong_theme',
  765. value: 'no'
  766. }];
  767.  
  768. value.forEach(function (v) {
  769. // 没有对应的项目就添加上项目
  770. if (!base.getValue(v.name)) base.setValue(v.name, v.value);
  771. });
  772. },
  773.  
  774. // 设置界面
  775. showSetting() {
  776. let dom = '',
  777. btn = '',
  778. colorList = ['#09AAFF', '#cc3235', '#518c17', '#ed944b', '#f969a5', '#bca280', '#b673ab', '#574AB8', '#1d2327', '#18a497', '#637dff', '#0d53ff', '#3181f9', '#f8d800', '#0396ff', '#32ccbc', '#f6416c', '#2271b1', '#59524c', '#ff679a', '#f44236', '#fec107', '#8bc24a', '#2594ed', '#9c28b1'],
  779. colorNameList = ['度盘<br/>经典蓝', '度盘<br/>平安红', '度盘<br/>盎然绿', '度盘<br/>周年橙', '度盘<br/>幸会粉', '度盘<br/>午后棕', '度盘<br/>物语紫', '度盘<br/>星空紫', 'OpenAI<br/>默认黑', 'OpenAI<br/>默认青', '里度<br/>霞光紫', '夸克<br/>极简蓝', '移动<br/>彩云蓝', '果核<br/>柠檬黄', '果核<br/>默认蓝', '果核<br/>碧波绿', '果核<br/>玫瑰红', '文派<br/>默认蓝', '文派<br/>咖啡灰', '哔哩<br/>少女粉', '哔哩<br/>高能红', '哔哩<br/>咸蛋黄', '哔哩<br/>早苗绿', '哔哩<br/>宝石蓝', '哔哩<br/>罗兰紫'];
  780. dom += `<div style="text-align: center;">带星号的设置项目将在网页刷新后生效</div>`
  781. dom += `<label class="pl-setting-label"><div class="pl-label">RPC主机</div><input type="text" placeholder="主机地址,需带上http(s)://,但不需要写端口与路径" class="swal2-input pl-input listener-rpc-domain" value="${base.getValue('setting_rpc_domain')}"></label>`;
  782. dom += `<label class="pl-setting-label"><div class="pl-label">RPC端口</div><input type="text" placeholder="端口号,例如:Motrix下载器为16800" class="swal2-input pl-input listener-rpc-port" value="${base.getValue('setting_rpc_port')}"></label>`;
  783. dom += `<label class="pl-setting-label"><div class="pl-label">RPC路径</div><input type="text" placeholder="路径,默认为/jsonrpc" class="swal2-input pl-input listener-rpc-path" value="${base.getValue('setting_rpc_path')}"></label>`;
  784. dom += `<label class="pl-setting-label"><div class="pl-label">RPC密钥</div><input type="text" placeholder="无密钥无需填写" class="swal2-input pl-input listener-rpc-token" value="${base.getValue('setting_rpc_token')}"></label>`;
  785. dom += `<label class="pl-setting-label"><div class="pl-label">RPC保存</div><input type="text" placeholder="文件下载后保存路径,例如:D:\\Downloads\\" class="swal2-input pl-input listener-rpc-dir" value="${base.getValue('setting_rpc_dir')}"></label>`;
  786. dom += `<label class="pl-setting-label"><div class="pl-label">当前RPC</div><div><span id="pl-rpcDomain">${base.getValue('setting_rpc_domain')}</span>:<span id="pl-rpcPort">${base.getValue('setting_rpc_port')}</span><span id="pl-rpcPath">${base.getValue('setting_rpc_path')}</span><button type="button" class="pl-button-mini swal2-confirm swal2-styled listener-rpc-test">测试</button></div></label>`;
  787. dom += `<label class="pl-setting-label" style="padding-top:0;flex-direction:row-reverse;text-align:right;"><span><a href="https://www.youxiaohou.com/zh-cn/motrix.html#使用指南" target="_blank" class="pl-a" data-no-instant="1">RPC配置说明</a>,适用于RPC下载👆</span></label>`;
  788.  
  789. colorList.forEach((v, i) => {
  790. btn += `<div style="background: ${v};border: 1px solid ${v}" class="pl-color-box ${v === base.getValue('setting_theme_color') ? 'listener-color' : 'listener-color'}">
  791. <div data-color="${v}" class="pl-mask">${colorNameList[i]} ${v === base.getValue('setting_theme_color') ? '<span id="pl-thisColor">(当前)</span>' : ''}</div>
  792. </div>`;
  793. });
  794.  
  795.  
  796. dom += `<label class="pl-setting-label"><div class="pl-label">终端类型</div><select class="swal2-select pl-input listener-terminal">`;
  797. Object.keys(terminalType).forEach(k => {
  798. dom += `<option value="${k}" ${base.getValue('setting_terminal_type') === k ? 'selected' : ''}>${terminalType[k]}</option>`;
  799. });
  800. dom += `</select></label>`;
  801. dom += `<label class="pl-setting-label" style="padding-top:0;flex-direction:row-reverse;text-align:right;"><span><a href="https://www.youxiaohou.com/zh-cn/curl.html" target="_blank" class="pl-a" data-no-instant="1">cURL使用教程</a>,适用于cURL下载👆</span></label>`;
  802.  
  803.  
  804. dom += `<label class="pl-setting-label"><div class="pl-label">[百度网盘]<br/>更换界面为主题颜色*</div><select class="swal2-select pl-input listener-baidu-theme">`;
  805. Object.keys(assistantTheme).forEach(value => { dom += `<option value="${value}" ${base.getValue('setting_baidu_theme') === value ? 'selected' : ''}>${assistantTheme[value]}</option>`; });
  806. dom += `</select></label>`;
  807. dom += `<label class="pl-setting-label" style="padding-top:0;flex-direction:row-reverse;text-align:right;"><span>旧版页面会美化,新版页面则是更换主题色👆</span></label>`;
  808.  
  809. dom += `<label class="pl-setting-label"><div class="pl-label">[阿里云盘]<br/>更换界面为主题颜色*</div><select class="swal2-select pl-input listener-ali-theme">`;
  810. Object.keys(assistantTheme).forEach(value => { dom += `<option value="${value}" ${base.getValue('setting_ali_theme') === value ? 'selected' : ''}>${assistantTheme[value]}</option>`; });
  811. dom += `</select></label>`;
  812.  
  813. dom += `<label class="pl-setting-label"><div class="pl-label">[迅雷云盘]<br/>更换界面为主题颜色*</div><select class="swal2-select pl-input listener-xunlei-theme">`;
  814. Object.keys(assistantTheme).forEach(value => { dom += `<option value="${value}" ${base.getValue('setting_xunlei_theme') === value ? 'selected' : ''}>${assistantTheme[value]}</option>`; });
  815. dom += `</select></label>`;
  816.  
  817. dom += `<label class="pl-setting-label"><div class="pl-label">[夸克网盘]<br/>更换界面为主题颜色*</div><select class="swal2-select pl-input listener-quark-theme">`;
  818. Object.keys(assistantTheme).forEach(value => { dom += `<option value="${value}" ${base.getValue('setting_quark_theme') === value ? 'selected' : ''}>${assistantTheme[value]}</option>`; });
  819. dom += `</select></label>`;
  820.  
  821. dom += `<label class="pl-setting-label"><div class="pl-label">[移动云盘]<br/>更换界面为主题颜色*</div><select class="swal2-select pl-input listener-yidong-theme">`;
  822. Object.keys(assistantTheme).forEach(value => { dom += `<option value="${value}" ${base.getValue('setting_yidong_theme') === value ? 'selected' : ''}>${assistantTheme[value]}</option>`; });
  823. dom += `</select></label>`;
  824.  
  825. dom += `<label class="pl-setting-label"><div class="pl-label">使用油小猴服务器*</div><select class="swal2-select pl-input listener-youxiaohou-server">`;
  826. Object.keys(monkeyServer).forEach(value => { dom += `<option value="${value}" ${base.getValue('setting_youxiaohou_server') === value ? 'selected' : ''}>${monkeyServer[value]}</option>`; });
  827. dom += `</select></label>`;
  828.  
  829. dom += `<label class="pl-setting-label"><div class="pl-label">主题颜色</div> <div class="pl-color">${btn}</div></label>`;
  830.  
  831. dom += `<button type="button" style="margin-top: 30px;" class="pl-button-mini swal2-deny swal2-styled listener-register">熄灭已经点亮的按钮*</button>`
  832.  
  833. dom = '<div>' + dom + '</div>';
  834.  
  835. Swal.fire({
  836. title: '助手设置',
  837. html: dom,
  838. icon: 'info',
  839. iconHtml: '⚙',
  840. allowOutsideClick: false,
  841. showCloseButton: true,
  842. showConfirmButton: false,
  843. heightAuto: false,
  844. scrollbarPadding: false,
  845. footer: pan.footer,
  846. });
  847. doc.on('click', '.listener-register', async function (e) {
  848. base.unRegisterInit(111111);
  849. });
  850. doc.on('click', '.listener-rpc-test', async function (e) {
  851. e.preventDefault();
  852. let domain = base.getValue('setting_rpc_domain'),
  853. port = base.getValue('setting_rpc_port'),
  854. path = base.getValue('setting_rpc_path'),
  855. token = base.getValue('setting_rpc_token');
  856. if (e.target.innerHTML !== "测试") return;
  857. e.target.innerHTML = "等待";
  858. e.target.style.backgroundColor = base.getValue('setting_theme_color') + 'D0';
  859. let result = await base.rpcTest(domain, port, path, token);
  860. if (result === "success") {
  861. e.target.innerHTML = "成功";
  862. e.target.style.backgroundColor = "#52c41a";
  863. } else {
  864. e.target.innerHTML = "失败";
  865. e.target.style.backgroundColor = "#cb1616";
  866. }
  867. setTimeout(function () {
  868. e.target.innerHTML = "测试";
  869. e.target.style.backgroundColor = base.getValue('setting_theme_color');
  870. }, 3000)
  871. });
  872. doc.on('click', '.listener-color', async function (e) {
  873. if (e.target.dataset.color) {
  874. if (document.getElementById("pl-thisColor")) {
  875. document.getElementById("pl-thisColor").remove();
  876. }
  877. e.target.innerHTML += '<span id="pl-thisColor">(当前)</span>';
  878. base.setValue('setting_theme_color', e.target.dataset.color);
  879. base.addPanLinkerStyle();
  880. }
  881. });
  882. doc.on('input', '.listener-rpc-domain', async function (e) {
  883. base.setValue('setting_rpc_domain', e.target.value);
  884. document.getElementById("pl-rpcDomain").innerHTML = e.target.value;
  885. });
  886. doc.on('input', '.listener-rpc-port', async function (e) {
  887. base.setValue('setting_rpc_port', e.target.value);
  888. document.getElementById("pl-rpcPort").innerHTML = e.target.value;
  889. });
  890. doc.on('input', '.listener-rpc-path', async function (e) {
  891. base.setValue('setting_rpc_path', e.target.value);
  892. document.getElementById("pl-rpcPath").innerHTML = e.target.value;
  893. });
  894. doc.on('input', '.listener-rpc-token', async function (e) {
  895. base.setValue('setting_rpc_token', e.target.value);
  896. });
  897. doc.on('input', '.listener-rpc-dir', async function (e) {
  898. base.setValue('setting_rpc_dir', e.target.value);
  899. });
  900. doc.on('change', '.listener-terminal', async function (e) {
  901. base.setValue('setting_terminal_type', e.target.value);
  902. });
  903. doc.on('change', '.listener-baidu-theme', async function (e) {
  904. base.setValue('setting_baidu_theme', e.target.value);
  905. });
  906. doc.on('change', '.listener-ali-theme', async function (e) {
  907. base.setValue('setting_ali_theme', e.target.value);
  908. });
  909. doc.on('change', '.listener-xunlei-theme', async function (e) {
  910. base.setValue('setting_xunlei_theme', e.target.value);
  911. });
  912. doc.on('change', '.listener-quark-theme', async function (e) {
  913. base.setValue('setting_quark_theme', e.target.value);
  914. });
  915. doc.on('change', '.listener-yidong-theme', async function (e) {
  916. base.setValue('setting_yidong_theme', e.target.value);
  917. });
  918. doc.on('change', '.listener-youxiaohou-server', async function (e) {
  919. base.setValue('setting_youxiaohou_server', e.target.value);
  920. });
  921. },
  922.  
  923. // 调试信息界面
  924. showDebug() {
  925. let debugInfo = '';
  926. let server = '';
  927. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  928. server = `https://api.youxiaohou.com/config/?ver=${version}&a=${author}`;
  929. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  930. server = `https://api.youxiaohou.com/config/v2/?ver=${version}&a=${author}`;
  931. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  932. server = `https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`;
  933. } else {
  934. server = `https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`;
  935. base.setValue('setting_youxiaohou_server', 'v2');
  936. }
  937. debugInfo += `<span>以下内容均为脚本自检信息<br/>本页面仅作为调试使用<span>`;
  938. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[外置]<br/>管理器名称</div>${manageHandler ? manageHandler : "无法获取"}</label>`;
  939. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[外置]<br/>管理器版本</div>${manageVersion ? manageVersion : "无法获取"}</label>`;
  940. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[内置]<br/>信息服务器</div>[${base.getValue('setting_youxiaohou_server')}]${server ? server : "无法获取"}</label>`;
  941. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[内置]<br/>脚本名称</div>${realname ? realname : "无法获取"}</label>`;
  942. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[内置]<br/>脚本版本</div>${realversion ? realversion : "无法获取"}</label>`;
  943. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[内置]<br/>脚本作者</div>${realauthor ? realauthor : "无法获取"}</label>`;
  944. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[上报]<br/>脚本版本</div>${version ? version : "无法获取"}</label>`;
  945. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[上报]<br/>脚本作者</div>${author ? author : "无法获取"}</label>`;
  946. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>初始化暗号</div>${pan.num ? pan.num : "无法获取"}</label>`;
  947. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>初始化协议</div>${pan.license ? pan.license : "无法获取"}</label>`;
  948. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>UA代理</div>${pan.ua ? pan.ua : "此网站暂无"}</label>`;
  949. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>公众号码</div>${pan.img ? `${pan.img}<img src="${pan.img}"></img>` : "无法获取"}</label>`;
  950. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>万能助手</div>${pan.assistant ? pan.assistant : "此网站暂无"}</label>`;
  951. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>网盘CDN</div>${pan.mirror ? pan.mirror : "此网站暂无"}</label>`;
  952. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>RPC管理</div>${pan.d ? pan.d : "无法获取"}</label>`;
  953. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>IDM介绍</div>${pan.idm ? pan.idm : "此网盘暂无"}</label>`;
  954. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>提示文本</div><code>${JSON.stringify(pan.init) ? JSON.stringify(pan.init) : "无法获取"}</code></label>`;
  955. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>网盘接口</div><code>${JSON.stringify(pan.pcs) ? JSON.stringify(pan.pcs) : "无法获取"}</code></label>`;
  956. debugInfo += `<label class="pl-setting-label"><div class="pl-label">[下发]<br/>Toast页脚</div>${pan.footer ? pan.footer : "此网站暂无"}</label>`;
  957. debugInfo = '<div>' + debugInfo + '</div>';
  958.  
  959. Swal.fire({
  960. icon: 'info',
  961. title: '调试信息',
  962. html: debugInfo,
  963. allowOutsideClick: false,
  964. showCloseButton: true,
  965. heightAuto: false,
  966. scrollbarPadding: false,
  967. confirmButtonText: '关闭'
  968. });
  969. },
  970.  
  971. // 更新日志界面
  972. showUpdateLog() {
  973. Swal.fire({
  974. icon: 'info',
  975. title: '更新日志',
  976. html: `<div>
  977. V1.0.9.2<br/>1、修复使用API下载时有可能会导致IDM无限弹窗的Bug。<br/><br/>
  978. V1.0.9.1<br/>1、修复在百度网盘旧版下脚本无法删除元素的Bug。<br/><br/>
  979. V1.0.9<br/>1、跟进官方V6.2.7,修复因无法进行百度授权而导致获取直链报错 9019 Bug。<br/><br/>
  980. V1.0.8.9<br/>1、跟进官方V6.2.3,优化保存到网盘提示,修复阿里云盘、移动云盘失效的问题;<br/>2、优化修改网盘主题的代码,减少对页面的破坏。<br/><br/>
  981. V1.0.8.8<br/>1、修复下载菜单字体过小的Bug。<br/><br/>
  982. V1.0.8.7<br/>1、修复在阿里云盘分享页面下点击“未点亮”按钮时没有任何反应的Bug;<br/>2、更新并优化网盘界面精简规则;<br/>3、支持更换 百度网盘、阿里云盘、迅雷云盘、夸克网盘、移动云盘 界面的主题颜色。<br/><br/>
  983. V1.0.8.6<br/>1、新增移动云盘会员中心页面,可在网盘中点击“会员中心”按钮查看(但无法使用第三方支付)。<br/><br/>
  984. V1.0.8.5<br/>1、跟进官方V6.1.6,修复迅雷网盘分享页面无法选中文件,修复移动云盘无法判断页面。<br/><br/>
  985. V1.0.8.4<br/>1、修复因重复绑定按钮而导致命令重复执行的Bug;<br/>2、优化调试信息界面排版;<br/>3、移除对百度网盘手机网页版的支持。<br/><br/>
  986. V1.0.8.3<br/>1、适配阿里云盘新域名alipan.com。<br/><br/>
  987. V1.0.8.2<br/>1、更换新图标。<br/><br/>
  988. V1.0.8.1<br/>1、修复因重复绑定按钮而导致RPC下载会发送多条下载请求的Bug;<br/>2、选择不使用油小猴服务器时,“用ghproxy连接Github仓库”更换为“用jsdelivr连接Github仓库”;<br/>3、跟进官方V6.1.4版本,修复移动网盘无法获取链接,支持阿里云盘新域名alipan.com。<br/><br/>
  989. V1.0.8<br/>1、修复迅雷网盘无法勾选文件。<br/><br/>
  990. V1.0.7.9<br/>1、更新精简网盘元素匹配规则,防止因通知横条而导致不能点到“API下载”以下的按钮。<br/><br/>
  991. V1.0.7.8<br/>1、跟进官方V6.1.2,加入V2接口。<br/>2、修复百度网盘下载时因为获取不到accessToken而一直转圈。<br/><br/>
  992. V1.0.7.7<br/>1、修复百度网盘的按钮会因为主题不同而被改变颜色的Bug;<br/>2、更新夸克网盘按钮与界面。<br/><br/>
  993. V1.0.7.6<br/>1、修复“注入”功能;<br/>2、黑暗模式支持随设置热切换。<br/><br/>
  994. V1.0.7.5<br/>1、修复阿里云盘下载逻辑;<br/>2、精简代码;<br/>3、支持深色模式;<br/>4、修改部分提示文本;<br/>5、修改部分CSS;<br/>6、设置可测试RPC连接。<br/><br/>
  995. V1.0.7.4<br/>1、优化下载逻辑;<br/>2、修复阿里云盘无法使用API下载。<br/><br/>
  996. V1.0.7.3<br/>1、如果出现网络请求错误时支持自动重新请求;<br/>2、可选择是否使用油小猴服务器。<br/><br/>
  997. V1.0.7.2<br/>1、修复使用RPC下载时会重复发送链接的Bug。<br/><br/>
  998. V1.0.7.1<br/>1、[实验功能,不影响正常使用]支持百度网盘手机网页版,勾选文件后可在顶栏找到“下载助手”按钮。<br/><br/>
  999. V1.0.7<br/>1、重构夸克网盘、阿里云盘按钮。<br/><br/>
  1000. V1.0.6.9<br/>1、下载窗口加入关闭按钮。<br/><br/>
  1001. V1.0.6.8<br/>1、修复夸克网盘按钮错位。<br/><br/>
  1002. V1.0.6.7<br/>1、将百度网盘界面修改为主题色,可在设置选择是否修改;<br/>2、增加主题色名称,更改部分内容颜色;<br/>3、移动云盘API下载支持批量复制;<br/>4、优化控制台输出结果;<br/>5、百度网盘API下载不使用IDM时可以显示剩余时间;<br/>6、“取消点亮按钮”按钮的位置现已移动到设置页面。<br/>7homo特有的彩蛋又回来力(喜)。<br/><br/>
  1003. V1.0.6.6<br/>1、修复暗号错误。<br/><br/>
  1004. V1.0.6.5<br/>1、修复即使输入正确暗号也不能成功点亮按钮的服务器错误。<br/><br/>
  1005. V1.0.6.4<br/>1、跟进官方V6.1.1版本,修复阿里云盘获取下载链接时的问题。<br/><br/>
  1006. V1.0.6.3<br/>1、照顾小屏幕用户,将始终显示复制全部链接的按钮;<br/>2、增加取消下载时的动画。<br/><br/>
  1007. V1.0.6.2<br/>1、修复部分界面错位,实现CSS内置;<br/>2、百度网盘界面将变得更加简洁。<br/><br/>
  1008. V1.0.6.1<br/>1、新增百度云盘API下载支持复制链接;<br/>2、为了照顾手机浏览器用户,增大项目之间间隙,新增隐藏IDM提示选项,可在助手设置中启用;<br/>3、修改CSS,界面会出现更多的主题色;<br/>4、支持在游小猴官网查看暗号;<br/>5、修复部分语法错误。<br/><br/>
  1009. V1.0.6<br/>1、修复了打开阿里云盘分享连接时因下载移动端广告导致只能点击API下载;<br/>2、跟进官方6.0.4版本,修复夸克网盘获取下载链接失效、支持移动云盘。<br/><br/>
  1010. V1.0.5.5<br/>1、感谢<a href="https://github.com/Night-stars-1">Night-stars-1</a>的帮助,修复因为原作者服务器导致的初始化暗号识别错误;<br/>2、修改一些文本以及提供给服务器的信息。<br/><br/>
  1011. V1.0.5.4<br/>1、小修小改css,让主题色出现在更多地方;<br/>2、修改下载链接获取失败的提示;<br/>3、增加更多的主题色,可在助手设置查看;<br/>4homo彩蛋被删去力(悲)。<br/><br/>
  1012. V1.0.5.3<br/>1、修啦修啦,阿里云盘可以摸到下载菜单了。<br/><br/>
  1013. V1.0.5.2<br/>1、增加脚本信息菜单(没有用);<br/>2、优化阿里云盘显示svg图片;<br/>3、修改弹窗按钮颜色。<br/><br/>
  1014. V1.0.5.1<br/>1、修复在切换按钮主题后夸克网盘不能正常显示按钮。<br/><br/>
  1015. V1.0.5<br/>1、跟进官方V5.0.4版本;<br/>2、小改动,照着官方版本更正文件名称检测;<br/>3、保留彩蛋,但必须舍弃官方暗号。<br/><br/>
  1016. V1.0.4<br/>大改!<br/>1、修复了原作者留下的夸克网盘切换文件夹就多一个“下载助手”按钮的大BUG;<br/>2、终于来了,在下载菜单增加“助手设置”“更新日志”按钮;<br/>【再也不用点进油猴管理再进设置了(保留油猴管理内设置)】<br/>3、修改阿里云盘和夸克网盘下载助手按钮样式;<br/>4、增加“取消点亮按钮”油猴菜单;<br/>5、修改部分css,使其与选择的主题更贴切。<br/><br/>
  1017. V1.0.3<br/>1、增加一个小彩蛋; 提示:<br/>homo(需在未点亮按钮状态触发)<br/>【需要重新恢复按钮为未点亮状态请进入 已安装脚本->编辑->开发者->重置到出厂->确定】<br/>2、修改/增加默认主题色。<br/><br/>
  1018. V1.0.2<br/>1、修改并加宽界面,调整部分css,使Sweetalert2界面更美观,更与原版相近;<br/>2、修改部分提示文字,使文字更容易复制。 <br/><br/>
  1019. V1.0.1<br/>1、去除更新提示;<br/>2、更新Sweetalert211版本;<br/>3、部分CDN节点更换为jsdelivr。<br/><br/>
  1020. V1.0.0<br/>1、增加“注入”功能(bushi);<br/>2、去除广告。
  1021. </div>`,
  1022. allowOutsideClick: false,
  1023. showCloseButton: false,
  1024. heightAuto: false,
  1025. scrollbarPadding: false,
  1026. confirmButtonText: '我已阅',
  1027. });
  1028. },
  1029.  
  1030. // 创建浮动标签
  1031. createTip() {
  1032. $('body').append('<div class="pl-tooltip"></div>');
  1033.  
  1034. doc.on('mouseenter mouseleave', '.listener-tip', function (e) {
  1035. if (e.type === 'mouseenter') {
  1036. let filename = e.currentTarget.innerText;
  1037. let size = e.currentTarget.dataset.size;
  1038. let tip = `${filename}<span style="margin-left: 10px;color: ${color}">${size}</span>`;
  1039. $(e.currentTarget).css({ opacity: '0.5' });
  1040. $('.pl-tooltip').html(tip).css({
  1041. 'left': e.pageX + 10 + 'px',
  1042. 'top': e.pageY - e.currentTarget.offsetTop > 14 ? e.pageY + 'px' : e.pageY + 20 + 'px'
  1043. }).show();
  1044. } else {
  1045. $(e.currentTarget).css({ opacity: '1' });
  1046. $('.pl-tooltip').hide(0);
  1047. }
  1048. });
  1049. },
  1050.  
  1051. // 创建加载弹窗
  1052. createLoading() {
  1053. return $('<div class="pl-loading"><div class="pl-loading-box"><div><div></div><div></div></div></div></div>');
  1054. },
  1055.  
  1056. // 创建下载用的隐藏 iframe
  1057. createDownloadIframe() {
  1058. let $div = $('<div style="padding:0;margin:0;display:block"></div>');
  1059. let $iframe = $('<iframe src="javascript:;" id="downloadIframe" style="display:none"></iframe>');
  1060. $div.append($iframe);
  1061. $('body').append($div);
  1062. },
  1063.  
  1064. // 获取镜像列表
  1065. getMirrorList(link, mirror, thread = 2) {
  1066. let host = new URL(link).host;
  1067. let mirrors = [];
  1068. for (let i = 0; i < mirror.length; i++) {
  1069. for (let j = 0; j < thread; j++) {
  1070. let item = link.replace(host, mirror[i]) + '&'.repeat(j);
  1071. mirrors.push(item);
  1072. }
  1073. }
  1074. return mirrors.join('\n');
  1075. },
  1076.  
  1077. // 监听元素出现并执行回调
  1078. listenElement(element, callback) {
  1079. let checkInterval = 1000; // 检查元素的间隔时间(毫秒)
  1080. let wasElementFound = false; // 用于跟踪元素是否之前已经找到
  1081.  
  1082. function checkElement() {
  1083. if (document.querySelector(element)) {
  1084. wasElementFound = true;
  1085. callback();
  1086. } else if (wasElementFound) {
  1087. wasElementFound = false; // 元素消失后重置标志
  1088. }
  1089.  
  1090. setTimeout(checkElement, checkInterval);
  1091. }
  1092. checkElement();
  1093. },
  1094.  
  1095. // 创建基础样式
  1096. addPanLinkerStyle() {
  1097. color = base.getValue('setting_theme_color');
  1098.  
  1099. let swalcss = `
  1100. .swal2-styled{transition: all 0.2s ease;}
  1101. .swal2-loader{display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;-webkit-animation:swal2-rotate-loading 1.5s linear 0s infinite normal;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:${color} transparent }
  1102. .swal2-styled.swal2-confirm{border:0;border-radius:.25em;background:initial;background-color:${color};color:#fff;font-size:1em}
  1103. .swal2-styled.swal2-confirm:hover{background-color:${color}90;}
  1104. .swal2-styled.swal2-confirm:focus{box-shadow:0 0 0 3px ${color}80 }
  1105. .swal2-styled.swal2-deny:hover{background-color:#dc374190;}
  1106. .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto;overflow:hidden;border-bottom-right-radius:5px;border-bottom-left-radius:5px}
  1107. .swal2-timer-progress-bar{width:100%;height:.25em;background:${color}33 }
  1108. .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:${color};color:#fff;line-height:2em;text-align:center}
  1109. .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:${color} }
  1110. .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:${color}}
  1111. .swal2-popup {padding:0 0 1.25em;flex-direction:column}
  1112. .swal2-close {position:absolute;top:1px;right:1px;transition: all 0.2s ease;}
  1113. div:where(.swal2-container) .swal2-html-container{margin: 1.3em 1.3em 0.3em;}
  1114. div:where(.swal2-container) button:where(.swal2-close):hover {color:${color};font-size:60px!important}
  1115. [class^="swal-"] {transition: all 0.2s ease;}
  1116. `;
  1117.  
  1118. // 先监听颜色方案变化 Panlinker-SweetAlert2-Default
  1119. window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
  1120. if (e.matches) {
  1121. // 切换到暗色主题
  1122. base.addStyle('swal-pub-style', 'style', GM_getResourceText('SwalDark'));
  1123. } else {
  1124. // 切换到浅色主题
  1125. base.addStyle('swal-pub-style', 'style', GM_getResourceText('Swal'));
  1126. }
  1127. base.addStyle('Panlinker-SweetAlert2-User', 'style', swalcss);
  1128. });
  1129. // 再修改主题 Panlinker-SweetAlert2-Default
  1130. if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  1131. // 切换到暗色主题
  1132. base.addStyle('swal-pub-style', 'style', GM_getResourceText('SwalDark'));
  1133. } else {
  1134. // 切换到浅色主题
  1135. base.addStyle('swal-pub-style', 'style', GM_getResourceText('Swal'));
  1136. }
  1137. base.addStyle('Panlinker-SweetAlert2-User', 'style', swalcss);
  1138.  
  1139. let uicss = `
  1140. ::-webkit-scrollbar {
  1141. width: 8px;
  1142. height: 8px;
  1143. transition: all 0.2s ease;
  1144. }
  1145.  
  1146. ::-webkit-scrollbar-track {
  1147. border-radius: 10px;
  1148. background: #fff;
  1149. }
  1150.  
  1151. ::-webkit-scrollbar-thumb,
  1152. ::-webkit-scrollbar-thumb:hover {
  1153. border-radius: 10px;
  1154. }
  1155.  
  1156. ::-webkit-scrollbar-thumb {
  1157. background-color: ${color}90 !important
  1158. }
  1159.  
  1160. ::-webkit-scrollbar-thumb:hover {
  1161. background-color: ${color}D0 !important
  1162. }
  1163.  
  1164. .swal2-popup {
  1165. font-size: 16px
  1166. }
  1167.  
  1168. .pl-a {
  1169. color: ${color};
  1170. }
  1171.  
  1172. .pl-a:hover {
  1173. color: ${color}90;
  1174. }
  1175.  
  1176. .pl-popup {
  1177. font-size: 12px;
  1178. width: 90%;
  1179. }
  1180.  
  1181. .pl-popup a {
  1182. color: ${color};
  1183. }
  1184.  
  1185. .pl-popup a:hover {
  1186. color: ${color}90;
  1187. }
  1188.  
  1189. .pl-header {
  1190. padding: 0;
  1191. align-items: flex-start;
  1192. border-bottom: 1px solid #eee;
  1193. margin: 0 0 10px;
  1194. padding: 0 0 5px;
  1195. }
  1196.  
  1197. .pl-title {
  1198. font-size: 16px;
  1199. line-height: 1;
  1200. white-space: nowrap;
  1201. text-overflow: ellipsis;
  1202. }
  1203.  
  1204. .pl-content {
  1205. padding: 0;
  1206. font-size: 12px;
  1207. }
  1208.  
  1209. .pl-main {
  1210. background-color:${color}15;
  1211. overflow: auto;
  1212. border-radius: 5px;
  1213. max-height:calc(${document.documentElement.clientHeight}px - 250px);
  1214. }
  1215.  
  1216. .pl-footer {
  1217. font-size: 15px;
  1218. margin-top: 10px;
  1219. padding-top: 5px;
  1220. color: #f56c6c;
  1221. text-align: center;
  1222. display: flex !important;
  1223. align-items: center;
  1224. justify-content: center;
  1225. }
  1226.  
  1227. .pl-item {
  1228. display: flex;
  1229. align-items: center;
  1230. line-height: 22px;
  1231. height: 50px;
  1232. background-color: ${color}30;
  1233. border-radius: 5px;
  1234. margin: 8px 6px;
  1235. }
  1236.  
  1237. .pl-item-name {
  1238. flex: 0 0 170px;
  1239. text-align: left;
  1240. margin: 6px;
  1241. overflow: hidden;
  1242. white-space: nowrap;
  1243. text-overflow: ellipsis;
  1244. cursor: default;
  1245. height: 30px;
  1246. }
  1247.  
  1248. .pl-item-link {
  1249. flex: 1;
  1250. text-align: left;
  1251. white-space: nowrap;
  1252. text-overflow: ellipsis;
  1253. cursor: pointer;
  1254. overflow: hidden;
  1255. }
  1256.  
  1257. .pl-item-btn {
  1258. background: ${color};
  1259. border-radius: 3px;
  1260. color: #ffffff;
  1261. cursor: pointer;
  1262. font-size: 12px;
  1263. outline: none;
  1264. display: flex;
  1265. align-items: center;
  1266. justify-content: center;
  1267. margin: 6px 6px;
  1268. padding: 0.625em 1.1em;
  1269. }
  1270.  
  1271. .pl-item-tip {
  1272. display: flex;
  1273. justify-content: space-between;
  1274. flex: 1;
  1275. }
  1276.  
  1277. .pl-back {
  1278. width: 70px;
  1279. background: #ddd;
  1280. border-radius: 3px;
  1281. cursor: pointer;
  1282. margin: 1px 6px;
  1283. color: #000;
  1284. }
  1285.  
  1286. .pl-ext {
  1287. display: inline-block;
  1288. width: 44px;
  1289. background: #999;
  1290. color: #fff;
  1291. height: 16px;
  1292. line-height: 16px;
  1293. font-size: 12px;
  1294. border-radius: 3px;
  1295. }
  1296.  
  1297. .pl-retry {
  1298. padding: 3px 10px;
  1299. background: #cc3235;
  1300. color: #fff;
  1301. border-radius: 3px;
  1302. cursor: pointer;
  1303. }
  1304.  
  1305. .pl-browserdownload {
  1306. padding: 3px 10px;
  1307. background: ${color};
  1308. color: #fff;
  1309. border-radius: 3px;
  1310. cursor: pointer;
  1311. }
  1312.  
  1313. .pl-item-progress {
  1314. display: flex;
  1315. flex: 1;
  1316. align-items: center
  1317. }
  1318.  
  1319. .pl-progress {
  1320. display: inline-block;
  1321. vertical-align: middle;
  1322. width: 100%;
  1323. box-sizing: border-box;
  1324. line-height: 1;
  1325. position: relative;
  1326. height: 15px;
  1327. flex: 1
  1328. }
  1329.  
  1330. .pl-progress-outer {
  1331. height: 15px;
  1332. border-radius: 100px;
  1333. background-color: #c1c1c1a1;
  1334. overflow: hidden;
  1335. position: relative;
  1336. vertical-align: middle;
  1337. }
  1338.  
  1339. .pl-progress-inner {
  1340. position: absolute;
  1341. left: 0;
  1342. top: 0;
  1343. background-color: ${color};
  1344. text-align: center;
  1345. border-radius: 100px;
  1346. line-height: 1;
  1347. white-space: nowrap;
  1348. transition: width .6s ease;
  1349. height: 15px
  1350. }
  1351.  
  1352. .pl-progress-inner-text {
  1353. display: inline-block;
  1354. vertical-align: middle;
  1355. color: #ffffff;
  1356. font-size: 12px;
  1357. margin: 0 5px;
  1358. height: 15px
  1359. }
  1360.  
  1361. .pl-progress-tip {
  1362. flex: 1;
  1363. text-align: right
  1364. }
  1365.  
  1366. .pl-progress-how {
  1367. flex: 0 0 100px;
  1368. background: #ddd;
  1369. border-radius: 3px;
  1370. margin-left: 10px;
  1371. cursor: pointer;
  1372. text-align: center;
  1373. color: #000;
  1374. }
  1375.  
  1376. .pl-progress-stop {
  1377. flex: 0 0 80px;
  1378. background: #cc3235;
  1379. cursor: pointer;
  1380. margin: 6px 6px 6px 10px;
  1381. font-size: 12px;
  1382. border: 0;
  1383. border-radius: 4px;
  1384. color: #ffffff;
  1385. outline: none;
  1386. display: flex;
  1387. align-items: center;
  1388. justify-content: center;
  1389. padding: 0.625em 1.1em;
  1390. }
  1391.  
  1392. .pl-progress-inner-text:after {
  1393. display: inline-block;
  1394. content: "";
  1395. height: 100%;
  1396. vertical-align: middle;
  1397. }
  1398.  
  1399. .pl-btn-primary {
  1400. background: ${color};
  1401. border: 0;
  1402. border-radius: 4px;
  1403. color: #ffffff;
  1404. cursor: pointer;
  1405. font-size: 12px;
  1406. outline: none;
  1407. display: flex;
  1408. align-items: center;
  1409. justify-content: center;
  1410. margin: 6px 6px;
  1411. padding: 0.625em 1.1em;
  1412. transition: 0.3s opacity;
  1413. }
  1414.  
  1415. .pl-btn-primary:hover {
  1416. opacity: 0.9;
  1417. transition: 0.3s opacity;
  1418. }
  1419.  
  1420. .pl-btn-success {
  1421. background: #55af28;
  1422. animation: easeOpacity 1.2s 2;
  1423. animation-fill-mode: forwards
  1424. }
  1425.  
  1426. .pl-btn-info {
  1427. background: #606266;
  1428. }
  1429.  
  1430. .pl-btn-warning {
  1431. background: #da9328;
  1432. }
  1433.  
  1434. .pl-btn-warning {
  1435. background: #da9328;
  1436. }
  1437.  
  1438. .pl-btn-danger {
  1439. background: #cc3235;
  1440. }
  1441.  
  1442. .pl-button-mini {
  1443. padding: 5px 10px;
  1444. }
  1445.  
  1446. .pl-dropdown-menu-item {
  1447. height: 30px;
  1448. display: flex;
  1449. align-items: center;
  1450. justify-content: center;
  1451. cursor: pointer;
  1452. color: ${color};
  1453. transition: all 0.2s ease;
  1454. }
  1455.  
  1456. .pl-dropdown-menu-item:hover {
  1457. background-color: ${color}15;
  1458. }
  1459.  
  1460. .pl-button-mode {
  1461. padding: 0px;
  1462. padding-left: 0px !important;
  1463. color: ${color} !important;
  1464. transition: all 0.2s ease;
  1465. }
  1466.  
  1467. .pl-button-mode:hover {
  1468. background-color: ${color}33 !important;
  1469. }
  1470.  
  1471. .pl-button,
  1472. .pl-dropdown-menu {
  1473. transition: all 0.2s ease;
  1474. }
  1475.  
  1476. .pl-button .pl-dropdown-menu {
  1477. display: none;
  1478. }
  1479.  
  1480. .pl-button:hover .pl-dropdown-menu {
  1481. display: block;
  1482. }
  1483.  
  1484. .pl-button-init {
  1485. opacity: 0.5;
  1486. animation: easeInitOpacity 1.2s 3;
  1487. animation-fill-mode: forwards
  1488. }
  1489.  
  1490. @keyframes easeInitOpacity {
  1491. from {
  1492. opacity: 0.5;
  1493. }
  1494.  
  1495. 50% {
  1496. opacity: 1
  1497. }
  1498.  
  1499. to {
  1500. opacity: 0.5;
  1501. }
  1502. }
  1503.  
  1504. @keyframes easeOpacity {
  1505. from {
  1506. opacity: 1;
  1507. }
  1508.  
  1509. 50% {
  1510. opacity: 0.35
  1511. }
  1512.  
  1513. to {
  1514. opacity: 1;
  1515. }
  1516. }
  1517.  
  1518. .baidu-button {
  1519. background: ${color} !important;
  1520. border-color: ${color} !important;
  1521. border: 1px solid ${color} !important;
  1522. display: inline-flex;
  1523. }
  1524.  
  1525. .baidu-button:hover {
  1526. background: ${color}b0 !important;
  1527. border-color: ${color} !important;
  1528. }
  1529.  
  1530. header[style="display: none;"]~#pl-button-link {
  1531. display: inline-block;
  1532. position: fixed;
  1533. top: 0.6em;
  1534. left: 65%;
  1535. z-index: 99999;
  1536. }
  1537.  
  1538. .ali-button {
  1539. background: ${color};
  1540. border: 0 solid transparent;
  1541. font-size: 14px;
  1542. margin-left: 20px;
  1543. padding: 8px 16px;
  1544. position: relative;
  1545. height: 32px;
  1546. border-radius: 100px;
  1547. display: flex;
  1548. align-items: center;
  1549. justify-content: center;
  1550. color: var(--basic_white);
  1551. cursor: pointer;
  1552. transition: all .3s ease;
  1553. }
  1554.  
  1555. .ali-button:hover {
  1556. background: ${color}D0
  1557. }
  1558.  
  1559. .ali-btn-icon {
  1560. vertical-align: -0.2em;
  1561. }
  1562.  
  1563. .tianyi-button {
  1564. margin-right: 20px;
  1565. padding: 4px 12px;
  1566. border-radius: 4px;
  1567. color: #fff;
  1568. font-size: 12px;
  1569. border: 1px solid ${color};
  1570. background: ${color};
  1571. cursor: pointer;
  1572. position: relative;
  1573. }
  1574.  
  1575. .tianyi-button:hover {
  1576. border-color: ${color}b0;
  1577. background: ${color}b0;
  1578. }
  1579.  
  1580. .yidong-button {
  1581. float: left;
  1582. position: relative;
  1583. margin: 20px 24px 20px 0;
  1584. width: 110px;
  1585. height: 36px;
  1586. background: ${color};
  1587. border-radius: 2px;
  1588. font-size: 14px;
  1589. color: #fff;
  1590. line-height: 39px;
  1591. text-align: center;
  1592. cursor: pointer;
  1593. }
  1594.  
  1595. .yidong-share-button {
  1596. display: inline-block;
  1597. position: relative;
  1598. font-size: 14px;
  1599. line-height: 36px;
  1600. height: 36px;
  1601. text-align: center;
  1602. color: #fff;
  1603. border: 1px solid ${color};
  1604. border-radius: 2px;
  1605. padding: 0 24px;
  1606. background: ${color};
  1607. }
  1608.  
  1609. .yidong-share-button:hover {
  1610. background: ${color}b0;
  1611. }
  1612.  
  1613. .yidong-button:hover {
  1614. background: ${color}b0;
  1615. }
  1616.  
  1617. .yidong-btn {
  1618. background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAGNQTFRFAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////mkUNoAAAACF0Uk5TAAbHPP9AMRtr9PwrV8zqXfmNgDODHTLD4iJxhGJJ8Z269m0aDgAAAMZJREFUeJzd0ssOgyAQBVDUK74rWq0PFP3/ryxqTMdGqJtuvGHD5CTDTGDs3nFc17kEPcC7BH3At/Tjvk5AYbBU+NcrwghL4uQDk3gtRSF1KWCCQEpghkd+3jp/ICNQoDANU0AQCJQmWAJ3h8+q3mFdvSywQdttsGvRWGAPLReoHXrbG6WWAzBoJ+3DaCnWI39NLbcvszvLeuTB2fYoqbNBNo7sGjzk31BhMsEJitxmiKk8zSQwE8gFjBGcNuCzOmdqPrib5A2JRQ7qK9g+hQAAAABJRU5ErkJggg==);
  1619. height: 20px;
  1620. line-height: 20px;
  1621. display: inline-block;
  1622. background-repeat: no-repeat;
  1623. background-size: 20px 20px;
  1624. text-indent: 25px;
  1625. }
  1626.  
  1627. .xunlei-button {
  1628. display: inline-flex;
  1629. align-items: center;
  1630. justify-content: center;
  1631. border: 0 solid transparent;
  1632. border-radius: 5px;
  1633. box-shadow: 0 0 0 0 transparent;
  1634. width: fit-content;
  1635. white-space: nowrap;
  1636. flex-shrink: 0;
  1637. font-size: 14px;
  1638. line-height: 1.5;
  1639. outline: 0;
  1640. touch-action: manipulation;
  1641. transition: background .3s ease, color .3s ease, border .3s ease, box-shadow .3s ease;
  1642. color: #fff;
  1643. background: ${color};
  1644. margin-left: 12px;
  1645. padding: 0px 12px;
  1646. position: relative;
  1647. cursor: pointer;
  1648. height: 36px;
  1649. }
  1650.  
  1651. .xunlei-button:hover {
  1652. background: ${color}b0;
  1653. }
  1654.  
  1655. .quark-button {
  1656. background: ${color} !important;
  1657. background-color:${color} !important;
  1658. }
  1659.  
  1660. .quark-button:hover {
  1661. background: ${color}b0 !important;
  1662. background-color:${color}b0 !important;
  1663. }
  1664.  
  1665. .quark-btn-icon {
  1666. width: 20px;
  1667. height: 20px;
  1668. vertical-align: -0.3em;
  1669. }
  1670.  
  1671. .element-clicked {
  1672. opacity: 0.5;
  1673. }
  1674.  
  1675. .pl-extra {
  1676. margin-top: 10px;
  1677. display: flex
  1678. }
  1679.  
  1680. .pl-extra button {
  1681. flex: 1
  1682. }
  1683.  
  1684. .pointer {
  1685. cursor: pointer
  1686. }
  1687.  
  1688. .pl-setting-label {
  1689. display: flex;
  1690. align-items: center;
  1691. justify-content: space-between;
  1692. padding-top: 10px;
  1693. }
  1694.  
  1695. .pl-label {
  1696. flex: 0 0 100px;
  1697. text-align: left;
  1698. }
  1699.  
  1700. .pl-input {
  1701. flex: 1;
  1702. padding: 8px 10px !important;
  1703. border: 1px solid #c2c2c2;
  1704. border-radius: 5px;
  1705. font-size: 14px !important;
  1706. min-width: 300px;
  1707. margin: 0;
  1708. darktheme
  1709. }
  1710.  
  1711. .init-input {
  1712. width: 400px;
  1713. margin: 1em 1em 3px;
  1714. font-size: 20px;
  1715. text-align: center;
  1716. font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
  1717. font-weight: 300;
  1718. }
  1719.  
  1720. .pl-color {
  1721. flex: 1;
  1722. display: flex;
  1723. flex-wrap: wrap
  1724. }
  1725.  
  1726. .pl-color-box {
  1727. width: 55px;
  1728. height: 55px;
  1729. margin: 10px 10px 0 0;
  1730. box-sizing: border-box;
  1731. border: 1px solid #fff;
  1732. cursor: pointer
  1733. }
  1734.  
  1735. .pl-mask {
  1736. width: 53px;
  1737. height: 53px;
  1738. opacity: 0;
  1739. transition: opacity 0.3s;
  1740. color: #fff;
  1741. font-size: 13px;
  1742. display: flex;
  1743. align-items: center;
  1744. justify-content: center;
  1745. flex-direction: column;
  1746. }
  1747.  
  1748. .pl-color-box:hover .pl-mask {
  1749. opacity: 1;
  1750. }
  1751.  
  1752. .pl-close:focus {
  1753. outline: 0;
  1754. box-shadow: none;
  1755. }
  1756.  
  1757. .tag-danger {
  1758. color: #cc3235;
  1759. margin: 0 5px;
  1760. }
  1761.  
  1762. .pl-tooltip {
  1763. position: absolute;
  1764. color: #ffffff;
  1765. max-width: 600px;
  1766. font-size: 12px;
  1767. padding: 5px 10px;
  1768. background: #333;
  1769. border-radius: 5px;
  1770. z-index: 110000;
  1771. line-height: 1.3;
  1772. display: none;
  1773. word-break: break-all;
  1774. }
  1775.  
  1776. @keyframes load {
  1777. 0% {
  1778. transform: rotate(0deg)
  1779. }
  1780.  
  1781. 100% {
  1782. transform: rotate(360deg)
  1783. }
  1784. }
  1785.  
  1786. .pl-loading-box>div>div {
  1787. position: absolute;
  1788. border-radius: 50%;
  1789. }
  1790.  
  1791. .pl-loading-box>div>div:nth-child(1) {
  1792. top: 9px;
  1793. left: 9px;
  1794. width: 82px;
  1795. height: 82px;
  1796. background: #ffffff;
  1797. }
  1798.  
  1799. .pl-loading-box>div>div:nth-child(2) {
  1800. top: 14px;
  1801. left: 38px;
  1802. width: 25px;
  1803. height: 25px;
  1804. background: #666666;
  1805. animation: load 1s linear infinite;
  1806. transform-origin: 12px 36px;
  1807. }
  1808.  
  1809. .pl-loading {
  1810. width: 16px;
  1811. height: 16px;
  1812. display: inline-block;
  1813. overflow: hidden;
  1814. background: none;
  1815. }
  1816.  
  1817. .pl-loading-box {
  1818. width: 100%;
  1819. height: 100%;
  1820. position: relative;
  1821. transform: translateZ(0) scale(0.16);
  1822. backface-visibility: hidden;
  1823. transform-origin: 0 0;
  1824. }
  1825.  
  1826. .pl-loading-box div {
  1827. box-sizing: content-box;
  1828. }
  1829.  
  1830. .pl-dropdown-menu {
  1831. position: absolute;
  1832. padding: 5px 0;
  1833. color: ${color};
  1834. background: themecolor;
  1835. z-index: 999;
  1836. width: 110px;
  1837. border-radius: 5px;
  1838. box-shadow: 0 1px 6px ${color}33;
  1839. -webkit-box-shadow: 0 1px 6px ${color}33;
  1840. text-align: center;
  1841. border: none;
  1842. transition: all 0.2s ease;
  1843. }
  1844.  
  1845. .swal2-container {
  1846. z-index: 100000;
  1847. }
  1848.  
  1849. body.swal2-height-auto {
  1850. height: inherit;
  1851. }
  1852.  
  1853. @media (prefers-color-scheme: dark) [data-theme=system] * {
  1854. color-scheme: dark;
  1855. }
  1856.  
  1857. /* Webkit, Opera, IE9, Chrome*/
  1858. ::selection {
  1859. background-color: ${color} !important;
  1860. background: ${color} !important;
  1861. color: white !important;
  1862. }
  1863.  
  1864. /* Mozilla Firefox */
  1865. ::-moz-selection {
  1866. background-color: ${color} !important;
  1867. background: ${color} !important;
  1868. color: white !important;
  1869. }
  1870.  
  1871. /* 百度网盘 */
  1872. :not([class*="rwl-exempt"]) ::selection {
  1873. background-color: ${color} !important;
  1874. background: ${color} !important;
  1875. color: white !important;
  1876. }
  1877. `;
  1878. // 先监听颜色方案变化
  1879. window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
  1880. if (e.matches) {
  1881. // 切换到暗色主题
  1882. let dark = uicss.replace("themecolor", "#19191a").replace("darktheme", "color-scheme: dark;");
  1883. base.addStyle('Panlinker-UI', 'style', dark);
  1884. } else {
  1885. // 切换到浅色主题
  1886. let light = uicss.replace("themecolor", "#fff").replace("darktheme", "");
  1887. base.addStyle('Panlinker-UI', 'style', light);
  1888. }
  1889. });
  1890. // 再修改主题
  1891. if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  1892. let dark = uicss.replace("themecolor", "#19191a").replace("darktheme", "color-scheme: dark;");
  1893. base.addStyle('Panlinker-UI', 'style', dark);
  1894. } else {
  1895. // 切换到浅色主题
  1896. let light = uicss.replace("themecolor", "#fff").replace("darktheme", "");
  1897. base.addStyle('Panlinker-UI', 'style', light);
  1898. }
  1899.  
  1900.  
  1901.  
  1902. if (/(pan|yun).baidu.com/.test(location.host) && base.getValue('setting_baidu_theme') === 'yes') {
  1903. base.addStyle('Panlinker-UI-Baidu', 'style', `
  1904. #layoutMain,
  1905. .DxdbeCb {
  1906. border-radius: 10px;
  1907. border-bottom-left-radius: 0;
  1908. border-bottom-right-radius: 0;
  1909. background: #ffffffA0 !important
  1910. }
  1911. .KPDwCE,
  1912. .DxdbeCb .OFaPaO .tanwePYr,
  1913. .xGLMIab .fufHyA:hover,
  1914. .module-search-timeline .form-box {
  1915. background: #ffffffA0 !important;
  1916. }
  1917. .KPDwCE .JDeHdxb,
  1918. .NHcGw .AuPKyz,
  1919. .xGLMIab .tvPMvPb,
  1920. .xGLMIab .FcQMwt,
  1921. .cazEfA .yfHIsP,
  1922. .hscjZ4QL .bbxnZ0Bq .ehnyLxWZ span,
  1923. .module-topToolBar,
  1924. .module-timeline-view .timeline-title-curday {
  1925. background: transparent !important;
  1926. border-bottom: 0;
  1927. }
  1928. .MdLxwM {
  1929. background :#fff !important;
  1930. }
  1931. .aside-absolute-container .QGOvsxb .remainingSpaceUi_span {
  1932. /*background: ${color} !important;*/
  1933. background: #8af248 !important;
  1934. border-radius: 10px 0 0 10px;
  1935. border-right: #fff 1px solid;
  1936. border-bottom: #fff 1px solid;
  1937. }
  1938. .xtJbHcb .CDaavKb .KQcHyA {
  1939. background: rgb(244,207,0) !important;
  1940. padding: 8px 15px;
  1941. }
  1942. .xtJbHcb .web-header-nav-new-version-inner {
  1943. background: ${color} !important;
  1944. padding: 8px 15px;
  1945. line-height: 15px;
  1946. width: auto;
  1947. height: auto;
  1948. }
  1949. a {
  1950. transition: all 0.2s ease !important;
  1951. }
  1952. .module-share-header .slide-show-header .slide-show-center {
  1953. float: inline-end;
  1954. margin: 10px 8px;
  1955. text-align: right;
  1956. }
  1957. .module-share-header .slide-show-header .slide-show-center .subscribe-btn {
  1958. background:${color}
  1959. }
  1960. #bd-main .bd-left {
  1961. margin: auto !important;
  1962. }
  1963. .verify-input input {
  1964. padding-left: 0 !important;
  1965. text-align: center !important;
  1966. }
  1967. .verify-input input:focus {
  1968. border: 2px solid ${color} !important;
  1969. }
  1970. `, 'body');
  1971. }
  1972. if (/(pan|yun).baidu.com/.test(location.host) && location.pathname !== '/disk/home' && base.getValue('setting_baidu_theme') === 'yes') {
  1973. window.onload = base.setColors([
  1974. ['#717fff', `${color}`],
  1975. ['#717FFF', `${color}`],
  1976. ['#06a8ff', `${color}`],
  1977. ['#06A8FF', `${color}`],
  1978. ['#06a7ff', `${color}`],
  1979. ['#06A7FF', `${color}`],
  1980. ['#dcdfe6', `${color}`],
  1981. ['#DCDFE6', `${color}`],
  1982. ['#0095ff', `${color}`],
  1983. ['#0095FF', `${color}`],
  1984. ['#09aaff', `${color}`],
  1985. ['#09AAFF', `${color}`],
  1986. ['#0ca6ff', `${color}`],
  1987. ['#0CA6FF', `${color}`],
  1988. ['#5040ff', `${color}`],
  1989. ['#5040FF', `${color}`],
  1990. ['#454d5a', `${color}`],
  1991. ['#454D5A', `${color}`],
  1992. ['#a2abbd', `${color}`],
  1993. ['#A2ABBD', `${color}`],
  1994. ['#030b1a', `${color}`],
  1995. ['#030B1A', `${color}`],
  1996. ['#afb3bf', `${color}`],
  1997. ['#AFB3BF', `${color}`],
  1998. ['#ff436a', `${color}`],
  1999. ['#FF436A', `${color}`],
  2000. ['#03081a', `${color}`],
  2001. ['#03081A', `${color}`],
  2002. ['#2974b6', `${color}`],
  2003. ['#2974B6', `${color}`],
  2004. ['#0596e6', `${color}`],
  2005. ['#0596E6', `${color}`],
  2006.  
  2007. ['#C3EAFF', `${color}`],
  2008. ['#c0d9fe', `${color}50`],
  2009. ['#0098EA', `${color}D0`],
  2010.  
  2011. ['#38b9ff', `${color}D0`],
  2012. ['#38B9FF', `${color}D0`],
  2013. ['#42d8ff', `${color}D0`],
  2014. ['#42D8FF', `${color}D0`],
  2015. ['#a48dff', `${color}D0`],
  2016. ['#A48DFF', `${color}D0`],
  2017. ['#6b79f2', `${color}D0`],
  2018. ['#6B79F2', `${color}D0`],
  2019.  
  2020. ['#9c86f2', `${color}90`],
  2021. ['#9C86F2', `${color}90`],
  2022. ['#83d3ff', `${color}90`],
  2023. ['#83D3FF', `${color}90`],
  2024.  
  2025. ['#fafafc', `${color}20`],
  2026. ['#FAFAFC', `${color}20`],
  2027. ['#f5fbff', `${color}20`],
  2028. ['#F5FBFF', `${color}20`],
  2029. ['#b4e5ff', `${color}20`],
  2030. ['#B4E5FF', `${color}20`],
  2031. ['#f0faff', `${color}20`],
  2032. ['#F0FAFF', `${color}20`],
  2033.  
  2034. ['#f1f3f8', `${color}15`],
  2035. ['#F1F3F8', `${color}15`],
  2036.  
  2037. ['#f2faff', `${color}10`],
  2038. ['#F2FAFF', `${color}10`],
  2039. ['#eef9fe', `${color}10`],
  2040. ['#EEF9FE', `${color}10`],
  2041. ['#f7f9fc', `${color}10`],
  2042. ['#F7F9FC', `${color}10`],
  2043. ['#f5f6fa', `${color}10`],
  2044. ['#F5F6FA', `${color}10`],
  2045. ['#b4e5ff', `${color}10`],
  2046. ['#B4E5FF', `${color}10`],
  2047. ['#e6f6ff', `${color}10`],
  2048. ['#E6F6FF', `${color}10`],
  2049.  
  2050. ['6,167,255,.1', base.hexToRgba(`${color}15`)],
  2051. ['6,167,255,.23', base.hexToRgba(`${color}3b`)],
  2052. ['164,141,255,.2', base.hexToRgba(`${color}30`)],
  2053. ['196,182,255,.2', base.hexToRgba(`${color}20`)],
  2054. ['113,127,255,.2', base.hexToRgba(`${color}40`)],
  2055. ['3,8,26,.6', base.hexToRgba(`${color}D0`)],
  2056. ['255,32,102,.4', base.hexToRgba(`${color}66`)],
  2057. ]);
  2058. };
  2059. if (/www.(aliyundrive|alipan).com/.test(location.host) && base.getValue('setting_ali_theme') === 'yes') {
  2060. window.onload = base.setColors([
  2061. ['#3763ff', `${color}`],
  2062. ['#8664ff', `${color}D0`],
  2063. ['99, 125, 255', base.hexToRgba(`${color}`)],
  2064. ['132, 133, 141', base.hexToRgba(`${color}`)],
  2065. ['112, 136, 255', base.hexToRgba(`${color}`)],
  2066. ['97, 122, 250', base.hexToRgba(`${color}`)],
  2067. ['68, 109, 255', base.hexToRgba(`${color}`)],
  2068. ['82, 110, 250', base.hexToRgba(`${color}20`)],
  2069. ['122, 144, 255', base.hexToRgba(`${color}D0`)],
  2070. ['138, 157, 255', base.hexToRgba(`${color}D0`)],
  2071. ['49, 49, 54', base.hexToRgba(`${color}`)],
  2072. ]);
  2073. };
  2074. if (/pan.xunlei.com/.test(location.host) && base.getValue('setting_xunlei_theme') === 'yes') {
  2075. base.addStyle('Panlinker-UI-Xunlei', 'style', `
  2076. * {
  2077. transition: all 0.2s ease;
  2078. }
  2079. .web-header {
  2080. background: linear-gradient(0deg,${color}D0,${color})
  2081. }
  2082. `);
  2083. window.onload = base.setColors([
  2084. ['#3f85ff', `${color}`],
  2085. ['63,133,255,.1', base.hexToRgba(`${color}20`)],
  2086. ['#2670ea', `${color}D0`],
  2087. ['#619bff', `${color}D0`],
  2088. ['#ecf3ff', `${color}10`],
  2089. ['#eee', `${color}20`],
  2090. ], "other");
  2091. };
  2092. if (/pan.quark.cn/.test(location.host) && base.getValue('setting_quark_theme') === 'yes') {
  2093. window.onload = base.setColors([
  2094. ['#0d53ff', `${color}`],
  2095. ['#e6f1ff', `${color}20`],
  2096. ['#f0faff', `${color}20`],
  2097. ['#7da3ff', `${color}D0`],
  2098. ['#ddd', `${color}D0`],
  2099. ['17,17,17,.9', base.hexToRgba(`${color}D0`)],
  2100. ['40,40,255,.04', base.hexToRgba(`${color}20`)],
  2101. ['#f7f7ff', 'transparent'],
  2102. ['238,247,255,0', base.hexToRgba(`${color}00`)],
  2103. ]);
  2104. base.addStyle('Panlinker-UI-Quark', 'style', `
  2105. .file-list .hover-oper .hover-transparent-bg {
  2106. background: transparent !important;
  2107. }
  2108. /* .viewer-toolbar-cus,
  2109. .viewer-cus .close {
  2110. background-color: ${color} !important;
  2111. } */
  2112. `);
  2113. };
  2114. if (/(yun|caiyun).139.com/.test(location.host) && base.getValue('setting_yidong_theme') === 'yes') {
  2115. base.addStyle('Panlinker-UI-Yidong', 'style', `
  2116. * {
  2117. transition: all 0.2s ease;
  2118. }
  2119. `);
  2120. window.onload = base.setColors([
  2121. ['#3181f9', `${color}`],
  2122. ['#5a9afa', `${color}`],
  2123. ['#98c0fc', `${color}D0`],
  2124. ['#2d76e5', `${color}D0`],
  2125. ['49,129,249,.08', base.hexToRgba(`${color}20`)],
  2126. ]);
  2127. };
  2128. },
  2129.  
  2130. // 暗号界面
  2131. async initDialog() {
  2132. let secret = ""
  2133. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  2134. secret = "当前暗号是‘" + pan.num + "’";
  2135. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  2136. secret = "当前开源协议是‘" + pan.license + "’,暗号是‘" + pan.num + "’";
  2137. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  2138. secret = "当前暗号是‘" + pan.num + "’";
  2139. } else {
  2140. base.setValue('setting_youxiaohou_server', 'v2');
  2141. secret = '<span style="color:red">检测到当前配置不正确,已自动修复<br/>请在刷新页面后再继续输入</span>';
  2142. }
  2143. let dialog = await Swal.fire({
  2144. title: `请阅读完以下全文再继续`,
  2145. allowOutsideClick: false,
  2146. showCloseButton: true,
  2147. showDenyButton: true,
  2148. confirmButtonText: '确定',
  2149. heightAuto: false,
  2150. scrollbarPadding: false,
  2151. html: `<div><img style="width: 250px;margin-bottom: 10px;" src="${pan.img}" alt="${pan.img}">
  2152. <input class="swal2-input init-input" id="init" type="text" placeholder="${pan.init[1]}"></div>
  2153. <div><span>服务器说道: ${pan.init[0]}”;</span></div>
  2154. <div><span>脚本说道: ${secret}”。</span></div>
  2155. <div>↓</div>
  2156. <div><span>但史丹利不知道的是,他可以按下<span style="color:red;font-style:italic;vertical-align:unset;">红色按钮</span>来点亮按钮</span></div>
  2157. <div><span>或者有仪式感地 输入以上暗号/开源协议 点亮</span></div>
  2158. <div><span>输入一些<span style="font-style:italic;vertical-align:unset;">恶臭的数字</span>甚至有彩蛋</span></div>
  2159. <div>↓</div>
  2160. <div><span><a target="_blank" href="https://www.youxiaohou.com" style="vertical-align:unset;">原作者</a>开发很辛苦,所以请有能力的你请支持下他的公众号</span></div>
  2161. <div><span>实在不行的话,那就来给这个改版点个<a href="https://github.com/hmjz100/Online-disk-direct-link-download-assistant/" style="vertical-align:unset;">Star</a>吧...</span></div>
  2162. <div><span>点亮后不仅能精简网盘界面 还能改变众多网盘主题色哦!</span></div>
  2163. `,
  2164. denyButtonText: '我就不输入,点我“注入”直接点亮'
  2165. });
  2166. if (dialog.isDenied) {
  2167. console.log("【(改)网盘直链下载助手】\n正在注入点亮按钮设置项目...");
  2168. message.warning("正在注入设置项目...");
  2169. setTimeout(function () {
  2170. base.setValue('setting_init_code', pan.num);
  2171. base.setValue('license', pan.license);
  2172. message.success("注入成功了!");
  2173. setTimeout(function () {
  2174. message.success(pan.init[2]);
  2175. setTimeout(function () {
  2176. location.reload();
  2177. }, 1500);
  2178. }, 1500);
  2179. }, 2500);
  2180. };
  2181. if (dialog.isConfirmed) {
  2182. if (pan.num === $('#init').val() || pan.license === $('#init').val()) {
  2183. console.log("【(改)网盘直链下载助手】\n暗号或协议正确")
  2184. message.success(pan.init[2]);
  2185. setTimeout(function () {
  2186. base.setValue('setting_init_code', pan.num);
  2187. base.setValue('license', pan.license);
  2188. location.reload();
  2189. }, 3000)
  2190. } else if ($('#init').val() === '114514' || $('#init').val() === '1919810' || $('#init').val() === '1145141919810') {
  2191. /*---
  2192. homo彩蛋又回来力(喜)
  2193. imageUrl: 'https://pic4.zhimg.com/80/v2-1b97a088e156c015108dec663bba8b04.jpg',
  2194. imageUrl: 'https://lh1.hetaousercontent.com/img/7d4c1c0b4adb0e95.jpg',
  2195. */
  2196. await Swal.fire({
  2197. icon: 'error',
  2198. title: '1145141919810',
  2199. html: '<span>homo特有的数字当然不行啦<br/>哼哼哼啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊</span>',
  2200. timer: 4000,
  2201. imageUrl: 'https://pic4.zhimg.com/80/v2-1b97a088e156c015108dec663bba8b04.jpg',
  2202. allowOutsideClick: false,
  2203. timerProgressBar: true,
  2204. showConfirmButton: false,
  2205. showDenyButton: true,
  2206. heightAuto: false,
  2207. scrollbarPadding: false,
  2208. denyButtonText: '哼哼哼啊啊啊啊啊啊啊啊啊啊',
  2209. });
  2210. message.info("成就:你触发了一个homo特有的彩蛋!");
  2211. setTimeout(function () {
  2212. Swal.fire({
  2213. title: '1145141919810',
  2214. text: 'homo特有的数字当然不行啦...吗?',
  2215. icon: 'question',
  2216. imageUrl: 'https://lh1.hetaousercontent.com/img/7d4c1c0b4adb0e95.jpg',
  2217. showConfirmButton: false,
  2218. allowOutsideClick: false,
  2219. });
  2220. setTimeout(function () {
  2221. base.setValue('setting_init_code', pan.num);
  2222. message.success("成就:哼哼哼啊啊啊啊啊啊啊啊地注入成功(喜)");
  2223. location.reload();
  2224. }, 3000)
  2225. }, 4000)
  2226. } else {
  2227. console.log("【(改)网盘直链下载助手】\n暗号错误")
  2228. await Swal.fire({
  2229. imageUrl: pan.img,
  2230. title: pan.init[3],
  2231. heightAuto: false,
  2232. scrollbarPadding: false,
  2233. html: `<div><span>${pan.init[4]}<br/>你可以在返回后选择“注入”立即点亮按钮,<br/>或者在输入框键入以下暗号:“${pan.num}”。</span></div>`,
  2234. confirmButtonText: '重新输入',
  2235. });
  2236. await this.initDialog();
  2237. return;
  2238. };
  2239. }
  2240. },
  2241. /*--- waitForKeyElements(): 一个实用函数,用于 Greasemonkey 脚本,
  2242. 它可以检测和处理AJAX加载的内容。
  2243. 使用示例:
  2244. base.waitForKeyElements (
  2245. "div.comments"
  2246. , commentCallbackFunction
  2247. );
  2248. // 页面特定的函数,用于在找到节点时执行我们想要的操作。
  2249. function commentCallbackFunction (jNode) {
  2250. jNode.text ("waitForKeyElements() 更改了这段注释。");
  2251. }
  2252. 重要提示:<br/>这个函数需要你的脚本加载了jQuery。
  2253. */
  2254. waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector) {
  2255. var targetNodes, btargetsFound;
  2256.  
  2257. if (typeof iframeSelector == "undefined")
  2258. targetNodes = $(selectorTxt);
  2259. else
  2260. targetNodes = $(iframeSelector).contents()
  2261. .find(selectorTxt);
  2262.  
  2263. if (targetNodes && targetNodes.length > 0) {
  2264. btargetsFound = true;
  2265. targetNodes.each(function () {
  2266. var jThis = $(this);
  2267. var alreadyFound = jThis.data('alreadyFound') || false;
  2268.  
  2269. if (!alreadyFound) {
  2270. //--- 调用载荷函数。
  2271. var cancelFound = actionFunction(jThis);
  2272. if (cancelFound) {
  2273. btargetsFound = false;
  2274. } else {
  2275. jThis.data('alreadyFound', true);
  2276. }
  2277. }
  2278. });
  2279. } else {
  2280. btargetsFound = false;
  2281. }
  2282.  
  2283. //--- 获取这个选择器的定时器控制变量。
  2284. var controlObj = base.waitForKeyElements.controlObj || {};
  2285. var controlKey = selectorTxt.replace(/[^\w]/g, "_");
  2286. var timeControl = controlObj[controlKey];
  2287.  
  2288. //--- 现在根据情况设置或清除定时器。
  2289. if (btargetsFound && bWaitOnce && timeControl) {
  2290. //--- 唯一需要清除定时器的情况。
  2291. clearInterval(timeControl);
  2292. delete controlObj[controlKey]
  2293. } else {
  2294. //--- 如果需要的话,设置一个定时器。
  2295. if (!timeControl) {
  2296. timeControl = setInterval(function () {
  2297. base.waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector);
  2298. }, 1000);
  2299. controlObj[controlKey] = timeControl;
  2300. }
  2301. }
  2302. base.waitForKeyElements.controlObj = controlObj;
  2303. },
  2304. };
  2305. // 用于油小猴服务器检测的脚本信息,防止服务器返回更新信息
  2306. let author = base.getValue('setting_script_author'),
  2307. version = base.getValue('setting_script_version')
  2308.  
  2309. //百度网盘
  2310. let baidu = {
  2311.  
  2312. _getExtra() {
  2313. let seKey = decodeURIComponent(base.getCookie('BDCLND'));
  2314. return '{' + '"sekey":"' + seKey + '"' + "}";
  2315. },
  2316.  
  2317. _getSurl() {
  2318. let reg = /(?<=s\/|surl=)([a-zA-Z0-9_-]+)/g;
  2319. if (reg.test(location.href)) {
  2320. return location.href.match(reg)[0];
  2321. }
  2322. return '';
  2323. },
  2324.  
  2325. _getFidList() {
  2326. let fidlist = [];
  2327. for (const v of selectList) {
  2328. if (+v.isdir !== 1) {
  2329. fidlist.push(v.fs_id);
  2330. }
  2331. }
  2332. return '[' + fidlist + ']';
  2333. },
  2334.  
  2335. _resetData() {
  2336. progress = {};
  2337. $.each(request, function (key) {
  2338. (request[key]).abort();
  2339. });
  2340. $.each(ins, function (key) {
  2341. clearInterval(ins[key]);
  2342. });
  2343. idm = {};
  2344. ins = {};
  2345. request = {};
  2346. },
  2347.  
  2348. setBDUSS() {
  2349. try {
  2350. GM_cookie && GM_cookie('list', { name: 'BDUSS' }, (cookies, error) => {
  2351. if (!error) {
  2352. let BDUSS = cookies?.[0]?.value;
  2353. if (BDUSS) {
  2354. base.setStorage("baiduyunPlugin_BDUSS", { BDUSS });
  2355. }
  2356. }
  2357. });
  2358. } catch (e) {
  2359. console.error("【(改)网盘直链下载助手】\nsetBDUSS\n错误信息:", e)
  2360. try {
  2361. let BDUSS = document.cookie.match(/BDUSS=(.*?)(;|$)/);
  2362. base.setStorage("baiduyunPlugin_BDUSS", { BDUSS: BDUSS });
  2363. } catch (e) {
  2364. console.error("【(改)网盘直链下载助手】\nsetBDUSS\n错误信息:", e)
  2365. }
  2366. }
  2367. },
  2368.  
  2369. getBDUSS() {
  2370. let baiduyunPlugin_BDUSS = base.getStorage('baiduyunPlugin_BDUSS') ? base.getStorage('baiduyunPlugin_BDUSS') : '{"baiduyunPlugin_BDUSS":""}';
  2371. return baiduyunPlugin_BDUSS.BDUSS || '';
  2372. },
  2373.  
  2374. convertLinkToAria(link, filename, ua) {
  2375. let BDUSS = this.getBDUSS();
  2376. if (!!BDUSS) {
  2377. filename = base.fixFilename(filename);
  2378. return encodeURIComponent(`aria2c "${link}" --out "${filename}" --header "User-Agent: ${ua}" --header "Cookie: BDUSS=${BDUSS}"`);
  2379. }
  2380. return {
  2381. link: pan.assistant,
  2382. text: pan.init[5]
  2383. };
  2384. },
  2385.  
  2386. convertLinkToBC(link, filename, ua) {
  2387. let BDUSS = this.getBDUSS();
  2388. if (!!BDUSS) {
  2389. let cookie = `BDUSS=${BDUSS}`;
  2390. let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}&cookie=${encodeURIComponent(cookie)}&user_agent=${encodeURIComponent(ua)}ZZ`;
  2391. return encodeURIComponent(`bc://http/${base.encode(bc)}`);
  2392. }
  2393. return {
  2394. link: pan.assistant,
  2395. text: pan.init[5]
  2396. };
  2397. },
  2398.  
  2399. convertLinkToCurl(link, filename, ua) {
  2400. let BDUSS = this.getBDUSS();
  2401. if (!!BDUSS) {
  2402. let terminal = base.getValue('setting_terminal_type');
  2403. filename = base.fixFilename(filename);
  2404. return encodeURIComponent(`${terminal !== 'wp' ? 'curl' : 'curl.exe'} -L -C - "${link}" -o "${filename}" -A "${ua}" -b "BDUSS=${BDUSS}"`);
  2405. }
  2406. return {
  2407. link: pan.assistant,
  2408. text: pan.init[5]
  2409. };
  2410. },
  2411.  
  2412. addPageListener() {
  2413. /*
  2414. 防止代码因其他原因被执行多次
  2415. 这段代码出自 Via轻插件,作者谷花泰
  2416. */
  2417. const key = encodeURIComponent('(改)网盘直链下载助手:百度网盘');
  2418. if (window[key]) return;
  2419. window[key] = true;
  2420.  
  2421. function _factory(e) {
  2422. let target = $(e.target);
  2423. let item = target.parents('.pl-item');
  2424. let link = item.find('.pl-item-link');
  2425. let progress = item.find('.pl-item-progress');
  2426. let tip = item.find('.pl-item-tip');
  2427. let copy = item.find('.pl-item-copy');
  2428. let howidm = item.find('.pl-progress-how');
  2429. let back = item.find('.pl-progress-back');
  2430. let stop = item.find('.pl-progress-stop');
  2431. return {
  2432. item, link, progress, tip, copy, howidm, back, stop, target,
  2433. };
  2434. }
  2435.  
  2436. function _reset(i) {
  2437. ins[i] && clearInterval(ins[i]);
  2438. request[i] && request[i].abort();
  2439. progress[i] = 0;
  2440. idm[i] = false;
  2441. }
  2442.  
  2443. doc.on('mouseenter mouseleave click', '.pl-button.g-dropdown-button', function (e) {
  2444. if (e.type === 'mouseleave') {
  2445. $(e.currentTarget).removeClass('button-open');
  2446. } else {
  2447. $(e.currentTarget).addClass('button-open');
  2448. $(e.currentTarget).find('.pl-dropdown-menu').show();
  2449. }
  2450. });
  2451. doc.on('mouseleave', '.pl-button.g-dropdown-button .pl-dropdown-menu', function (e) {
  2452. $(e.currentTarget).hide();
  2453. });
  2454.  
  2455. doc.on('click', '.pl-button-mode', function (e) {
  2456. mode = e.target.dataset.mode;
  2457. if (!mode) return;
  2458. Swal.fire({
  2459. heightAuto: false,
  2460. scrollbarPadding: false,
  2461. showConfirmButton: false,
  2462. html: `链接获取中`,
  2463. willOpen: function () {
  2464. Swal.showLoading();
  2465. }
  2466. });
  2467. baidu.getPCSLink();
  2468. });
  2469. doc.on('click', '.listener-link-api', async function (e) {
  2470. e.preventDefault();
  2471. let o = _factory(e);
  2472. let $width = o.item.find('.pl-progress-inner');
  2473. let $text = o.item.find('.pl-progress-inner-text');
  2474. let filename = o.link[0].dataset.filename;
  2475. let index = o.link[0].dataset.index;
  2476. _reset(index);
  2477. base.get(o.link[0].dataset.link, { "User-Agent": pan.ua }, 'blob', { filename, index });
  2478. let startTime = Date.now(); // 记录下载开始时间
  2479. let prevLoaded = 0; // 上一次的已下载数据量
  2480. let prevTime = startTime; // 上一次的时间
  2481. let size = Number(o.link[0].dataset.size);
  2482. ins[index] = setInterval(function () {
  2483. let prog = +progress[index] || 0;
  2484. let isIDM = idm[index] || false;
  2485.  
  2486. if (isIDM) {
  2487. // 处理IDM的代码
  2488. o.tip.hide();
  2489. o.progress.hide();
  2490. o.copy.show();
  2491. o.link.text('链接已被IDM捕获~请查看IDM下载窗口哦!').animate({ opacity: '0.5' }, "slow").show();
  2492. clearInterval(ins[index]);
  2493. setTimeout(
  2494. function () {
  2495. o.link.text('重新下载').animate({ opacity: '1' }, "slow");
  2496. }, 2000
  2497. )
  2498. idm[index] = false;
  2499. } else {
  2500. // 处理普通下载的情况...
  2501. let currentTime = Date.now();
  2502. let elapsedTime = currentTime - startTime;
  2503. let totalProgress = prog / 100;
  2504. let totalElapsedSeconds = elapsedTime / 1000;
  2505. let estimatedTotalTimeSeconds = totalElapsedSeconds / totalProgress;
  2506. let remainingTimeSeconds = estimatedTotalTimeSeconds - totalElapsedSeconds;
  2507.  
  2508. // 将剩余时间转换为天、时、分、秒
  2509. let remainingDays = Math.floor(remainingTimeSeconds / (60 * 60 * 24));
  2510. remainingTimeSeconds %= (60 * 60 * 24);
  2511.  
  2512. let remainingHours = Math.floor(remainingTimeSeconds / (60 * 60));
  2513. remainingTimeSeconds %= (60 * 60);
  2514.  
  2515. let remainingMinutes = Math.floor(remainingTimeSeconds / 60);
  2516. let remainingSeconds = Math.floor(remainingTimeSeconds % 60);
  2517.  
  2518. // 计算下载速度
  2519. let loaded = prog * size / 100; // 已下载数据量
  2520. let currentTimeDiff = currentTime - prevTime; // 当前时间与上一次时间的差值
  2521. let loadedDiff = loaded - prevLoaded; // 当前已下载数据量与上一次的差值
  2522. let downloadSpeed = (currentTimeDiff !== 0) ? loadedDiff / (currentTimeDiff / 1000) : 0; // 下载速度(单位:字节/秒)
  2523.  
  2524. // 更新上一次的数据
  2525. prevLoaded = loaded;
  2526. prevTime = currentTime;
  2527.  
  2528. // 更改界面
  2529. o.link.hide();
  2530. o.tip.hide();
  2531. o.stop.show();
  2532. o.copy.hide();
  2533. o.progress.show();
  2534.  
  2535. // 更新进度条
  2536. $width.css('width', prog + '%');
  2537.  
  2538. // 更新进度条文本
  2539. let timeText = '';
  2540. if (Number.isFinite(remainingDays) && remainingDays > 0) {
  2541. timeText = remainingDays + '天 ' + base.repairTimer(remainingHours) + '时:' + base.repairTimer(remainingMinutes) + '分:' + base.repairTimer(remainingSeconds) + '秒';
  2542. } else if (Number.isFinite(remainingHours) && remainingHours > 0) {
  2543. timeText = base.repairTimer(remainingHours) + '时:' + base.repairTimer(remainingMinutes) + '分:' + base.repairTimer(remainingSeconds) + '秒';
  2544. } else if (Number.isFinite(remainingMinutes) && remainingMinutes > 0) {
  2545. timeText = base.repairTimer(remainingMinutes) + '分:' + base.repairTimer(remainingSeconds) + '秒';
  2546. } else if (Number.isFinite(remainingSeconds) && remainingSeconds > 0) {
  2547. timeText = remainingSeconds + '秒';
  2548. } else if (Number.isFinite(remainingSeconds) && remainingSeconds === 0) {
  2549. timeText = '即将完成';
  2550. } else {
  2551. timeText = '计算中...';
  2552. }
  2553.  
  2554. let speedText = '';
  2555. speedText = base.sizeFormat(downloadSpeed)
  2556. $text.text(prog + '% | 剩余时间:' + timeText + ' | 速度:' + speedText + '/秒');
  2557.  
  2558. if (prog === 100) {
  2559. setTimeout(function () {
  2560. clearInterval(ins[index]);
  2561. progress[index] = 0;
  2562. o.item.find('.pl-progress-stop').hide();
  2563. o.howidm.hide();
  2564. $text.text('下载完成了!浏览器下载框应该弹出来了哦~');
  2565. o.back.show()
  2566. setTimeout(function () {
  2567. o.link.text('重新下载').animate({ opacity: '1' }, "slow");
  2568. }, 3000)
  2569. }, 3000)
  2570. }
  2571. }
  2572. }, 500);
  2573. });
  2574. doc.on('click', '.listener-retry', async function (e) {
  2575. let o = _factory(e);
  2576. o.tip.hide();
  2577. o.link.show();
  2578. });
  2579. doc.on('click', '.listener-how', async function (e) {
  2580. let o = _factory(e);
  2581. let index = o.link[0].dataset.index;
  2582. if (request[index]) {
  2583. request[index].abort();
  2584. clearInterval(ins[index]);
  2585. o.progress.hide();
  2586. o.tip.show();
  2587. }
  2588.  
  2589. });
  2590. doc.on('click', '.listener-stop', async function (e) {
  2591. let o = _factory(e);
  2592. let index = o.link[0].dataset.index;
  2593. if (request[index]) {
  2594. request[index].abort();
  2595. clearInterval(ins[index]);
  2596. o.item.find('.pl-progress-inner-text').text('正在取消...');
  2597. o.item.find('.pl-progress-inner').css('width', 100 + '%');
  2598. setTimeout(function () {
  2599. o.tip.hide();
  2600. o.back.hide();
  2601. o.link.show(0);
  2602. o.copy.show();
  2603. o.progress.hide();
  2604. o.stop.hide();
  2605. }, 1050)
  2606. }
  2607. });
  2608. doc.on('click', '.listener-back', async function (e) {
  2609. let o = _factory(e);
  2610. o.progress.hide();
  2611. o.tip.hide();
  2612. o.link.show();
  2613. o.copy.show();
  2614. o.stop.hide();
  2615. o.back.hide();
  2616. });
  2617. doc.on('click', '.listener-link-aria, .listener-copy-all', function (e) {
  2618. e.preventDefault();
  2619. if (!e.target.dataset.link) {
  2620. $(e.target).removeClass('listener-copy-all').addClass('pl-btn-danger').html(`${pan.init[5]}👉<a href="${pan.assistant}" target="_blank" class="pl-a">点击此处安装</a>👈`);
  2621. } else {
  2622. base.setClipboard(decodeURIComponent(e.target.dataset.link));
  2623. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  2624. setTimeout(
  2625. function () {
  2626. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  2627. }, 2000
  2628. )
  2629. }
  2630. });
  2631. doc.on('click', '.listener-download-all', function (e) {
  2632. $('.pl-item-link').click();
  2633. $(e.target).text('下载开始,下载进度见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  2634. setTimeout(
  2635. function () {
  2636. $(e.target).text('下载全部链接').animate({ opacity: '1' }, "slow");
  2637. }, 2000
  2638. )
  2639. });
  2640. doc.on('click', '.listener-link-rpc', async function (e) {
  2641. e.preventDefault();
  2642. let target = $(e.currentTarget);
  2643.  
  2644. target.find('.icon').remove();
  2645. target.find('.pl-loading').remove();
  2646. target.prepend(base.createLoading());
  2647.  
  2648. let res = await baidu.sendLinkToRPC(e.currentTarget.dataset.filename, e.currentTarget.dataset.link);
  2649. if (res === 'success') {
  2650. $('.listener-rpc-task').show();
  2651. target.removeClass('pl-btn-danger').html('发送成功了!快去看看吧~').animate({ opacity: '0.5' }, "slow");
  2652. } else if (res === 'assistant') {
  2653. target.addClass('pl-btn-danger').html(`${pan.init[5]}👉<a href="${pan.assistant}" target="_blank" class="pl-a">点击此处安装</a>👈`);
  2654. } else {
  2655. target.addClass('pl-btn-danger').text('发送失败,检查一下您的RPC配置信息哦!').animate({ opacity: '0.5' }, "slow");
  2656. }
  2657. });
  2658. doc.on('click', '.listener-send-rpc', function (e) {
  2659. $('.listener-link-rpc').click();
  2660. $(e.target).text('发送完成,发送结果见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  2661. });
  2662. doc.on('click', '.listener-open-setting', function () {
  2663. base.showSetting();
  2664. });
  2665. doc.on('click', '.listener-open-updatelog', function () {
  2666. base.showUpdateLog();
  2667. });
  2668. doc.on('click', '.listener-rpc-task', function (e) {
  2669. e.preventDefault();
  2670. let rpc = JSON.stringify({
  2671. domain: base.getValue('setting_rpc_domain'),
  2672. port: base.getValue('setting_rpc_port'),
  2673. }), url = `${pan.d}/?rpc=${base.encode(rpc)}#${base.getValue('setting_rpc_token')}`;
  2674. GM_openInTab(url, { active: true });
  2675. });
  2676. document.documentElement.addEventListener('mouseup', function (e) {
  2677. if (e.target.nodeName === 'A' && ~e.target.className.indexOf('pl-a')) {
  2678. e.stopPropagation();
  2679. }
  2680. }, true);
  2681. },
  2682.  
  2683. removeAD() {
  2684. base.waitForKeyElements(".wp-s-header-user__vip-center", function (tag) {
  2685. tag.remove();
  2686. });
  2687. base.waitForKeyElements(".wp-s-header-user__create-team-content", function (tag) {
  2688. tag.remove();
  2689. });
  2690. base.waitForKeyElements(".app-user-vip-center-box.vip-center-type-2", function (tag) {
  2691. tag.remove();
  2692. }, true);
  2693. base.waitForKeyElements(".wp-s-header__vip-btn-tip", function (tag) {
  2694. tag.fadeToggle();
  2695. }, true);
  2696. base.waitForKeyElements(".app-user-vip-center-tip", function (tag) {
  2697. tag.fadeToggle();
  2698. }, true);
  2699. base.waitForKeyElements("#web-header-text-s-45", function (tag) {
  2700. tag.fadeToggle();
  2701. }, true);
  2702. base.waitForKeyElements(".wp-s-header__vip-btn", function (tag) {
  2703. tag[0].innerText = "会员中心";
  2704. }, true);
  2705. base.waitForKeyElements(".KQcHyA", function (tag) {
  2706. tag[0].innerText = "会员中心";
  2707. }, true);
  2708. base.waitForKeyElements(".gOIbzPb", function (tag) {
  2709. tag.fadeToggle();
  2710. }, true);
  2711. base.waitForKeyElements(".popper__arrow", function (tag) {
  2712. tag.fadeToggle();
  2713. });
  2714. base.waitForKeyElements(".wp-s-header-user__create-team-title", function (tag) {
  2715. tag.fadeToggle();
  2716. }, true);
  2717. base.waitForKeyElements(".web-header-ad-item", function (tag) {
  2718. tag.fadeToggle();
  2719. });
  2720. base.waitForKeyElements(".wp-s-header__game-entry", function (tag) {
  2721. tag.fadeToggle();
  2722. }, true)
  2723. base.waitForKeyElements(".bd-aside-ad", function (tag) {
  2724. tag.fadeToggle();
  2725. }, true)
  2726. base.waitForKeyElements(".btn-img-tips", function (tag) {
  2727. tag.fadeToggle();
  2728. }, true)
  2729. base.waitForKeyElements(".nd-operate-guidance", function (tag) {
  2730. tag.fadeToggle();
  2731. }, true)
  2732. base.waitForKeyElements(".module-operation-content", function (tag) {
  2733. tag[0].remove()
  2734. document.querySelector(".module-canvas").click();
  2735. }, true)
  2736. base.waitForKeyElements(".newIcon", function (tag) {
  2737. tag.fadeToggle();
  2738. }, true);
  2739. base.waitForKeyElements(".u-badge__content.is-dot", function (tag) {
  2740. tag.fadeToggle();
  2741. }, true);
  2742. base.waitForKeyElements(".wp-side-options.g-clearfix", function (tag) {
  2743. tag.fadeToggle();
  2744. }, true);
  2745. base.waitForKeyElements(".wp-s-header-user__drop-channel", function (tag) {
  2746. tag.fadeToggle();
  2747. }, true);
  2748. base.waitForKeyElements(".app-download", function (tag) {
  2749. tag.fadeToggle();
  2750. }, true);
  2751. base.waitForKeyElements('.g-button[title="保存到手机"]', function (tag) {
  2752. tag.fadeToggle();
  2753. }, true)
  2754. base.waitForKeyElements('.yike-entrance', function (tag) {
  2755. tag.remove();
  2756. })
  2757. base.waitForKeyElements("p.wp-s-aside-nav__main-item-text", function (tag) {
  2758. if (tag[0].innerHTML.match(/(插件|相册|笔记)/) && tag[0].closest('a') && tag[0].closest('a').getAttribute('target') !== "_blank") {
  2759. $(tag[0].closest('a')).fadeToggle();
  2760. } else {
  2761. tag[0].innerHTML = tag[0].innerHTML.replace("百度", "");
  2762. }
  2763. }, true);
  2764. base.waitForKeyElements('dd[node-type="header-link"]', function (tag) {
  2765. tag.children().each(function () {
  2766. let tag = $(this);
  2767. if (!tag.attr("node-type")) return;
  2768. let type = tag.attr("node-type");
  2769. if (
  2770. type !== "disk-home" &&
  2771. type !== "mbox-homepage" &&
  2772. type !== "find-apps"
  2773. ) {
  2774. tag.fadeToggle();
  2775. }
  2776. });
  2777. }, true);
  2778. base.waitForKeyElements(".__yunguanjia", function (tag) {
  2779. tag[0].innerHTML = `
  2780. <div class="yunguanjia-list __yunguanjia row g-clearfix _item sel">
  2781. <span type="radio" class="radio-box _radioInput __yunguanjiaRadio">
  2782. <span class="device-name">添加我的电脑</span>
  2783. </span>
  2784. <div class="__yunguanjiaTips radio-tips" style="display: block;">
  2785. 用电脑下载并登录最新百度网盘客户端,即自动完成添加。
  2786. <a href="//pan.baidu.com/download" target="_blank">下载百度网盘客户端</a>
  2787. <br/>
  2788. <a>(改)网盘直链下载助手</a> 修复该选项
  2789. </div>
  2790. </div>`;
  2791. }, true)
  2792. // 美化分享页面
  2793. if (pt === 'share') {
  2794. base.waitForKeyElements(`iframe[src^="/buy/ad"]`, function (tag) {
  2795. tag.fadeToggle();
  2796. }, true)
  2797. base.waitForKeyElements(`.theme-white.init-new`, function (tag) {
  2798. tag[0].style.background = '#DCEFFE url(https://nd-static.bdstatic.com/m-static/disk-share/widget/pageModule/init-new/image/init-bg_1708266.png) no-repeat center center'
  2799. }, true)
  2800. base.waitForKeyElements(`#layoutApp`, function (tag) {
  2801. tag[0].style.background = '#DCEFFE url(https://nd-static.bdstatic.com/m-static/disk-share/widget/pageModule/init-new/image/init-bg_1708266.png) no-repeat center center'
  2802. document.body.style.background = '#DCEFFE url(https://nd-static.bdstatic.com/m-static/disk-share/widget/pageModule/init-new/image/init-bg_1708266.png) no-repeat center center'
  2803. }, true)
  2804. base.waitForKeyElements(`#bd-main .bd-left`, function (tag) {
  2805. tag[0].style.background = '#ffffffC0';
  2806. tag[0].style.borderRadius = '10px';
  2807.  
  2808. }, true)
  2809. base.waitForKeyElements(`.KPDwCE`, function (tag) {
  2810. tag[0].style.setProperty('background', 'transparent');
  2811. }, true)
  2812. base.waitForKeyElements('.share-list .KPDwCE .AuPKyz', function (tag) {
  2813. tag[0].style.setProperty('background', 'transparent');
  2814. }, true)
  2815. }
  2816. },
  2817.  
  2818. addButton() {
  2819. if (document.getElementById("pl-button-link")) {
  2820. document.getElementById("pl-button-link").remove()
  2821. }
  2822. if (!pt) return;
  2823. let $toolWrap;
  2824. let $button = $(`<div class="g-dropdown-button pointer pl-button" id="pl-button-link"><div class="baidu-button g-button g-button-blue"><span class="g-button-right"><em class="icon icon-download" style="color:#fff;"></em><span class="text" style="width: 60px;">下载助手</span></span></div><div class="menu" style="color: ${color};border-color: ${color};width:auto;z-index:41;"><div class="g-button-menu pl-button-mode" style="padding: 0px;" data-mode="api" ">API下载</div><div class="g-button-menu pl-button-mode" style="padding: 0px;" data-mode="aria" ">Aria下载</div><div class="g-button-menu pl-button-mode" style="padding: 0px;" data-mode="rpc" ">RPC下载</div><div class="g-button-menu pl-button-mode" style="padding: 0px;" data-mode="curl" ">cURL下载</div><div class="g-button-menu pl-button-mode" style="padding: 0px;" data-mode="bc" ">BC下载</div><div class="g-button-menu pl-button-mode listener-open-setting" style="padding: 0px;" ">助手设置</div><div class="g-button-menu pl-button-mode listener-open-updatelog" style="padding: 0px;" ">更新日志</div></div></div>`);
  2825. if (pt === 'home') $toolWrap = pan.btn.home;
  2826. if (pt === 'main') {
  2827. $toolWrap = pan.btn.main;
  2828. $button = $(`
  2829. <div class="wp-s-agile-tool-bar__h-group pl-button" id="pl-button-link">
  2830. <div class="wp-s-agile-tool-bar__h-action is-need-left-sep is-main">
  2831. <button type="button" class="u-button nd-file-list-toolbar-action-item u-button--primary u-button--small is-round is-has-icon pl-button baidu-button">
  2832. <i class="u-icon u-icon-download"></i>
  2833. <span>下载助手</span>
  2834. </button>
  2835. <ul class="dropdown-list nd-common-float-menu pl-dropdown-menu">
  2836. <li class="pl-button-mode sub cursor-p" data-mode="api">API下载</li>
  2837. <li class="pl-button-mode sub cursor-p" data-mode="aria">Aria下载</li>
  2838. <li class="pl-button-mode sub cursor-p" data-mode="rpc">RPC下载</li>
  2839. <li class="pl-button-mode sub cursor-p" data-mode="curl">cURL下载</li>
  2840. <li class="pl-button-mode sub cursor-p" data-mode="bc">BC下载</li>
  2841. <li class="pl-button-mode sub cursor-p listener-open-setting"">助手设置</li>
  2842. <li class="pl-button-mode sub cursor-p listener-open-updatelog">更新日志</li>
  2843. </ul>
  2844. </div>
  2845. </div>`);
  2846. }
  2847. if (pt === 'youth') {
  2848. $toolWrap = pan.btn.main;
  2849. $button = $(`
  2850. <div class="wp-s-agile-tool-bar__h-group pl-button" id="pl-button-link">
  2851. <div class="wp-s-agile-tool-bar__h-action is-need-left-sep is-main">
  2852. <button type="button" class="u-button nd-file-list-toolbar-action-item u-button--primary u-button--small is-round is-has-icon pl-button baidu-button" style="font-size:14px;font-weight:700">
  2853. <i class="u-icon u-icon-more"></i>
  2854. <span>网盘助手</span>
  2855. </button>
  2856. <ul class="dropdown-list nd-common-float-menu pl-dropdown-menu">
  2857. <li class="pl-button-mode sub cursor-p listener-open-setting"">助手设置</li>
  2858. <li class="pl-button-mode sub cursor-p listener-open-updatelog">更新日志</li>
  2859. </ul>
  2860. </div>
  2861. </div>`);
  2862. }
  2863. if (pt === 'share') $toolWrap = pan.btn.share;
  2864. base.listenElement($toolWrap, function () {
  2865. $toolWrap = $($toolWrap);
  2866. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  2867. })
  2868. this.setBDUSS();
  2869. },
  2870.  
  2871. addInitButton() {
  2872. if (document.getElementById("pl-button-link")) {
  2873. document.getElementById("pl-button-link").remove()
  2874. }
  2875. if (!pt) return;
  2876. let $toolWrap;
  2877. let $button = $(`<div class="g-dropdown-button pointer pl-button-init" id="pl-button-link" style="opacity:0.5"><div style="color:#fff;" class="g-button g-button-blue"><span class="g-button-right"><em class="icon icon-download" style="color:#fff;"></em><span class="text" style="width: 60px;">点我点亮</span></span></div></div>`);
  2878. if (pt === 'home') {
  2879. $toolWrap = pan.btn.home;
  2880. }
  2881. if (pt === 'main' || pt === 'youth') {
  2882. $toolWrap = pan.btn.main;
  2883. $button = $(`
  2884. <div class="wp-s-agile-tool-bar__h-group pl-button-init" id="pl-button-link">
  2885. <div class="wp-s-agile-tool-bar__h-action is-need-left-sep is-main">
  2886. <button type="button" class="u-button nd-file-list-toolbar-action-item u-button--primary u-button--small is-round is-has-icon pl-button baidu-button" style="font-size:14px;font-weight:700">
  2887. <i class="u-icon u-icon-download"></i>
  2888. <span>点我点亮</span>
  2889. </button>
  2890. </div>
  2891. </div>`);
  2892. }
  2893. if (pt === 'share') $toolWrap = pan.btn.share;
  2894. $button.click(function () { base.initDialog() });
  2895. base.listenElement($toolWrap, function () {
  2896. $toolWrap = $($toolWrap);
  2897. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  2898. })
  2899. },
  2900.  
  2901. async getToken() {
  2902. function openTab() {
  2903. GM_openInTab(pan.pcs[3], { active: true, insert: true, setParent: true });
  2904. base.deleteValue('baidu_access_token');
  2905. };
  2906.  
  2907. const waitForToken = function () {
  2908. new Promise((resolve) => {
  2909. let attempts = 0;
  2910. const interval = setInterval(function () {
  2911. const token = base.getValue('baidu_access_token');
  2912. if (token) {
  2913. clearInterval(interval);
  2914. resolve(token);
  2915. }
  2916. attempts++;
  2917. if (attempts > 60) {
  2918. clearInterval(interval);
  2919. resolve('');
  2920. }
  2921. }, 1000);
  2922. })
  2923. };
  2924.  
  2925. if (manageHandler === 'Tampermonkey' && base.getMajorVersion(manageVersion) >= 5) {
  2926. openTab();
  2927. return waitForToken();
  2928. }
  2929.  
  2930. let res = await base.getFinalUrl(pan.pcs[3]);
  2931.  
  2932. if (!res.includes('authorize') && !res.includes('access_token=')) {
  2933. openTab();
  2934. return waitForToken();
  2935. }
  2936.  
  2937. if (res.includes('authorize')) {
  2938. // 使用await关键字等待base.get函数的返回结果,获取网页内容
  2939. let html = await base.get(pan.pcs[3], {}, 'text');
  2940.  
  2941. // 使用正则表达式匹配html中的'bdstoken'和'client_id'
  2942. let bdstoken = html.match(/name="bdstoken"\s+value="([^"]+)"/)?.[1];
  2943. let client_id = html.match(/name="client_id"\s+value="([^"]+)"/)?.[1];
  2944.  
  2945. // 构建一个包含所需参数的数据对象,包含百度授权所需参数
  2946. let data = {
  2947. grant_permissions_arr: 'netdisk',
  2948. bdstoken: bdstoken,
  2949. client_id: client_id,
  2950. response_type: "token",
  2951. display: "page",
  2952. grant_permissions: "basic,netdisk"
  2953. };
  2954.  
  2955. // 向服务器发送POST请求,实现自动授权
  2956. await base.post(pan.pcs[3], base.stringify(data), {
  2957. 'Content-Type': 'application/x-www-form-urlencoded',
  2958. });
  2959.  
  2960. // 授权完后再次获取'access_token'
  2961. let res2 = await base.getFinalUrl(pan.pcs[3]);
  2962. let accessToken = res2.match(/access_token=([^&]+)/)?.[1];
  2963. accessToken && base.setValue('baidu_access_token', accessToken);
  2964. return accessToken;
  2965. };
  2966. // 如果已有'access_token',则获取新的'access_token'
  2967. let accessToken = res.match(/access_token=([^&]+)/)?.[1];
  2968. accessToken && base.setValue('baidu_access_token', accessToken);
  2969. return accessToken;
  2970. },
  2971.  
  2972. async getPCSLink(maxRequestTime = 1) {
  2973. selectList = this.getSelectedList();
  2974. let fidList = this._getFidList(), url, res;
  2975.  
  2976. if (pt === 'home' || pt === 'main') {
  2977. if (selectList.length === 0) {
  2978. return message.error('提示:<br/>先勾选要下载的文件哦~');
  2979. }
  2980. if (fidList.length === 2) {
  2981. return message.error('提示:<br/>请打开文件夹后再勾选文件~');
  2982. }
  2983. fidList = encodeURIComponent(fidList);
  2984. let accessToken = base.getValue('baidu_access_token')
  2985. if (!accessToken || accessToken === undefined) {
  2986. message.error('提示:<br/>稍后请在新标签页中授权助手获取信息~');
  2987. return setTimeout(async function () {
  2988. await baidu.getToken();
  2989. }, 1500)
  2990. }
  2991. url = `${pan.pcs[0]}&fsids=${fidList}&access_token=${accessToken}`;
  2992. res = await base.get(url, { "User-Agent": pan.ua });
  2993. }
  2994. if (pt === 'share') {
  2995. this.getShareData();
  2996. if (!params.bdstoken) {
  2997. return message.error('提示:<br/>请先登录网盘~');
  2998. }
  2999. if (selectList.length === 0) {
  3000. return message.error('提示:<br/>请先勾选要下载的文件哦~');
  3001. }
  3002. if (fidList.length === 2) {
  3003. return message.error('提示:<br/>请打开文件夹后再勾选文件~');
  3004. }
  3005. let dialog = await Swal.fire({
  3006. toast: true,
  3007. icon: 'info',
  3008. title: `提示:<br/>请将文件<span class="tag-danger">[保存到网盘]</span>后再👉前往<span class="tag-danger">[我的网盘]</span>中下载哦!`,
  3009. showConfirmButton: true,
  3010. confirmButtonText: '点击保存',
  3011. position: 'top',
  3012. });
  3013. if (dialog.isConfirmed) {
  3014. $('.tools-share-save-hb')[0].click();
  3015. }
  3016. return;
  3017. }
  3018. if (res.errno === 0) {
  3019. let html = this.generateDom(res.list);
  3020. this.showMainDialog(pan[mode][0], html, pan[mode][1]);
  3021. } else if (res.errno === 112) {
  3022. return message.error('提示:<br/>页面过期了,刷新重试下吧~<br/>代码:' + res.errno);
  3023. } else if (res.errno === 9019) {
  3024. maxRequestTime--;
  3025. await this.getToken();
  3026. if (maxRequestTime > 0) {
  3027. await this.getPCSLink(maxRequestTime);
  3028. } else {
  3029. message.error('提示:<br/>获取下载链接失败,刷新网页后再试试吧~<br/>代码:' + res.errno);
  3030. }
  3031. } else {
  3032. base.deleteValue('baidu_access_token');
  3033. if (res.errno) {
  3034. message.error('提示:<br/>获取下载链接失败,刷新网页后再试试吧~<br/>代码:' + res.errno);
  3035. } else {
  3036. message.error('提示:<br/>获取下载链接失败,刷新网页后再试试吧~');
  3037. }
  3038. }
  3039. },
  3040.  
  3041. generateDom(list) {
  3042. let content = '<div class="pl-main">';
  3043. let alinkAllText = '';
  3044. base.sortByName(list);
  3045. list.forEach((v, i) => {
  3046. if (v.isdir === 1) return;
  3047. let filename = v.server_filename || v.filename;
  3048. let ext = base.getExtension(filename);
  3049. let size = base.sizeFormat(v.size);
  3050. let dlink = v.dlink + '&access_token=' + base.getValue('baidu_access_token');
  3051. if (mode === 'api') {
  3052. alinkAllText += dlink + '\r\n';
  3053. content += `<div class="pl-item">
  3054. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3055. <a class="pl-item-link pl-a listener-link-api" href="${dlink}" data-filename="${filename}" data-size="${v.size}" data-link="${dlink}" data-index="${i}">${dlink}<br/>下载 ${filename}</a>
  3056. <!--<a class="pl-item-copy" target="_blank" href="${dlink}" title="点击使用浏览器下载" data-filename="${filename}" data-link="${dlink}">传统下载</a>-->
  3057. <!--<button class="pl-item-copy pl-btn-primary listener-copy-all" href="${dlink}" title="点击复制链接" data-filename="${filename}" data-link="${dlink}">复制链接</button>-->
  3058. <div class="pl-item-tip" style="display: none"><span>若没有弹出IDM下载框,找到IDM <b>选项</b> -> <b>文件类型</b> -> <b>第一个框</b> 中添加后缀 <span class="pl-ext">${ext}</span>,<a href="${pan.idm}" target="_blank" class="pl-a">详见此处</a></span> <span class="pl-back listener-back">返回</span></div>
  3059. <div class="pl-item-progress" style="display: none">
  3060. <div class="pl-progress">
  3061. <div class="pl-progress-outer"></div>
  3062. <div class="pl-progress-inner" style="width:5%">
  3063. <div class="pl-progress-inner-text">正在加载进度...0%</div>
  3064. </div>
  3065. </div>
  3066. <span class="pl-progress-stop listener-stop">取消下载</span>
  3067. `;
  3068. content += `<span class="pl-progress-tip" style="display: none" >未发现IDM,使用自带浏览器下载</span>
  3069. <span class="pl-progress-back pl-back listener-back" style="display: none">返回</span>
  3070. <span class="pl-progress-how listener-how" style="display: none">如何唤起IDM?</span>
  3071. `;
  3072. content += `</div></div>`
  3073. }
  3074. if (mode === 'aria') {
  3075. let alink = this.convertLinkToAria(dlink, filename, pan.ua);
  3076. if (typeof (alink) === 'object') {
  3077. content += `<div class="pl-item">
  3078. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3079. <a class="pl-item-link pl-a" target="_blank" href="${alink.link}" title="点击复制aria2c链接" data-filename="${filename}" data-link="${alink.link}">${decodeURIComponent(alink.text)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  3080. } else {
  3081. alinkAllText += alink + '\r\n';
  3082. content += `<div class="pl-item">
  3083. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3084. <a class="pl-item-link pl-a listener-link-aria" href="${alink}" title="点击复制aria2c链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  3085. }
  3086. }
  3087. if (mode === 'rpc') {
  3088. content += `<div class="pl-item">
  3089. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3090. <button class="pl-item-link listener-link-rpc pl-btn-primary pl-btn-info" data-filename="${filename}" data-link="${dlink}"><em class="icon icon-device"></em><span style="margin-left: 5px;">将 ${filename} 推送到 RPC 下载器</span></button></div>`;
  3091. }
  3092. if (mode === 'curl') {
  3093. let alink = this.convertLinkToCurl(dlink, filename, pan.ua);
  3094. if (typeof (alink) === 'object') {
  3095. content += `<div class="pl-item">
  3096. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3097. <a class="pl-item-link pl-a" target="_blank" href="${alink.link}" title="点击复制curl链接" data-filename="${filename}" data-link="${alink.link}">${decodeURIComponent(alink.text)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  3098. } else {
  3099. alinkAllText += alink + '\r\n';
  3100. content += `<div class="pl-item">
  3101. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3102. <a class="pl-item-link pl-a listener-link-aria" href="${alink}" title="点击复制curl链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  3103. }
  3104. }
  3105. if (mode === 'bc') {
  3106. let alink = this.convertLinkToBC(dlink, filename, pan.ua);
  3107. if (typeof (alink) === 'object') {
  3108. content += `<div class="pl-item">
  3109. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3110. <a class="pl-item-link pl-a" href="${decodeURIComponent(alink.link)}" title="点击用比特彗星下载" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink.text)}<br/>下载 ${filename}</a> </div>`;
  3111. } else {
  3112. alinkAllText += alink + '\r\n';
  3113. content += `<div class="pl-item">
  3114. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3115. <a class="pl-item-link pl-a" href="${decodeURIComponent(alink)}" title="点击用比特彗星下载" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>下载 ${filename}</a> </div>`;
  3116. }
  3117. }
  3118. });
  3119.  
  3120. content += '</div>';
  3121.  
  3122. if (mode === 'api')
  3123. content += `<div class="pl-extra"><button class="pl-btn-primary listener-download-all">下载全部链接</button></div>`;
  3124. if (mode === 'aria')
  3125. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部命令行</button></div>`;
  3126. if (mode === 'rpc') {
  3127. let rpc = base.getValue('setting_rpc_domain') + ':' + base.getValue('setting_rpc_port') + base.getValue('setting_rpc_path');
  3128. content += `<div class="pl-extra"><button class="pl-btn-primary listener-send-rpc">发送全部链接</button><button title="${rpc}" class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px">设置 RPC 参数(当前为:${rpc})</button><button class="pl-btn-primary pl-btn-success listener-rpc-task" style="margin-left: 10px;display: none">查看下载任务</button></div>`;
  3129. }
  3130. if (mode === 'curl') {
  3131. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部链接</button><button class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px;">设置终端类型(当前为:${terminalType[base.getValue('setting_terminal_type')]})</button></div>`;
  3132. }
  3133. return content;
  3134. },
  3135.  
  3136. async sendLinkToRPC(filename, link) {
  3137. let rpc = {
  3138. domain: base.getValue('setting_rpc_domain'),
  3139. port: base.getValue('setting_rpc_port'),
  3140. path: base.getValue('setting_rpc_path'),
  3141. token: base.getValue('setting_rpc_token'),
  3142. dir: base.getValue('setting_rpc_dir'),
  3143. };
  3144. let BDUSS = this.getBDUSS();
  3145. if (!BDUSS) return 'assistant';
  3146.  
  3147. let url = `${rpc.domain}:${rpc.port}${rpc.path}`;
  3148. let rpcData = {
  3149. id: new Date().getTime(),
  3150. jsonrpc: '2.0',
  3151. method: 'aria2.addUri',
  3152. params: [`token:${rpc.token}`, [link], {
  3153. dir: rpc.dir,
  3154. out: filename,
  3155. header: [`User-Agent: ${pan.ua}`, `Cookie: BDUSS=${BDUSS}`]
  3156. }]
  3157. };
  3158. try {
  3159. let res = await base.post(url, rpcData, { "User-Agent": pan.ua }, '');
  3160. if (res.result) return 'success';
  3161. return 'fail';
  3162. } catch (e) {
  3163. return 'fail';
  3164. }
  3165. },
  3166.  
  3167. getSelectedList() {
  3168. try {
  3169. var List = require("system-core:context/context.js").instanceForSystem.list;
  3170. var selectList = List.getSelected();
  3171. if (!selectList.length) {
  3172. selectList = List.getCurrentList();
  3173. }
  3174. return selectList;
  3175. } catch (e) {
  3176. var list1 = unsafeWindow.document.querySelector('.wp-s-core-pan');
  3177. if (list1 && list1.__vue__) {
  3178. return list1.__vue__.selectedList;
  3179. } else {
  3180. var list2 = unsafeWindow.document.querySelector('.file-list');
  3181. return list2.__vue__.allFileList.filter(function (item) { return !!item.selected; });
  3182. }
  3183. }
  3184. },
  3185.  
  3186. getLogid() {
  3187. let ut = require("system-core:context/context.js").instanceForSystem.tools.baseService;
  3188. return ut.base64Encode(base.getCookie("BAIDUID"));
  3189. },
  3190.  
  3191. getShareData() {
  3192. let res = locals.dump();
  3193. params.shareType = 'secret';
  3194. params.sign = '';
  3195. params.timestamp = '';
  3196. params.bdstoken = res.bdstoken.value;
  3197. params.channel = 'chunlei';
  3198. params.clienttype = 0;
  3199. params.web = 1;
  3200. params.app_id = 250528;
  3201. params.encrypt = 0;
  3202. params.product = 'share';
  3203. params.logid = this.getLogid();
  3204. params.primaryid = res.shareid.value;
  3205. params.uk = res.share_uk.value;
  3206. params.shareType === 'secret' && (params.extra = this._getExtra());
  3207. params.surl = this._getSurl();
  3208. },
  3209.  
  3210. detectPage() {
  3211. let path = location.pathname;
  3212. if (/^\/disk\/home/.test(path)) return 'home';
  3213. if (/^\/disk\/main/.test(path)) return 'main';
  3214. if (/^\/youth\/pan\/main/.test(path)) return 'youth';
  3215. if (/^\/(s|share)\//.test(path)) return 'share';
  3216. return '';
  3217. },
  3218.  
  3219. showMainDialog(title, html, footer) {
  3220. Swal.fire({
  3221. title,
  3222. html,
  3223. footer,
  3224. allowOutsideClick: false,
  3225. showCloseButton: true,
  3226. heightAuto: false,
  3227. scrollbarPadding: false,
  3228. position: 'center',
  3229. width,
  3230. padding: '15px 20px 5px',
  3231. customClass,
  3232. confirmButtonText: '关闭',
  3233. }).then(function () {
  3234. this._resetData();
  3235. });
  3236. },
  3237.  
  3238. async initAuthorize() {
  3239. base.registerMenuCommand();
  3240. Swal.fire({
  3241. heightAuto: false,
  3242. scrollbarPadding: false,
  3243. showConfirmButton: false,
  3244. allowOutsideClick: false,
  3245. allowEscapeKey: false,
  3246. allowEnterKey: false,
  3247. html: `请稍后`,
  3248. willOpen: function () {
  3249. Swal.showLoading();
  3250. },
  3251. });
  3252. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  3253. let res = await base.post(`https://api.youxiaohou.com/config/?ver=${version}&a=${author}`, {}, {}, 'text');
  3254. pan = JSON.parse(base.decode(res));
  3255. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  3256. let res = await base.post(`https://api.youxiaohou.com/config/v2/?ver=${version}&a=${author}`, {}, {}, 'text');
  3257. pan = JSON.parse(base.decode(res));
  3258. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  3259. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  3260. pan = JSON.parse(res);
  3261. } else {
  3262. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  3263. pan = JSON.parse(res);
  3264. base.setValue('setting_youxiaohou_server', 'v2');
  3265. }
  3266. Object.freeze && Object.freeze(pan);
  3267. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  3268. let url = new URL(location.href)
  3269. let auth = new URL(pan.pcs[3])
  3270. if (
  3271. /openapi.baidu.com\/oauth\/2.0\/authorize/.test(location.href) &&
  3272. (location.href.includes('basic+netdisk') || location.href.includes('basic,netdisk')) &&
  3273. (
  3274. url.searchParams.get("client_id") === auth.searchParams.get("client_id")/* ||
  3275. url.searchParams.get("client_id") === 'L6g70tBRRIXLsY0Z3HwKqlRE' || // pcstest_oauth
  3276. url.searchParams.get("client_id") === 'fSds3K4w43rw37tOqlQmTa2kDwaczK4U' || // 小度智能词典笔专业版
  3277. url.searchParams.get("client_id") === 'TFwtw8uwHxpdkvVqVKdIlx1XqXUnr1zG' || // 印象笔记
  3278. url.searchParams.get("client_id") === '9dgBV9yesuBVOXaxls7aVHbLBLqU8yyg' || // WPS文档
  3279. url.searchParams.get("client_id") === 'IlLqBbU3GjQ0t46TRwFateTprHWl39zF' // 百度手机助手 */
  3280. )
  3281. ) {
  3282. let dialog = await Swal.fire({
  3283. icon: 'info',
  3284. title: `提示`,
  3285. html: '你好呀,为了获取百度网盘文件的下载直链<br/>我们需要您的授权来使 “下载助手” 读取您的网盘数据<br/><br/>由于使用了别的应用ID,所以授权的应用名称会有不同<br/>获取到的数据仅用于生成直链,请放心授权ヾ(≧▽≦*)o',
  3286. showConfirmButton: true,
  3287. showDenyButton: true,
  3288. allowOutsideClick: false,
  3289. allowEscapeKey: false,
  3290. allowEnterKey: false,
  3291. confirmButtonText: '授权',
  3292. denyButtonText: '再想想',
  3293. position: 'center'
  3294. });
  3295. if (dialog.isConfirmed) {
  3296. base.waitForKeyElements("button#auth-allow", function (element) {
  3297. element[0].click();
  3298. })
  3299. return;
  3300. }
  3301. if (dialog.isDenied) {
  3302. let dialog = await Swal.fire({
  3303. icon: 'question',
  3304. title: `好吧(* ̄3 ̄)╭`,
  3305. html: '那就再想一想<br/>想好了就按下 “授权” 按钮吧~',
  3306. timer: 180000,
  3307. toast: true,
  3308. timerProgressBar: true,
  3309. showConfirmButton: false,
  3310. showDenyButton: false,
  3311. position: 'bottom-end',
  3312. })
  3313. return;
  3314. }
  3315. } else if (/openapi.baidu.com\/oauth\/2.0\/login_success/.test(location.href)) {
  3316. let int = setInterval(async function () {
  3317. if (location.href.includes('access_token') && (location.href.includes('basic+netdisk') || location.href.includes('basic,netdisk'))) {
  3318. clearInterval(int)
  3319. let token = location.href.match(/access_token=(.*?)&/)[1];
  3320. base.setValue('baidu_access_token', token);
  3321. let dialog = await Swal.fire({
  3322. icon: 'success',
  3323. title: `成功啦`,
  3324. html: '你已 成功授权/授权过 脚本读取您的网盘数据<br/>等待 <span id="second">3</span> 秒之后将关闭此页面',
  3325. timer: 3000,
  3326. timerProgressBar: true,
  3327. showConfirmButton: true,
  3328. showDenyButton: false,
  3329. allowOutsideClick: false,
  3330. allowEscapeKey: false,
  3331. allowEnterKey: false,
  3332. confirmButtonText: '关闭页面',
  3333. position: 'center',
  3334. willOpen: function () {
  3335. let sec = 3.1;
  3336. setInterval(() => {
  3337. sec -= 0.1;
  3338. document.getElementById("second").innerText = sec.toFixed(1);
  3339. }, 100);
  3340. setTimeout(() => {
  3341. window.close()
  3342. }, 3100);
  3343. },
  3344. });
  3345. if (dialog.isConfirmed) {
  3346. window.close()
  3347. return;
  3348. }
  3349. } else {
  3350. clearInterval(int)
  3351. Swal.close()
  3352. }
  3353. }, 1)
  3354. } else {
  3355. Swal.close()
  3356. }
  3357. } else {
  3358. Swal.close()
  3359. }
  3360. },
  3361.  
  3362. async initPanLinker() {
  3363. pt = this.detectPage();
  3364. base.createTip();
  3365. base.registerMenuCommand();
  3366. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  3367. let res = await base.post(`https://api.youxiaohou.com/config/?ver=${version}&a=${author}`, {}, {}, 'text');
  3368. pan = JSON.parse(base.decode(res));
  3369. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  3370. let res = await base.post(`https://api.youxiaohou.com/config/v2/?ver=${version}&a=${author}`, {}, {}, 'text');
  3371. pan = JSON.parse(base.decode(res));
  3372. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  3373. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  3374. pan = JSON.parse(res);
  3375. } else {
  3376. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  3377. pan = JSON.parse(res);
  3378. base.setValue('setting_youxiaohou_server', 'v2');
  3379. }
  3380. Object.freeze && Object.freeze(pan);
  3381. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  3382. this.addButton();
  3383. this.addPageListener();
  3384. } else {
  3385. this.addInitButton();
  3386. }
  3387. },
  3388. };
  3389.  
  3390. //阿里云盘
  3391. let ali = {
  3392.  
  3393. convertLinkToAria(link, filename, ua) {
  3394. filename = base.fixFilename(filename);
  3395. return encodeURIComponent(`aria2c "${link}" --out "${filename}" --header "Referer: https://${location.host}/"`);
  3396. },
  3397.  
  3398. convertLinkToBC(link, filename, ua) {
  3399. let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}&refer=${encodeURIComponent(`https://${location.host}/`)}ZZ`;
  3400. return encodeURIComponent(`bc://http/${base.encode(bc)}`);
  3401. },
  3402.  
  3403. convertLinkToCurl(link, filename, ua) {
  3404. let terminal = base.getValue('setting_terminal_type');
  3405. filename = base.fixFilename(filename);
  3406. return encodeURIComponent(`${terminal !== 'wp' ? 'curl' : 'curl.exe'} -L -C - "${link}" -o "${filename}" -e "https://${location.host}/"`);
  3407. },
  3408.  
  3409. addPageListener() {
  3410. /*
  3411. 防止代码因其他原因被执行多次
  3412. 这段代码出自 Via轻插件,作者谷花泰
  3413. */
  3414. const key = encodeURIComponent('(改)网盘直链下载助手:阿里云盘');
  3415. if (window[key]) return;
  3416. window[key] = true;
  3417.  
  3418. function _factory(e) {
  3419. let target = $(e.target);
  3420. let item = target.parents('.pl-item');
  3421. let link = item.find('.pl-item-link');
  3422. let progress = item.find('.pl-item-progress');
  3423. let tip = item.find('.pl-item-tip');
  3424. let copy = item.find('.pl-item-copy');
  3425. let howidm = item.find('.pl-progress-how');
  3426. let back = item.find('.pl-progress-back');
  3427. let stop = item.find('.pl-progress-stop');
  3428. return {
  3429. item, link, progress, tip, copy, howidm, back, stop, target,
  3430. };
  3431. }
  3432.  
  3433. function _reset(i) {
  3434. ins[i] && clearInterval(ins[i]);
  3435. request[i] && request[i].abort();
  3436. progress[i] = 0;
  3437. idm[i] = false;
  3438. }
  3439. doc.on('click', '.pl-button-mode', function (e) {
  3440. mode = e.target.dataset.mode;
  3441. if (!mode) return;
  3442. Swal.fire({
  3443. heightAuto: false,
  3444. scrollbarPadding: false,
  3445. showConfirmButton: false,
  3446. html: `链接获取中`,
  3447. willOpen: function () {
  3448. Swal.showLoading();
  3449. }
  3450. });
  3451. ali.getPCSLink();
  3452. });
  3453. doc.on('click', '.listener-link-api', async function (e) {
  3454. e.preventDefault();
  3455. let o = _factory(e);
  3456. let $width = o.item.find('.pl-progress-inner');
  3457. let $text = o.item.find('.pl-progress-inner-text');
  3458. let filename = o.link[0].dataset.filename;
  3459. let index = o.link[0].dataset.index;
  3460. _reset(index);
  3461. let dataset = e.currentTarget.dataset;
  3462. let href = dataset.link;
  3463. //let url = await this.getRealLink(dataset.did, dataset.fid);
  3464. //if (url) href = url;
  3465. base.get(href, { "User-Agent": pan.ua, "Referer": `https://${location.host}/` }, 'blob', { filename, index });
  3466. let startTime = Date.now(); // 记录下载开始时间
  3467. let prevLoaded = 0; // 上一次的已下载数据量
  3468. let prevTime = startTime; // 上一次的时间
  3469. let size = Number(o.link[0].dataset.size);
  3470. ins[index] = setInterval(function () {
  3471. let prog = +progress[index] || 0;
  3472. // 处理普通下载的情况...
  3473. let currentTime = Date.now();
  3474. let elapsedTime = currentTime - startTime;
  3475. let totalProgress = prog / 100;
  3476. let totalElapsedSeconds = elapsedTime / 1000;
  3477. let estimatedTotalTimeSeconds = totalElapsedSeconds / totalProgress;
  3478. let remainingTimeSeconds = estimatedTotalTimeSeconds - totalElapsedSeconds;
  3479.  
  3480. // 将剩余时间转换为天、时、分、秒
  3481. let remainingDays = Math.floor(remainingTimeSeconds / (60 * 60 * 24));
  3482. remainingTimeSeconds %= (60 * 60 * 24);
  3483.  
  3484. let remainingHours = Math.floor(remainingTimeSeconds / (60 * 60));
  3485. remainingTimeSeconds %= (60 * 60);
  3486.  
  3487. let remainingMinutes = Math.floor(remainingTimeSeconds / 60);
  3488. let remainingSeconds = Math.floor(remainingTimeSeconds % 60);
  3489.  
  3490. // 计算下载速度
  3491. let loaded = prog * size / 100; // 已下载数据量
  3492. let currentTimeDiff = currentTime - prevTime; // 当前时间与上一次时间的差值
  3493. let loadedDiff = loaded - prevLoaded; // 当前已下载数据量与上一次的差值
  3494. let downloadSpeed = (currentTimeDiff !== 0) ? loadedDiff / (currentTimeDiff / 1000) : 0; // 下载速度(单位:字节/秒)
  3495.  
  3496. // 更新上一次的数据
  3497. prevLoaded = loaded;
  3498. prevTime = currentTime;
  3499.  
  3500. // 更改界面
  3501. o.link.hide();
  3502. o.tip.hide();
  3503. o.stop.show();
  3504. o.copy.hide();
  3505. o.progress.show();
  3506.  
  3507. // 更新进度条
  3508. $width.css('width', prog + '%');
  3509.  
  3510. // 更新进度条文本
  3511. let timeText = '';
  3512. if (Number.isFinite(remainingDays) && remainingDays > 0) {
  3513. timeText = remainingDays + '天 ' + base.repairTimer(remainingHours) + '时:' + base.repairTimer(remainingMinutes) + '分:' + base.repairTimer(remainingSeconds) + '秒';
  3514. } else if (Number.isFinite(remainingHours) && remainingHours > 0) {
  3515. timeText = base.repairTimer(remainingHours) + '时:' + base.repairTimer(remainingMinutes) + '分:' + base.repairTimer(remainingSeconds) + '秒';
  3516. } else if (Number.isFinite(remainingMinutes) && remainingMinutes > 0) {
  3517. timeText = base.repairTimer(remainingMinutes) + '分:' + base.repairTimer(remainingSeconds) + '秒';
  3518. } else if (Number.isFinite(remainingSeconds) && remainingSeconds > 0) {
  3519. timeText = remainingSeconds + '秒';
  3520. } else if (Number.isFinite(remainingSeconds) && remainingSeconds === 0) {
  3521. timeText = '即将完成';
  3522. } else {
  3523. timeText = '计算中...';
  3524. }
  3525.  
  3526. let speedText = '';
  3527. speedText = base.sizeFormat(downloadSpeed)
  3528.  
  3529. $text.text(prog + '% | 剩余时间:' + timeText + ' | 速度:' + speedText + '/秒');
  3530.  
  3531. if (prog === 100) {
  3532. setTimeout(function () {
  3533. clearInterval(ins[index]);
  3534. progress[index] = 0;
  3535. o.item.find('.pl-progress-stop').hide();
  3536. o.howidm.hide();
  3537. $text.text('下载完成了!浏览器下载框应该弹出来了哦~');
  3538. o.back.show()
  3539. setTimeout(function () {
  3540. o.link.text('重新下载').animate({ opacity: '1' }, "slow");
  3541. }, 3000)
  3542. }, 3000)
  3543. }
  3544. }, 500);
  3545. });
  3546. doc.on('click', '.listener-retry', async function (e) {
  3547. let o = _factory(e);
  3548. o.tip.hide();
  3549. o.link.show();
  3550. });
  3551. doc.on('click', '.listener-how', async function (e) {
  3552. let o = _factory(e);
  3553. let index = o.link[0].dataset.index;
  3554. if (request[index]) {
  3555. request[index].abort();
  3556. clearInterval(ins[index]);
  3557. o.progress.hide();
  3558. o.tip.show();
  3559. }
  3560.  
  3561. });
  3562. doc.on('click', '.listener-stop', async function (e) {
  3563. let o = _factory(e);
  3564. let index = o.link[0].dataset.index;
  3565. if (request[index]) {
  3566. request[index].abort();
  3567. clearInterval(ins[index]);
  3568. o.item.find('.pl-progress-inner-text').text('正在取消...');
  3569. o.item.find('.pl-progress-inner').css('width', 100 + '%');
  3570. setTimeout(function () {
  3571. o.tip.hide();
  3572. o.back.hide();
  3573. o.link.show(0);
  3574. o.copy.show();
  3575. o.progress.hide();
  3576. o.stop.hide();
  3577. }, 1050)
  3578. }
  3579. });
  3580. doc.on('click', '.listener-back', async function (e) {
  3581. let o = _factory(e);
  3582. o.progress.hide();
  3583. o.tip.hide();
  3584. o.link.show();
  3585. o.copy.show();
  3586. o.stop.hide();
  3587. o.back.hide();
  3588. });
  3589. doc.on('click', '.listener-link-api-btn', async function (e) {
  3590. base.setClipboard(e.target.dataset.filename);
  3591. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  3592. setTimeout(
  3593. function () {
  3594. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  3595. }, 2000
  3596. )
  3597. });
  3598. doc.on('click', '.listener-link-aria, .listener-copy-all', function (e) {
  3599. e.preventDefault();
  3600. base.setClipboard(decodeURIComponent(e.target.dataset.link));
  3601. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  3602. setTimeout(
  3603. function () {
  3604. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  3605. }, 2000
  3606. )
  3607. });
  3608. doc.on('click', '.listener-link-rpc', async function (e) {
  3609. e.preventDefault();
  3610. let target = $(e.currentTarget);
  3611.  
  3612. target.find('.icon').remove();
  3613. target.find('.pl-loading').remove();
  3614. target.prepend(base.createLoading());
  3615.  
  3616. let res = await ali.sendLinkToRPC(e.currentTarget.dataset.filename, e.currentTarget.dataset.link);
  3617. if (res === 'success') {
  3618. $('.listener-rpc-task').show();
  3619. target.removeClass('pl-btn-danger').html('发送成功了!快去看看吧~').animate({ opacity: '0.5' }, "slow");
  3620. } else if (res === 'assistant') {
  3621. target.addClass('pl-btn-danger').html(`${pan.init[5]}👉<a href="${pan.assistant}" target="_blank" class="pl-a">点击此处安装</a>👈`);
  3622. } else {
  3623. target.addClass('pl-btn-danger').text('发送失败,检查一下您的RPC配置信息哦!').animate({ opacity: '0.5' }, "slow");
  3624. }
  3625. });
  3626. doc.on('click', '.listener-send-rpc', function (e) {
  3627. $('.listener-link-rpc').click();
  3628. $(e.target).text('发送完成,发送结果见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  3629. });
  3630. doc.on('click', '.listener-download-all', function (e) {
  3631. $('.pl-item-link').click();
  3632. $(e.target).text('下载开始,下载进度见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  3633. setTimeout(
  3634. function () {
  3635. $(e.target).text('下载全部链接').animate({ opacity: '1' }, "slow");
  3636. }, 2000
  3637. )
  3638. });
  3639. doc.on('click', '.listener-open-setting', function () {
  3640. base.showSetting();
  3641. });
  3642. doc.on('click', '.listener-open-updatelog', function () {
  3643. base.showUpdateLog();
  3644. });
  3645. doc.on('click', '.listener-rpc-task', function () {
  3646. let rpc = JSON.stringify({
  3647. domain: base.getValue('setting_rpc_domain'),
  3648. port: base.getValue('setting_rpc_port'),
  3649. }), url = `${pan.d}/?rpc=${base.encode(rpc)}#${base.getValue('setting_rpc_token')}`;
  3650. GM_openInTab(url, { active: true });
  3651. });
  3652. document.documentElement.addEventListener('mouseup', function (e) {
  3653. if (e.target.nodeName === 'A' && ~e.target.className.indexOf('pl-a')) {
  3654. e.stopPropagation();
  3655. }
  3656. }, true);
  3657. },
  3658.  
  3659. async getRealLink(d, f) {
  3660. let authorization = `${base.getStorage('token').token_type} ${base.getStorage('token').access_token}`;
  3661. let res = await base.post(pan.pcs[1], {
  3662. drive_id: d,
  3663. file_id: f
  3664. }, {
  3665. authorization,
  3666. "content-type": "application/json;charset=utf-8",
  3667. "referer": "https://www.aliyundrive.com/",
  3668. "x-canary": "client=windows,app=adrive,version=v6.0.0"
  3669. });
  3670. if (res.code === 'AccessTokenInvalid') {
  3671. return message.error('提示:<br/>Token过期了,请刷新网页后再试');
  3672. }
  3673. if (res.url) {
  3674. return res.url;
  3675. }
  3676. return '';
  3677. },
  3678.  
  3679. removeAD() {
  3680. base.waitForKeyElements('[class*="share-list-banner"]', function (tag) {
  3681. tag.fadeToggle();
  3682. }, true);
  3683. base.waitForKeyElements('[class*="to-app"]', function (tag) {
  3684. tag.fadeToggle();
  3685. }, true);
  3686. base.waitForKeyElements('[class*="btn-mobile-save"]', function (tag) {
  3687. tag.fadeToggle();
  3688. });
  3689. base.waitForKeyElements('div[class*="text"]', function (tag) {
  3690. if (tag[0].innerHTML.match("SVIP"))
  3691. tag.fadeToggle();
  3692. }, true);
  3693. base.waitForKeyElements('[class*="SplashScreenImg--close"]', function (tag) {
  3694. tag[0].click();
  3695. }, true);
  3696. base.waitForKeyElements('[class*="container"]', function (tag) {
  3697. tag.find('[class^="icon-close"]').click();
  3698. }, true);
  3699. base.waitForKeyElements('[class*="popup_main_close"]', function (tag) {
  3700. tag[0].click();
  3701. }, true);
  3702. },
  3703.  
  3704. addButton() {
  3705. if (document.getElementById("pl-button-link")) {
  3706. document.getElementById("pl-button-link").remove()
  3707. }
  3708. if (!pt) return;
  3709. let $toolWrap;
  3710. let svg = `<svg class="ali-btn-icon" style="margin-right: 3px;" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M853.333 938.667H170.667a85.333 85.333 0 0 1-85.334-85.334v-384A85.333 85.333 0 0 1 170.667 384H288a32 32 0 0 1 0 64H170.667a21.333 21.333 0 0 0-21.334 21.333v384a21.333 21.333 0 0 0 21.334 21.334h682.666a21.333 21.333 0 0 0 21.334-21.334v-384A21.333 21.333 0 0 0 853.333 448H736a32 32 0 0 1 0-64h117.333a85.333 85.333 0 0 1 85.334 85.333v384a85.333 85.333 0 0 1-85.334 85.334z" fill="#FFFFFF"></path><path d="M715.03 543.552a32.81 32.81 0 0 0-46.251 0L554.005 657.813v-540.48a32 32 0 0 0-64 0v539.734L375.893 543.488a32.79 32.79 0 0 0-46.229 0 32.427 32.427 0 0 0 0 46.037l169.557 168.811a32.81 32.81 0 0 0 46.251 0l169.557-168.81a32.47 32.47 0 0 0 0-45.974z" fill="#FFFFFF"></path></svg>`
  3711. let $button = $(`<div id="pl-button-link" class="ali-button pl-button"><span data-role="icon" data-render-as="svg" class="icon">${svg}下载助手</span><ul class="pl-dropdown-menu" style="top: 30px; right: 0;"><li class="pl-dropdown-menu-item pl-button-mode" data-mode="api">API下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="aria" >Aria下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="rpc">RPC下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="curl">cURL下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="bc" >BC下载</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-setting">助手设置</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-updatelog">更新日志</li></ul></div>`);
  3712. if (pt === 'home') {
  3713. base.listenElement(pan.btn.home, function () {
  3714. $toolWrap = $(pan.btn.home);
  3715. $('.pl-button').length === 0 && $toolWrap.append($button);
  3716. })
  3717. }
  3718. if (pt === 'share') {
  3719. $button = $(`<div id="pl-button-link" class="ali-button pl-button"><span data-role="icon" data-render-as="svg" class="icon">${svg}下载助手</span><ul class="pl-dropdown-menu" style="top: 30px; right: 16px;"><li class="pl-dropdown-menu-item pl-button-mode" data-mode="api">API下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="aria" >Aria下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="rpc">RPC下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="curl">cURL下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="bc" >BC下载</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-setting">助手设置</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-updatelog">更新日志</li></ul></div>`);
  3720. $button.css({ 'margin-right': '10px', "height": "36px", "width": "auto", "padding": "1px 30px" });
  3721. base.listenElement(pan.btn.share, function () {
  3722. $toolWrap = $(pan.btn.share);
  3723. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  3724. })
  3725. }
  3726. base.createDownloadIframe();
  3727. },
  3728.  
  3729. addInitButton() {
  3730. if (document.getElementById("pl-button-link")) {
  3731. document.getElementById("pl-button-link").remove()
  3732. }
  3733. if (!pt) return;
  3734. let $toolWrap;
  3735. let $button = $(`<div id="pl-button-link" class="ali-button pl-button-init"><span data-role="icon" data-render-as="svg" class="icon"><svg class="ali-btn-icon" style="margin-right: 3px;" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M853.333 938.667H170.667a85.333 85.333 0 0 1-85.334-85.334v-384A85.333 85.333 0 0 1 170.667 384H288a32 32 0 0 1 0 64H170.667a21.333 21.333 0 0 0-21.334 21.333v384a21.333 21.333 0 0 0 21.334 21.334h682.666a21.333 21.333 0 0 0 21.334-21.334v-384A21.333 21.333 0 0 0 853.333 448H736a32 32 0 0 1 0-64h117.333a85.333 85.333 0 0 1 85.334 85.333v384a85.333 85.333 0 0 1-85.334 85.334z" fill="#FFFFFF"></path><path d="M715.03 543.552a32.81 32.81 0 0 0-46.251 0L554.005 657.813v-540.48a32 32 0 0 0-64 0v539.734L375.893 543.488a32.79 32.79 0 0 0-46.229 0 32.427 32.427 0 0 0 0 46.037l169.557 168.811a32.81 32.81 0 0 0 46.251 0l169.557-168.81a32.47 32.47 0 0 0 0-45.974z" fill="#FFFFFF"></path></svg>点我点亮</span></div>`);
  3736. $button.css({ "width": "auto" });
  3737. if (pt === 'home') {
  3738. base.listenElement(pan.btn.home, function () {
  3739. $toolWrap = $(pan.btn.home);
  3740. $('.pl-button-init').length === 0 && $toolWrap.append($button);
  3741. })
  3742. }
  3743. if (pt === 'share') {
  3744. $button = $(`<div id="pl-button-link" class="ali-button pl-button-init"><span data-role="icon" data-render-as="svg" class="icon"><svg class="ali-btn-icon" style="margin-right: 3px;" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M853.333 938.667H170.667a85.333 85.333 0 0 1-85.334-85.334v-384A85.333 85.333 0 0 1 170.667 384H288a32 32 0 0 1 0 64H170.667a21.333 21.333 0 0 0-21.334 21.333v384a21.333 21.333 0 0 0 21.334 21.334h682.666a21.333 21.333 0 0 0 21.334-21.334v-384A21.333 21.333 0 0 0 853.333 448H736a32 32 0 0 1 0-64h117.333a85.333 85.333 0 0 1 85.334 85.333v384a85.333 85.333 0 0 1-85.334 85.334z" fill="#FFFFFF"></path><path d="M715.03 543.552a32.81 32.81 0 0 0-46.251 0L554.005 657.813v-540.48a32 32 0 0 0-64 0v539.734L375.893 543.488a32.79 32.79 0 0 0-46.229 0 32.427 32.427 0 0 0 0 46.037l169.557 168.811a32.81 32.81 0 0 0 46.251 0l169.557-168.81a32.47 32.47 0 0 0 0-45.974z" fill="#FFFFFF"></path></svg>点我点亮</span></div>`);
  3745. $button.css({ 'margin-right': '10px', "height": "36px", "padding": "1px 30px", "width": "auto" });
  3746. base.listenElement(pan.btn.share, function () {
  3747. $toolWrap = $(pan.btn.share);
  3748. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  3749. })
  3750. }
  3751. $button.click(function () { base.initDialog() });
  3752. },
  3753.  
  3754. async getPCSLink() {
  3755. let reactDomGrid = document.querySelector(pan.dom.grid);
  3756. if (reactDomGrid) {
  3757. let dialog = await Swal.fire({
  3758. title: '提示',
  3759. html: '<div style="display: flex;align-items: center;justify-content: center;">请先切换到&nbsp;&nbsp;<svg class="icon" class="icon--D3kMk " viewBox="0 0 1024 1024" width="20" height="20"><use xlink:href="#PDSDrag"></use></svg>&nbsp;<b>列表视图</b>&nbsp;&nbsp;后获取下载链接</div>',
  3760. icon: 'info',
  3761. showCloseButton: true,
  3762. showDenyButton: true,
  3763. heightAuto: false,
  3764. scrollbarPadding: false,
  3765. confirmButtonText: '切换',
  3766. denyButtonText: '不要'
  3767. });
  3768. if (dialog.isConfirmed) {
  3769. document.querySelector(pan.dom.switch).click();
  3770. return message.success('提示:<br/>切换为列表视图成功<br/>请再获取一次下载链接吧~');
  3771. }
  3772. return false;
  3773. }
  3774. selectList = this.getSelectedList();
  3775. if (selectList.length === 0) {
  3776. return message.error('提示:<br/>请先勾选要下载的文件哦~');
  3777. }
  3778. if (this.isOnlyFolder()) {
  3779. return message.error('提示:<br/>请打开文件夹后再勾选文件~');
  3780. }
  3781. if (pt === 'share') {
  3782. if (selectList.length > 20) {
  3783. return message.error('提示:<br/>一次最多只能勾选 20 个文件哦!');
  3784. }
  3785. try {
  3786. let authorization = `${base.getStorage('token').token_type} ${base.getStorage('token').access_token}`;
  3787. let xShareToken = base.getStorage('shareToken').share_token;
  3788.  
  3789. for (let i = 0; i < selectList.length; i++) {
  3790. let res = await base.post(pan.pcs[0], {
  3791. expire_sec: 600,
  3792. file_id: selectList[i].fileId,
  3793. share_id: selectList[i].shareId
  3794. }, {
  3795. authorization,
  3796. "content-type": "application/json;charset=utf-8",
  3797. "x-share-token": xShareToken
  3798. });
  3799. if (res.download_url) {
  3800. selectList[i].downloadUrl = res.download_url;
  3801. }
  3802. }
  3803. } catch (e) {
  3804. return message.error('提示:<br/>请先登录网盘~');
  3805. }
  3806. } else {
  3807. if (selectList.length > 20) {
  3808. return message.error('提示:<br/>每次最多只能选 20 个文件哦~');
  3809. }
  3810. let noUrlSelectList = selectList.filter(v => !Boolean(v.url))
  3811. let queue = [];
  3812. noUrlSelectList.forEach((item, index) => {
  3813. queue.push(this.getRealLink(item.driveId, item.fileId));
  3814. });
  3815.  
  3816. const res = await Promise.all(queue);
  3817. res.forEach((val, index) => {
  3818. noUrlSelectList[index].url = val;
  3819. });
  3820.  
  3821. }
  3822. let html = this.generateDom(selectList);
  3823. this.showMainDialog(pan[mode][0], html, pan[mode][1]);
  3824. },
  3825.  
  3826. generateDom(list) {
  3827. let content = '<div class="pl-main">';
  3828. let alinkAllText = '';
  3829. list.forEach((v, i) => {
  3830. if (v.type === 'folder') return;
  3831. let filename = v.name;
  3832. let fid = v.fileId;
  3833. let did = v.driveId;
  3834. let size = base.sizeFormat(v.size);
  3835. let dlink = v.downloadUrl || v.url;
  3836. if (mode === 'api') {
  3837. alinkAllText += dlink + '\r\n';
  3838. content += `<div class="pl-item">
  3839. <div class="pl-item-name listener-tip" data-size="${size}" >${filename}</div>
  3840. <a class="pl-item-link pl-a listener-link-api" href="${dlink}" data-did="${did}" data-fid="${fid}" data-filename="${filename}" data-link="${dlink}" data-size="${v.size}" data-index="${i}">${dlink}<br/>下载 ${filename}</a>
  3841. <div class="pl-item-copy pl-btn-primary listener-link-api-btn" data-filename="${filename}">复制文件名</div>
  3842. <div class="pl-item-tip" style="display: none"><span><span class="pl-ext"></span></span> <span class="pl-back listener-back">返回</span></div>
  3843. <div class="pl-item-progress" style="display: none">
  3844. <div class="pl-progress">
  3845. <div class="pl-progress-outer"></div>
  3846. <div class="pl-progress-inner" style="width:5%">
  3847. <div class="pl-progress-inner-text">正在加载进度...0%</div>
  3848. </div>
  3849. </div>
  3850. <span class="pl-progress-stop listener-stop">取消下载</span>
  3851. `;
  3852. content += `<span class="pl-progress-tip" style="display: none" >使用自带浏览器下载</span>
  3853. <span class="pl-progress-back pl-back listener-back" style="display: none">返回</span>
  3854. <span class="pl-progress-how listener-how" style="display: none">如何唤起IDM?</span>
  3855. `;
  3856. content += `</div></div>`;
  3857. }
  3858. if (mode === 'aria') {
  3859. let alink = this.convertLinkToAria(dlink, filename, navigator.userAgent);
  3860. alinkAllText += alink + '\r\n';
  3861. content += `<div class="pl-item">
  3862. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3863. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制aria2c链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  3864. }
  3865. if (mode === 'rpc') {
  3866. content += `<div class="pl-item">
  3867. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3868. <button class="pl-item-link listener-link-rpc pl-btn-primary pl-btn-info" data-filename="${filename}" data-link="${dlink.replace(' ', '%20')}"><em class="icon icon-device"></em><span style="margin-left: 5px;">将 ${filename} 推送到 RPC 下载器</span></button></div>`;
  3869. }
  3870. if (mode === 'curl') {
  3871. let alink = this.convertLinkToCurl(dlink, filename, navigator.userAgent);
  3872. alinkAllText += alink + '\r\n';
  3873. content += `<div class="pl-item">
  3874. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3875. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制curl链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  3876. }
  3877. if (mode === 'bc') {
  3878. let alink = this.convertLinkToBC(dlink, filename, navigator.userAgent);
  3879. content += `<div class="pl-item">
  3880. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  3881. <a class="pl-item-link" href="${decodeURIComponent(alink)}" title="点击用比特彗星下载" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>下载 ${filename}</a> </div>`;
  3882. }
  3883. });
  3884. content += '</div>';
  3885. if (mode === 'api')
  3886. content += `<div class="pl-extra"><button class="pl-btn-primary listener-download-all">下载全部链接</button></div>`;
  3887. if (mode === 'aria')
  3888. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部命令行</button></div>`;
  3889. if (mode === 'rpc') {
  3890. let rpc = base.getValue('setting_rpc_domain') + ':' + base.getValue('setting_rpc_port') + base.getValue('setting_rpc_path');
  3891. content += `<div class="pl-extra"><button class="pl-btn-primary listener-send-rpc">发送全部链接</button><button title="${rpc}" class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px">设置 RPC 参数(当前为:${rpc})</button><button class="pl-btn-primary pl-btn-success listener-rpc-task" style="margin-left: 10px;display: none">查看下载任务</button></div>`;
  3892. }
  3893. if (mode === 'curl')
  3894. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部链接</button><button class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px;">前往助手设置修改当前终端类型(${terminalType[base.getValue('setting_terminal_type')]})</button></div>`;
  3895. return content;
  3896. },
  3897.  
  3898. async sendLinkToRPC(filename, link) {
  3899. let rpc = {
  3900. domain: base.getValue('setting_rpc_domain'),
  3901. port: base.getValue('setting_rpc_port'),
  3902. path: base.getValue('setting_rpc_path'),
  3903. token: base.getValue('setting_rpc_token'),
  3904. dir: base.getValue('setting_rpc_dir'),
  3905. };
  3906.  
  3907. let url = `${rpc.domain}:${rpc.port}${rpc.path}`;
  3908. let rpcData = {
  3909. id: new Date().getTime(),
  3910. jsonrpc: '2.0',
  3911. method: 'aria2.addUri',
  3912. params: [`token:${rpc.token}`, [link], {
  3913. dir: rpc.dir,
  3914. out: filename,
  3915. header: [`Referer: https://${location.host}/`]
  3916. }]
  3917. };
  3918. try {
  3919. let res = await base.post(url, rpcData, { "Referer": `https://${location.host}/` }, '');
  3920. if (res.result) return 'success';
  3921. return 'fail';
  3922. } catch (e) {
  3923. return 'fail';
  3924. }
  3925. },
  3926.  
  3927. getSelectedList() {
  3928. try {
  3929. let selectedList = [];
  3930. let reactDom = document.querySelector(pan.dom.list);
  3931. let reactObj = base.findReact(reactDom, 1);
  3932. let props = reactObj.pendingProps;
  3933. if (props) {
  3934. let fileList = props.dataSource || [];
  3935. let selectedKeys = props.selectedKeys.split(',');
  3936. fileList.forEach(function (val) {
  3937. if (selectedKeys.includes(val.fileId)) {
  3938. selectedList.push(val);
  3939. }
  3940. });
  3941. }
  3942. return selectedList;
  3943. } catch (e) {
  3944. return [];
  3945. }
  3946. },
  3947.  
  3948. detectPage() {
  3949. let path = location.pathname;
  3950. if (/^\/(drive)/.test(path)) return 'home';
  3951. if (/^\/(s|share)\//.test(path)) return 'share';
  3952. return '';
  3953. },
  3954.  
  3955. isOnlyFolder() {
  3956. for (let i = 0; i < selectList.length; i++) {
  3957. if (selectList[i].type === 'file') return false;
  3958. }
  3959. return true;
  3960. },
  3961.  
  3962. showMainDialog(title, html, footer) {
  3963. Swal.fire({
  3964. title,
  3965. html,
  3966. footer,
  3967. allowOutsideClick: false,
  3968. showCloseButton: true,
  3969. position: 'center',
  3970. width,
  3971. padding: '15px 20px 5px',
  3972. customClass,
  3973. confirmButtonText: '关闭',
  3974. });
  3975. },
  3976.  
  3977. async initPanLinker() {
  3978. pt = this.detectPage();
  3979. base.createTip();
  3980. base.registerMenuCommand();
  3981. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  3982. let res = await base.post(`https://api.youxiaohou.com/config/ali/?ver=${version}&a=${author}`, {}, {}, 'text');
  3983. pan = JSON.parse(base.decode(res));
  3984. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  3985. let res = await base.post(`https://api.youxiaohou.com/config/v2/ali/?ver=${version}&a=${author}`, {}, {}, 'text');
  3986. pan = JSON.parse(base.decode(res));
  3987. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  3988. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/ali.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  3989. pan = JSON.parse(res);
  3990. } else {
  3991. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/ali.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  3992. pan = JSON.parse(res);
  3993. base.setValue('setting_youxiaohou_server', 'v2');
  3994. }
  3995. Object.freeze && Object.freeze(pan);
  3996. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  3997. this.addButton();
  3998. this.addPageListener();
  3999. } else {
  4000. this.addInitButton();
  4001. }
  4002. }
  4003. };
  4004.  
  4005. //天翼云盘
  4006. let tianyi = {
  4007.  
  4008. convertLinkToAria(link, filename, ua) {
  4009. filename = base.fixFilename(filename);
  4010. return encodeURIComponent(`aria2c "${link}" --out "${filename}"`);
  4011. },
  4012.  
  4013. convertLinkToBC(link, filename, ua) {
  4014. let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}ZZ`;
  4015. return encodeURIComponent(`bc://http/${base.encode(bc)}`);
  4016. },
  4017.  
  4018. convertLinkToCurl(link, filename, ua) {
  4019. let terminal = base.getValue('setting_terminal_type');
  4020. filename = base.fixFilename(filename);
  4021. return encodeURIComponent(`${terminal !== 'wp' ? 'curl' : 'curl.exe'} -L -C - "${link}" -o "${filename}"`);
  4022. },
  4023.  
  4024. addPageListener() {
  4025. /*
  4026. 防止代码因其他原因被执行多次
  4027. 这段代码出自 Via轻插件,作者谷花泰
  4028. */
  4029. const key = encodeURIComponent('(改)网盘直链下载助手:天翼云盘');
  4030. if (window[key]) return;
  4031. window[key] = true;
  4032.  
  4033. doc.on('click', '.pl-button-mode', function (e) {
  4034. mode = e.target.dataset.mode;
  4035. if (!mode) return;
  4036. Swal.fire({
  4037. heightAuto: false,
  4038. scrollbarPadding: false,
  4039. showConfirmButton: false,
  4040. html: `链接获取中`,
  4041. willOpen: function () {
  4042. Swal.showLoading();
  4043. }
  4044. });
  4045. tianyi.getPCSLink();
  4046. });
  4047. doc.on('click', '.listener-link-api', async function (e) {
  4048. e.preventDefault();
  4049. $('#downloadIframe').attr('src', e.currentTarget.dataset.link);
  4050. });
  4051. doc.on('click', '.listener-link-aria, .listener-copy-all', function (e) {
  4052. e.preventDefault();
  4053. base.setClipboard(decodeURIComponent(e.target.dataset.link));
  4054. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  4055. setTimeout(
  4056. function () {
  4057. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  4058. }, 2000
  4059. )
  4060. });
  4061. doc.on('click', '.listener-link-rpc', async function (e) {
  4062. e.preventDefault();
  4063. let target = $(e.currentTarget);
  4064.  
  4065. target.find('.icon').remove();
  4066. target.find('.pl-loading').remove();
  4067. target.prepend(base.createLoading());
  4068.  
  4069. let res = await tianyi.sendLinkToRPC(e.currentTarget.dataset.filename, e.currentTarget.dataset.link);
  4070. if (res === 'success') {
  4071. $('.listener-rpc-task').show();
  4072. target.removeClass('pl-btn-danger').html('发送成功了!快去看看吧~').animate({ opacity: '0.5' }, "slow");
  4073. } else if (res === 'assistant') {
  4074. target.addClass('pl-btn-danger').html(`${pan.init[5]}👉<a href="${pan.assistant}" target="_blank" class="pl-a">点击此处安装</a>👈`);
  4075. } else {
  4076. target.addClass('pl-btn-danger').text('发送失败,检查一下您的RPC配置信息哦!').animate({ opacity: '0.5' }, "slow");
  4077. }
  4078. });
  4079. doc.on('click', '.listener-send-rpc', function (e) {
  4080. $('.listener-link-rpc').click();
  4081. $(e.target).text('发送完成,发送结果见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  4082. });
  4083. doc.on('click', '.listener-open-setting', function () {
  4084. base.showSetting();
  4085. });
  4086. doc.on('click', '.listener-open-updatelog', function () {
  4087. base.showUpdateLog();
  4088. });
  4089. doc.on('click', '.listener-rpc-task', function () {
  4090. let rpc = JSON.stringify({
  4091. domain: base.getValue('setting_rpc_domain'),
  4092. port: base.getValue('setting_rpc_port'),
  4093. }), url = `${pan.d}/?rpc=${base.encode(rpc)}#${base.getValue('setting_rpc_token')}`;
  4094. GM_openInTab(url, { active: true });
  4095. });
  4096. },
  4097.  
  4098. removeAD() {
  4099. base.waitForKeyElements(".advertising-mask", function (tag) {
  4100. tag.fadeToggle();
  4101. }, true);
  4102. },
  4103.  
  4104. addButton() {
  4105. if (document.getElementById("pl-button-link")) {
  4106. document.getElementById("pl-button-link").remove()
  4107. }
  4108. if (!pt) return;
  4109. let $toolWrap;
  4110. let $button = $(`<div class="tianyi-button pl-button" id="pl-button-link">下载助手<ul class="pl-dropdown-menu" style="top: 26px;"><li class="pl-dropdown-menu-item pl-button-mode" data-mode="api">API下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="aria" >Aria下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="rpc">RPC下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="curl">cURL下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="bc" >BC下载</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-setting">助手设置</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-updatelog">更新日志</li></ul></div>`);
  4111. if (pt === 'home') {
  4112. base.listenElement(pan.btn.home, function () {
  4113. $toolWrap = $(pan.btn.home);
  4114. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  4115. })
  4116. }
  4117. if (pt === 'share') {
  4118. base.listenElement(pan.btn.share, function () {
  4119. $toolWrap = $(pan.btn.share);
  4120. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  4121. })
  4122. }
  4123. base.createDownloadIframe();
  4124. },
  4125.  
  4126. addInitButton() {
  4127. if (document.getElementById("pl-button-link")) {
  4128. document.getElementById("pl-button-link").remove()
  4129. }
  4130. if (!pt) return;
  4131. let $toolWrap;
  4132. let $button = $(`<div class="tianyi-button pl-button-init" id="pl-button-link">点我点亮</div>`);
  4133. if (pt === 'home') {
  4134. base.listenElement(pan.btn.home, function () {
  4135. $toolWrap = $(pan.btn.home);
  4136. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  4137. })
  4138. }
  4139. if (pt === 'share') {
  4140. $button.css({ 'margin-right': '10px' });
  4141. base.listenElement(pan.btn.share, function () {
  4142. $toolWrap = $(pan.btn.share);
  4143. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  4144. })
  4145. }
  4146. $button.click(function () { base.initDialog() });
  4147. },
  4148.  
  4149. async getToken() {
  4150. let res = await base.getFinalUrl(pan.pcs[1], {});
  4151. let accessToken = res.match(/accessToken=(\w+)/)?.[1];
  4152. accessToken && base.setStorage('accessToken', accessToken);
  4153. return accessToken;
  4154. },
  4155.  
  4156. async getFileUrlByOnce(item, index, token) {
  4157. try {
  4158. if (item.downloadUrl) return {
  4159. index,
  4160. downloadUrl: item.downloadUrl
  4161. };
  4162. let time = Date.now(),
  4163. fileId = item.fileId,
  4164. o = "AccessToken=" + token + "&Timestamp=" + time + "&fileId=" + fileId,
  4165. url = pan.pcs[2] + '?fileId=' + fileId;
  4166. if (item.shareId) {
  4167. o = "AccessToken=" + token + "&Timestamp=" + time + "&dt=1&fileId=" + fileId + "&shareId=" + item.shareId;
  4168. url += '&dt=1&shareId=' + item.shareId;
  4169. }
  4170. let sign = md5(o).toString();
  4171. let res = await base.get(url, {
  4172. "accept": "application/json;charset=UTF-8",
  4173. "sign-type": 1,
  4174. "accesstoken": token,
  4175. "timestamp": time,
  4176. "signature": sign
  4177. });
  4178. if (res.res_code === 0) {
  4179. return {
  4180. index,
  4181. downloadUrl: res.fileDownloadUrl
  4182. };
  4183. } else if (res.errorCode === 'InvalidSessionKey') {
  4184. return {
  4185. index,
  4186. downloadUrl: '提示:<br/>请先登录网盘~'
  4187. };
  4188. } else if (res.res_code === 'ShareNotFoundFlatDir') {
  4189. return {
  4190. index,
  4191. downloadUrl: '提示:<br/>请先[转存]文件,之后再👉前往[我的网盘]中下载哦~'
  4192. };
  4193. } else {
  4194. return {
  4195. index,
  4196. downloadUrl: '获取下载地址失败,刷新后再试试吧~' + (res.res_code ? res.res_code : "")
  4197. };
  4198. }
  4199. } catch (e) {
  4200. return {
  4201. index,
  4202. downloadUrl: '获取下载地址失败,刷新后再试试吧~'
  4203. };
  4204. }
  4205. },
  4206.  
  4207. async getPCSLink() {
  4208. selectList = this.getSelectedList();
  4209. if (selectList.length === 0) {
  4210. return message.error('提示:<br/>请先勾选要下载的文件哦~');
  4211. }
  4212. if (this.isOnlyFolder()) {
  4213. return message.error('提示:<br/>请打开文件夹后再勾选文件~');
  4214. }
  4215. let token = base.getStorage('accessToken') || await this.getToken();
  4216. if (!token) {
  4217. return message.error('提示:<br/>请先登录网盘~');
  4218. }
  4219. let queue = [];
  4220. for (const [index, item] of selectList.entries()) {
  4221. queue.push(this.getFileUrlByOnce(item, index, token));
  4222. }
  4223.  
  4224. const res = await Promise.all(queue);
  4225. res.forEach(val => {
  4226. selectList[val.index].downloadUrl = val.downloadUrl;
  4227. });
  4228.  
  4229. let html = this.generateDom(selectList);
  4230. this.showMainDialog(pan[mode][0], html, pan[mode][1]);
  4231. },
  4232.  
  4233. generateDom(list) {
  4234. let content = '<div class="pl-main">';
  4235. let alinkAllText = '';
  4236. list.forEach((v, i) => {
  4237. if (v.isFolder) return;
  4238. let filename = v.fileName;
  4239. let size = base.sizeFormat(v.size);
  4240. let dlink = v.downloadUrl;
  4241. if (mode === 'api') {
  4242. content += `<div class="pl-item">
  4243. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4244. <a class="pl-item-link listener-link-api" data-filename="${filename}" data-link="${dlink}" data-index="${i}">${dlink}<br/>下载 ${filename}</a>
  4245. </div>`;
  4246. }
  4247. if (mode === 'aria') {
  4248. let alink = this.convertLinkToAria(dlink, filename, navigator.userAgent);
  4249. alinkAllText += alink + '\r\n';
  4250. content += `<div class="pl-item">
  4251. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4252. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制aria2c链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  4253. }
  4254. if (mode === 'rpc') {
  4255. content += `<div class="pl-item">
  4256. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4257. <button class="pl-item-link listener-link-rpc pl-btn-primary pl-btn-info" data-filename="${filename}" data-link="${dlink}"><em class="icon icon-device"></em><span style="margin-left: 5px;">将 ${filename} 推送到 RPC 下载器</span></button></div>`;
  4258. }
  4259. if (mode === 'curl') {
  4260. let alink = this.convertLinkToCurl(dlink, filename, navigator.userAgent);
  4261. alinkAllText += alink + '\r\n';
  4262. content += `<div class="pl-item">
  4263. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4264. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制curl链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  4265. }
  4266. if (mode === 'bc') {
  4267. let alink = this.convertLinkToBC(dlink, filename, navigator.userAgent);
  4268. content += `<div class="pl-item">
  4269. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4270. <a class="pl-item-link" href="${decodeURIComponent(alink)}" title="点击用比特彗星下载" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>下载 ${filename}</a> </div>`;
  4271. }
  4272. });
  4273. content += '</div>';
  4274. if (mode === 'aria')
  4275. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部命令行</button></div>`;
  4276. if (mode === 'rpc') {
  4277. let rpc = base.getValue('setting_rpc_domain') + ':' + base.getValue('setting_rpc_port') + base.getValue('setting_rpc_path');
  4278. content += `<div class="pl-extra"><button class="pl-btn-primary listener-send-rpc">发送全部链接</button><button title="${rpc}" class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px">设置 RPC 参数(当前为:${rpc})</button><button class="pl-btn-primary pl-btn-success listener-rpc-task" style="margin-left: 10px;display: none">查看下载任务</button></div>`;
  4279. }
  4280. if (mode === 'curl')
  4281. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部链接</button><button class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px;">设置终端类型(当前为:${terminalType[base.getValue('setting_terminal_type')]})</button></div>`;
  4282. return content;
  4283. },
  4284.  
  4285. async sendLinkToRPC(filename, link) {
  4286. let rpc = {
  4287. domain: base.getValue('setting_rpc_domain'),
  4288. port: base.getValue('setting_rpc_port'),
  4289. path: base.getValue('setting_rpc_path'),
  4290. token: base.getValue('setting_rpc_token'),
  4291. dir: base.getValue('setting_rpc_dir'),
  4292. };
  4293.  
  4294. let url = `${rpc.domain}:${rpc.port}${rpc.path}`;
  4295. let rpcData = {
  4296. id: new Date().getTime(),
  4297. jsonrpc: '2.0',
  4298. method: 'aria2.addUri',
  4299. params: [`token:${rpc.token}`, [link], {
  4300. dir: rpc.dir,
  4301. out: filename,
  4302. header: []
  4303. }]
  4304. };
  4305. try {
  4306. let res = await base.post(url, rpcData, {}, '');
  4307. if (res.result) return 'success';
  4308. return 'fail';
  4309. } catch (e) {
  4310. return 'fail';
  4311. }
  4312. },
  4313.  
  4314. getSelectedList() {
  4315. try {
  4316. return document.querySelector(".c-file-list").__vue__.selectedList;
  4317. } catch (e) {
  4318. return [document.querySelector(".info-detail").__vue__.fileDetail];
  4319. }
  4320. },
  4321.  
  4322. detectPage() {
  4323. let path = location.pathname;
  4324. if (/^\/web\/main/.test(path)) return 'home';
  4325. if (/^\/web\/share/.test(path)) return 'share';
  4326. return '';
  4327. },
  4328.  
  4329. isOnlyFolder() {
  4330. for (let i = 0; i < selectList.length; i++) {
  4331. if (!selectList[i].isFolder) return false;
  4332. }
  4333. return true;
  4334. },
  4335.  
  4336. showMainDialog(title, html, footer) {
  4337. Swal.fire({
  4338. title,
  4339. html,
  4340. footer,
  4341. allowOutsideClick: false,
  4342. showCloseButton: true,
  4343. position: 'center',
  4344. width,
  4345. padding: '15px 20px 5px',
  4346. customClass,
  4347. confirmButtonText: '关闭',
  4348. });
  4349. },
  4350.  
  4351. async initPanLinker() {
  4352. pt = this.detectPage();
  4353. base.createTip();
  4354. base.registerMenuCommand();
  4355. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  4356. let res = await base.post(`https://api.youxiaohou.com/config/tianyi/?ver=${version}&a=${author}`, {}, {}, 'text');
  4357. pan = JSON.parse(base.decode(res));
  4358. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  4359. let res = await base.post(`https://api.youxiaohou.com/config/v2/tianyi/?ver=${version}&a=${author}`, {}, {}, 'text');
  4360. pan = JSON.parse(base.decode(res));
  4361. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  4362. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/tianyi.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  4363. pan = JSON.parse(res);
  4364. } else {
  4365. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/tianyi.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  4366. pan = JSON.parse(res);
  4367. base.setValue('setting_youxiaohou_server', 'v2');
  4368. }
  4369. Object.freeze && Object.freeze(pan);
  4370. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  4371. this.addButton();
  4372. this.addPageListener();
  4373. } else {
  4374. this.addInitButton();
  4375. }
  4376. this.getToken();
  4377. }
  4378. };
  4379.  
  4380. //迅雷云盘
  4381. let xunlei = {
  4382.  
  4383. convertLinkToAria(link, filename, ua) {
  4384. filename = base.fixFilename(filename);
  4385. return encodeURIComponent(`aria2c "${link}" --out "${filename}"`);
  4386. },
  4387.  
  4388. convertLinkToBC(link, filename, ua) {
  4389. let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}ZZ`;
  4390. return encodeURIComponent(`bc://http/${base.encode(bc)}`);
  4391. },
  4392.  
  4393. convertLinkToCurl(link, filename, ua) {
  4394. let terminal = base.getValue('setting_terminal_type');
  4395. filename = base.fixFilename(filename);
  4396. return encodeURIComponent(`${terminal !== 'wp' ? 'curl' : 'curl.exe'} -L -C - "${link}" -o "${filename}"`);
  4397. },
  4398.  
  4399. addPageListener() {
  4400. /*
  4401. 防止代码因其他原因被执行多次
  4402. 这段代码出自 Via轻插件,作者谷花泰
  4403. */
  4404. const key = encodeURIComponent('(改)网盘直链下载助手:迅雷云盘');
  4405. if (window[key]) return;
  4406. window[key] = true;
  4407.  
  4408. doc.on('click', '.pl-button-mode', function (e) {
  4409. mode = e.target.dataset.mode;
  4410. if (!mode) return;
  4411. Swal.fire({
  4412. heightAuto: false,
  4413. scrollbarPadding: false,
  4414. showConfirmButton: false,
  4415. html: `链接获取中`,
  4416. willOpen: function () {
  4417. Swal.showLoading();
  4418. }
  4419. });
  4420. xunlei.getPCSLink();
  4421. });
  4422. doc.on('click', '.listener-link-api', async function (e) {
  4423. e.preventDefault();
  4424. $('#downloadIframe').attr('src', e.currentTarget.dataset.link);
  4425. });
  4426. doc.on('click', '.listener-link-api-btn', async function (e) {
  4427. base.setClipboard(e.target.dataset.filename);
  4428. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  4429. setTimeout(
  4430. function () {
  4431. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  4432. }, 2000
  4433. )
  4434. });
  4435. doc.on('click', '.listener-link-bc-btn', async function (e) {
  4436. let mirror = base.getMirrorList(e.target.dataset.dlink, pan.mirror);
  4437. base.setClipboard(mirror);
  4438. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  4439. setTimeout(
  4440. function () {
  4441. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  4442. }, 2000
  4443. )
  4444. });
  4445. doc.on('click', '.listener-link-aria, .listener-copy-all', function (e) {
  4446. e.preventDefault();
  4447. base.setClipboard(decodeURIComponent(e.target.dataset.link));
  4448. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  4449. setTimeout(
  4450. function () {
  4451. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  4452. }, 2000
  4453. )
  4454. });
  4455. doc.on('click', '.listener-link-rpc', async function (e) {
  4456. e.preventDefault();
  4457. let target = $(e.currentTarget);
  4458.  
  4459. target.find('.icon').remove();
  4460. target.find('.pl-loading').remove();
  4461. target.prepend(base.createLoading());
  4462.  
  4463. let res = await xunlei.sendLinkToRPC(e.currentTarget.dataset.filename, e.currentTarget.dataset.link);
  4464. if (res === 'success') {
  4465. $('.listener-rpc-task').show();
  4466. target.removeClass('pl-btn-danger').html('发送成功了!快去看看吧~').animate({ opacity: '0.5' }, "slow");
  4467. } else if (res === 'assistant') {
  4468. target.addClass('pl-btn-danger').html(`${pan.init[5]}👉<a href="${pan.assistant}" target="_blank" class="pl-a">点击此处安装</a>👈`);
  4469. } else {
  4470. target.addClass('pl-btn-danger').text('发送失败,检查一下您的RPC配置信息哦!').animate({ opacity: '0.5' }, "slow");
  4471. }
  4472. });
  4473. doc.on('click', '.listener-send-rpc', function (e) {
  4474. $('.listener-link-rpc').click();
  4475. $(e.target).text('发送完成,发送结果见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  4476. });
  4477. doc.on('click', '.listener-open-setting', function () {
  4478. base.showSetting();
  4479. });
  4480. doc.on('click', '.listener-open-updatelog', function () {
  4481. base.showUpdateLog();
  4482. });
  4483. doc.on('click', '.listener-rpc-task', function () {
  4484. let rpc = JSON.stringify({
  4485. domain: base.getValue('setting_rpc_domain'),
  4486. port: base.getValue('setting_rpc_port'),
  4487. }), url = `${pan.d}/?rpc=${base.encode(rpc)}#${base.getValue('setting_rpc_token')}`;
  4488. GM_openInTab(url, { active: true });
  4489. });
  4490. },
  4491.  
  4492. addButton() {
  4493. if (document.getElementById("pl-button-link")) {
  4494. document.getElementById("pl-button-link").remove()
  4495. }
  4496. if (!pt) return;
  4497. let $toolWrap;
  4498. let $button = $(`<div class="xunlei-button pl-button" id="pl-button-link"><i class="xlpfont xlp-download"></i><span style="font-size: 13px;margin-left: 6px;">下载助手</span><ul class="pl-dropdown-menu" style="top: 34px;"><li class="pl-dropdown-menu-item pl-button-mode" data-mode="api">API下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="aria" >Aria下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="rpc">RPC下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="curl">cURL下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="bc" >BC下载</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-setting">助手设置</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-updatelog">更新日志</li></ul></div>`);
  4499. if (pt === 'home') {
  4500. base.listenElement(pan.btn.home, function () {
  4501. $toolWrap = $(pan.btn.home);
  4502. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  4503. })
  4504. }
  4505. if (pt === 'share') {
  4506. $button.css({ 'margin-right': '10px' });
  4507. base.listenElement(pan.btn.share, function () {
  4508. $toolWrap = $(pan.btn.share);
  4509. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  4510. })
  4511. }
  4512. base.createDownloadIframe();
  4513. },
  4514.  
  4515. addInitButton() {
  4516. if (document.getElementById("pl-button-link")) {
  4517. document.getElementById("pl-button-link").remove()
  4518. }
  4519. if (!pt) return;
  4520. let $toolWrap;
  4521. let $button = $(`<div class="xunlei-button pl-button-init" id="pl-button-link"><i class="xlpfont xlp-download"></i><span style="font-size: 13px;margin-left: 6px;">点我点亮</span></div>`);
  4522. if (pt === 'home') {
  4523. base.listenElement(pan.btn.home, function () {
  4524. $toolWrap = $(pan.btn.home);
  4525. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  4526. })
  4527. }
  4528. if (pt === 'share') {
  4529. $button.css({ 'margin-right': '10px' });
  4530. base.listenElement(pan.btn.share, function () {
  4531. $toolWrap = $(pan.btn.share);
  4532. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  4533. })
  4534. }
  4535. $button.click(function () { base.initDialog() });
  4536. },
  4537.  
  4538. getToken() {
  4539. let credentials = {}, captcha = {};
  4540. for (let i = 0; i < localStorage.length; i++) {
  4541. if (/^credentials_/.test(localStorage.key(i))) {
  4542. credentials = base.getStorage(localStorage.key(i));
  4543. base.setStorage('');
  4544. }
  4545. if (/^captcha_[\w]{16}/.test(localStorage.key(i))) {
  4546. captcha = base.getStorage(localStorage.key(i));
  4547. }
  4548. }
  4549. let deviceid = /(\w{32})/.exec(base.getStorage('deviceid').split(','))[0];
  4550. let token = {
  4551. credentials,
  4552. captcha,
  4553. deviceid
  4554. };
  4555. return token;
  4556. },
  4557.  
  4558. async getFileUrlByOnce(item, index, token) {
  4559. try {
  4560. if (item.downloadUrl) return {
  4561. index,
  4562. downloadUrl: item.downloadUrl
  4563. };
  4564. let res = await base.get(pan.pcs[0] + item.id, {
  4565. 'Authorization': `${token.credentials.token_type} ${token.credentials.access_token}`,
  4566. 'content-type': "application/json",
  4567. 'x-captcha-token': token.captcha.token,
  4568. 'x-device-id': token.deviceid,
  4569. });
  4570. if (res.web_content_link) {
  4571. return {
  4572. index,
  4573. downloadUrl: res.web_content_link
  4574. };
  4575. } else {
  4576. return {
  4577. index,
  4578. downloadUrl: '获取下载地址失败,刷新后再试试吧~'
  4579. };
  4580. }
  4581. } catch (e) {
  4582. return message.error('提示:<br/>请先登录网盘后再刷新页面呢~');
  4583. }
  4584. },
  4585.  
  4586. async getPCSLink() {
  4587. selectList = this.getSelectedList();
  4588. if (selectList.length === 0) {
  4589. return message.error('提示:<br/>请先勾选要下载的文件哦~');
  4590. }
  4591. if (this.isOnlyFolder()) {
  4592. return message.error('提示:<br/>请打开文件夹后再勾选文件~');
  4593. }
  4594. if (pt === 'home') {
  4595. let queue = [];
  4596. let token = this.getToken();
  4597. for (const [index, item] of selectList.entries()) {
  4598. queue.push(this.getFileUrlByOnce(item, index, token));
  4599. }
  4600.  
  4601. const res = await Promise.all(queue);
  4602. res.forEach(val => {
  4603. selectList[val.index].downloadUrl = val.downloadUrl;
  4604. });
  4605. } else {
  4606. let dialog = await Swal.fire({
  4607. toast: true,
  4608. icon: 'info',
  4609. title: `提示:<br/>请将文件<span class="tag-danger">[保存到网盘]</span>后再👉前往<span class="tag-danger">[我的网盘]</span>中下载哦!`,
  4610. showConfirmButton: true,
  4611. confirmButtonText: '点击保存',
  4612. position: 'top',
  4613. });
  4614. if (dialog.isConfirmed) {
  4615. $('.saveToCloud')[0].click();
  4616. return;
  4617. }
  4618. }
  4619. let html = this.generateDom(selectList);
  4620. this.showMainDialog(pan[mode][0], html, pan[mode][1]);
  4621.  
  4622. },
  4623.  
  4624. generateDom(list) {
  4625. let content = '<div class="pl-main">';
  4626. let alinkAllText = '';
  4627. list.forEach((v, i) => {
  4628. if (v.kind === 'drive#folder') return;
  4629. let filename = v.name;
  4630. let size = base.sizeFormat(+v.size);
  4631. let dlink = v.downloadUrl;
  4632. if (mode === 'api') {
  4633. content += `<div class="pl-item">
  4634. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4635. <a class="pl-item-link listener-link-api" data-filename="${filename}" data-link="${dlink}" data-index="${i}">${dlink}<br/>下载 ${filename}</a>
  4636. <div class="pl-item-btn listener-link-api-btn" data-filename="${filename}">复制文件名</div>
  4637. </div>`;
  4638. }
  4639. if (mode === 'aria') {
  4640. let alink = this.convertLinkToAria(dlink, filename, navigator.userAgent);
  4641. alinkAllText += alink + '\r\n';
  4642. content += `<div class="pl-item">
  4643. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4644. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制aria2c链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  4645. }
  4646. if (mode === 'rpc') {
  4647. content += `<div class="pl-item">
  4648. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4649. <button class="pl-item-link listener-link-rpc pl-btn-primary pl-btn-info" data-filename="${filename}" data-link="${dlink}"><em class="icon icon-device"></em><span style="margin-left: 5px;">将 ${filename} 推送到 RPC 下载器</span></button></div>`;
  4650. }
  4651. if (mode === 'curl') {
  4652. let alink = this.convertLinkToCurl(dlink, filename, navigator.userAgent);
  4653. alinkAllText += alink + '\r\n';
  4654. content += `<div class="pl-item">
  4655. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4656. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制curl链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  4657. }
  4658. if (mode === 'bc') {
  4659. let alink = this.convertLinkToBC(dlink, filename, navigator.userAgent);
  4660. content += `<div class="pl-item">
  4661. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  4662. <a class="pl-item-link" href="${decodeURIComponent(alink)}" title="点击用比特彗星下载" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>下载 ${filename}</a>
  4663. <div class="pl-item-btn listener-link-bc-btn" data-dlink="${dlink}">复制镜像地址</div>
  4664. </div>`;
  4665. }
  4666. });
  4667. content += '</div>';
  4668. if (mode === 'aria')
  4669. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部命令行</button></div>`;
  4670. if (mode === 'rpc') {
  4671. let rpc = base.getValue('setting_rpc_domain') + ':' + base.getValue('setting_rpc_port') + base.getValue('setting_rpc_path');
  4672. content += `<div class="pl-extra"><button class="pl-btn-primary listener-send-rpc">发送全部链接</button><button title="${rpc}" class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px">设置 RPC 参数(当前为:${rpc})</button><button class="pl-btn-primary pl-btn-success listener-rpc-task" style="margin-left: 10px;display: none">查看下载任务</button></div>`;
  4673. }
  4674. if (mode === 'curl')
  4675. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部链接</button><button class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px;">设置终端类型(当前为:${terminalType[base.getValue('setting_terminal_type')]})</button></div>`;
  4676. return content;
  4677. },
  4678.  
  4679. async sendLinkToRPC(filename, link) {
  4680. let rpc = {
  4681. domain: base.getValue('setting_rpc_domain'),
  4682. port: base.getValue('setting_rpc_port'),
  4683. path: base.getValue('setting_rpc_path'),
  4684. token: base.getValue('setting_rpc_token'),
  4685. dir: base.getValue('setting_rpc_dir'),
  4686. };
  4687.  
  4688. let url = `${rpc.domain}:${rpc.port}${rpc.path}`;
  4689. let rpcData = {
  4690. id: new Date().getTime(),
  4691. jsonrpc: '2.0',
  4692. method: 'aria2.addUri',
  4693. params: [`token:${rpc.token}`, [link], {
  4694. dir: rpc.dir,
  4695. out: filename,
  4696. header: []
  4697. }]
  4698. };
  4699. try {
  4700. let res = await base.post(url, rpcData, {}, '');
  4701. if (res.result) return 'success';
  4702. return 'fail';
  4703. } catch (e) {
  4704. return 'fail';
  4705. }
  4706. },
  4707.  
  4708. getSelectedList() {
  4709. try {
  4710. let doms = document.querySelectorAll('.SourceListItem__item--XxpOC');
  4711. let selectedList = [];
  4712. for (let dom of doms) {
  4713. let domVue = dom.__vue__;
  4714. if (domVue.selected.includes(domVue.info.id)) {
  4715. selectedList.push(domVue.info);
  4716. }
  4717. }
  4718. return selectedList;
  4719. } catch (e) {
  4720. return [];
  4721. }
  4722. },
  4723.  
  4724. detectPage() {
  4725. let path = location.pathname;
  4726. if (/^\/$/.test(path)) return 'home';
  4727. if (/^\/(s|share)\//.test(path)) return 'share';
  4728. return '';
  4729. },
  4730.  
  4731. isOnlyFolder() {
  4732. for (let i = 0; i < selectList.length; i++) {
  4733. if (selectList[i].kind === 'drive#file') return false;
  4734. }
  4735. return true;
  4736. },
  4737.  
  4738. showMainDialog(title, html, footer) {
  4739. Swal.fire({
  4740. title,
  4741. html,
  4742. footer,
  4743. allowOutsideClick: false,
  4744. showCloseButton: true,
  4745. position: 'center',
  4746. width,
  4747. padding: '15px 20px 5px',
  4748. customClass,
  4749. confirmButtonText: '关闭',
  4750. });
  4751. },
  4752.  
  4753. async initPanLinker() {
  4754. pt = this.detectPage();
  4755. base.createTip();
  4756. base.registerMenuCommand();
  4757. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  4758. let res = await base.post(`https://api.youxiaohou.com/config/xunlei/?ver=${version}&a=${author}`, {}, {}, 'text');
  4759. pan = JSON.parse(base.decode(res));
  4760. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  4761. let res = await base.post(`https://api.youxiaohou.com/config/v2/xunlei/?ver=${version}&a=${author}`, {}, {}, 'text');
  4762. pan = JSON.parse(base.decode(res));
  4763. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  4764. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/xunlei.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  4765. pan = JSON.parse(res);
  4766. } else {
  4767. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/xunlei.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  4768. pan = JSON.parse(res);
  4769. base.setValue('setting_youxiaohou_server', 'v2');
  4770. }
  4771. Object.freeze && Object.freeze(pan);
  4772. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  4773. this.addButton();
  4774. this.addPageListener();
  4775. } else {
  4776. this.addInitButton();
  4777. }
  4778. }
  4779. };
  4780.  
  4781. //夸克网盘
  4782. let quark = {
  4783.  
  4784. convertLinkToAria(link, filename, ua) {
  4785. filename = base.fixFilename(filename);
  4786. return encodeURIComponent(`aria2c "${link}" --out "${filename}" --header "Cookie: ${document.cookie}"`);
  4787. },
  4788.  
  4789. convertLinkToBC(link, filename, ua) {
  4790. let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}&cookie=${encodeURIComponent(document.cookie)}ZZ`;
  4791. return encodeURIComponent(`bc://http/${base.encode(bc)}`);
  4792. },
  4793.  
  4794. convertLinkToCurl(link, filename, ua) {
  4795. let terminal = base.getValue('setting_terminal_type');
  4796. filename = base.fixFilename(filename);
  4797. return encodeURIComponent(`${terminal !== 'wp' ? 'curl' : 'curl.exe'} -L -C - "${link}" -o "${filename}" -b "${document.cookie}"`);
  4798. },
  4799.  
  4800. addPageListener() {
  4801. /*
  4802. 防止代码因其他原因被执行多次
  4803. 这段代码出自 Via轻插件,作者谷花泰
  4804. */
  4805. const key = encodeURIComponent('(改)网盘直链下载助手:夸客网盘');
  4806. if (window[key]) return;
  4807. window[key] = true;
  4808.  
  4809. window.addEventListener('hashchange', async function (e) {
  4810. let home = 'https://pan.quark.cn/list#/', all = 'https://pan.quark.cn/list#/list/all';
  4811. if (e.oldURL === home && e.newURL === all) return;
  4812. await base.sleep(150);
  4813. if ($('.quark-button').length > 0) return;
  4814. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  4815. this.addButton();
  4816. this.addPageListener();
  4817. } else {
  4818. this.addInitButton();
  4819. }
  4820. });
  4821. doc.on('click', '.pl-button-mode', function (e) {
  4822. mode = e.target.dataset.mode;
  4823. if (!mode) return;
  4824. Swal.fire({
  4825. heightAuto: false,
  4826. scrollbarPadding: false,
  4827. showConfirmButton: false,
  4828. html: `链接获取中`,
  4829. willOpen: function () {
  4830. Swal.showLoading();
  4831. }
  4832. });
  4833. quark.getPCSLink();
  4834. });
  4835. doc.on('click', '.listener-link-save', async function (e) {
  4836. e.preventDefault();
  4837. selectList = this.getSelectedList();
  4838. if (selectList.length === 0) {
  4839. return message.error('提示:<br/>请先勾选要保存到网盘的文件哦~');
  4840. }
  4841. message.info('提示:<br/>因夸克限制,请先保存到自己网盘后再下载哦!');
  4842. await base.sleep(500);
  4843. document.querySelector('.file-info_r').click();
  4844. });
  4845. doc.on('click', '.listener-link-api', async function (e) {
  4846. e.preventDefault();
  4847. $('#downloadIframe').attr('src', e.currentTarget.dataset.link);
  4848. });
  4849. doc.on('click', '.listener-link-aria, .listener-copy-all', function (e) {
  4850. e.preventDefault();
  4851. base.setClipboard(decodeURIComponent(e.target.dataset.link));
  4852. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  4853. setTimeout(
  4854. function () {
  4855. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  4856. }, 2000
  4857. )
  4858. });
  4859. doc.on('click', '.listener-link-rpc', async function (e) {
  4860. e.preventDefault();
  4861. let target = $(e.currentTarget);
  4862.  
  4863. target.find('.icon').remove();
  4864. target.find('.pl-loading').remove();
  4865. target.prepend(base.createLoading());
  4866.  
  4867. let res = await quark.sendLinkToRPC(e.currentTarget.dataset.filename, e.currentTarget.dataset.link);
  4868. if (res === 'success') {
  4869. $('.listener-rpc-task').show();
  4870. target.removeClass('pl-btn-danger').html('发送成功了!快去看看吧~').animate({ opacity: '0.5' }, "slow");
  4871. } else if (res === 'assistant') {
  4872. target.addClass('pl-btn-danger').html(`${pan.init[5]}👉<a href="${pan.assistant}" target="_blank" class="pl-a">点击此处安装</a>👈`);
  4873. } else {
  4874. target.addClass('pl-btn-danger').text('发送失败,检查一下您的RPC配置信息哦!').animate({ opacity: '0.5' }, "slow");
  4875. }
  4876. });
  4877. doc.on('click', '.listener-send-rpc', function (e) {
  4878. $('.listener-link-rpc').click();
  4879. $(e.target).text('发送完成,发送结果见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  4880. });
  4881. doc.on('click', '.listener-open-setting', function () {
  4882. base.showSetting();
  4883. });
  4884. doc.on('click', '.listener-open-updatelog', function () {
  4885. base.showUpdateLog();
  4886. });
  4887. doc.on('click', '.listener-rpc-task', function () {
  4888. let rpc = JSON.stringify({
  4889. domain: base.getValue('setting_rpc_domain'),
  4890. port: base.getValue('setting_rpc_port'),
  4891. }), url = `${pan.d}/?rpc=${base.encode(rpc)}#${base.getValue('setting_rpc_token')}`;
  4892. GM_openInTab(url, { active: true });
  4893. });
  4894. },
  4895.  
  4896. removeAD() {
  4897.  
  4898. base.waitForKeyElements('[class*="Activity--video-toolbar-activity"]', function (tag) {
  4899. tag.fadeToggle();
  4900. }, true);
  4901.  
  4902. base.waitForKeyElements('span[class*="SectionHeaderController--icon-download"]', function (tag) {
  4903. tag.fadeToggle();
  4904. }, true);
  4905.  
  4906. base.waitForKeyElements('div[class*="SectionHeaderController--download-popover"]', function (tag) {
  4907. tag.find(".ant-popover-arrow").css({ "left": "75%" });
  4908. });
  4909.  
  4910. base.waitForKeyElements('div[class*="DetailLayout--client-download"]', function (tag) {
  4911. tag.fadeToggle();
  4912. }, true);
  4913.  
  4914. base.waitForKeyElements(".next-box.share-right-side-content", function (tag) {
  4915. tag.fadeToggle();
  4916. }, true);
  4917.  
  4918. base.waitForKeyElements('[class*="DetailLayout--container"] .feature-screen', function (tag) {
  4919. tag.fadeToggle();
  4920. });
  4921.  
  4922. /*base.waitForKeyElements('.ant-modal-content .ant-modal-body .right-wrap', function (tag) {
  4923. if (tag.find(".hint").text().includes("客户端")) tag.fadeToggle();
  4924. });*/
  4925.  
  4926. base.waitForKeyElements(".pc-member-entrance span", function (tag) {
  4927. tag.text("会员中心");
  4928. });
  4929.  
  4930. base.waitForKeyElements(".pc-member-entrance .tips", function (tag) {
  4931. tag.fadeToggle();
  4932. });
  4933.  
  4934. base.waitForKeyElements(".modal .modal-content .halo-animated-background .halo-content .pay-modal .close", function (tag) {
  4935. tag[0].click();
  4936. });
  4937.  
  4938. base.waitForKeyElements(".modal .modal-content .halo-animated-background .halo-content .red-envelope .close", function (tag) {
  4939. tag[0].click();
  4940. });
  4941. },
  4942.  
  4943. addButton() {
  4944. let svg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMiI+PHBhdGggc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJNOSAxMmwyIDIgMi0yeiIvPjxwYXRoIGQ9Ik0xNCA4aDEuNTUzYy44NSAwIDEuMTYuMDkzIDEuNDcuMjY3LjMxMS4xNzQuNTU2LjQzLjcyMi43NTYuMTY2LjMyNi4yNTUuNjUuMjU1IDEuNTR2NC44NzNjMCAuODkyLS4wODkgMS4yMTUtLjI1NSAxLjU0LS4xNjYuMzI3LS40MS41ODMtLjcyMi43NTctLjMxLjE3NC0uNjIuMjY3LTEuNDcuMjY3SDYuNDQ3Yy0uODUgMC0xLjE2LS4wOTMtMS40Ny0uMjY3YTEuNzc4IDEuNzc4IDAgMDEtLjcyMi0uNzU2Yy0uMTY2LS4zMjYtLjI1NS0uNjUtLjI1NS0xLjU0di00Ljg3M2MwLS44OTIuMDg5LTEuMjE1LjI1NS0xLjU0LjE2Ni0uMzI3LjQxLS41ODMuNzIyLS43NTcuMzEtLjE3NC42Mi0uMjY3IDEuNDctLjI2N0gxMSIvPjxwYXRoIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0iTTExIDN2MTAiLz48L2c+PC9zdmc+';
  4945. if (document.getElementById("pl-button-link")) {
  4946. document.getElementById("pl-button-link").remove()
  4947. }
  4948. if (!pt) return;
  4949. let $toolWrap;
  4950. let $button = $(`<div id="pl-button-link" class="ant-dropdown-trigger pl-button"><button type="button" class="quark-button ant-btn btn-file ant-btn-primary"><img class="quark-btn-icon" src="` + svg + `"><span>下载助手</span></button><ul class="pl-dropdown-menu" style="top: 55px;"><li class="pl-dropdown-menu-item pl-button-mode" data-mode="api">API下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="aria">Aria下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="rpc">RPC下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="curl">cURL下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="bc">BC下载</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-setting">助手设置</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-updatelog">更新日志</li></ul></div>`);
  4951. if (pt === 'home') {
  4952. base.listenElement(pan.btn.home, function () {
  4953. $toolWrap = $(pan.btn.home);
  4954. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  4955. });
  4956. }
  4957. if (pt === 'share') {
  4958. $button = $(`<div id="pl-button-link" class="ant-dropdown-trigger pl-button"><button type="button" class="quark-button ant-btn btn-file ant-btn-primary" style="height: 40px;"><img class="quark-btn-icon" src="` + svg + `"><span>下载助手</span></button><ul class="pl-dropdown-menu" style="top: 100px;"><li class="pl-dropdown-menu-item pl-button-mode listener-link-save" style="background-color: ${color}b0 !important;color:#fff !important;" data-mode="save"><span class="save-btn-icon"></span>保存后下载</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-setting">助手设置</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-updatelog">更新日志</li></ul></div>`);
  4959. base.listenElement(pan.btn.share, function () {
  4960. $toolWrap = $(pan.btn.share);
  4961. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  4962. });
  4963. }
  4964. $button.css({ "margin-right": "10px", "display": "inline-block" });
  4965. },
  4966.  
  4967. addInitButton() {
  4968. let svg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMiI+PHBhdGggc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJNOSAxMmwyIDIgMi0yeiIvPjxwYXRoIGQ9Ik0xNCA4aDEuNTUzYy44NSAwIDEuMTYuMDkzIDEuNDcuMjY3LjMxMS4xNzQuNTU2LjQzLjcyMi43NTYuMTY2LjMyNi4yNTUuNjUuMjU1IDEuNTR2NC44NzNjMCAuODkyLS4wODkgMS4yMTUtLjI1NSAxLjU0LS4xNjYuMzI3LS40MS41ODMtLjcyMi43NTctLjMxLjE3NC0uNjIuMjY3LTEuNDcuMjY3SDYuNDQ3Yy0uODUgMC0xLjE2LS4wOTMtMS40Ny0uMjY3YTEuNzc4IDEuNzc4IDAgMDEtLjcyMi0uNzU2Yy0uMTY2LS4zMjYtLjI1NS0uNjUtLjI1NS0xLjU0di00Ljg3M2MwLS44OTIuMDg5LTEuMjE1LjI1NS0xLjU0LjE2Ni0uMzI3LjQxLS41ODMuNzIyLS43NTcuMzEtLjE3NC42Mi0uMjY3IDEuNDctLjI2N0gxMSIvPjxwYXRoIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0iTTExIDN2MTAiLz48L2c+PC9zdmc+';
  4969. if (document.getElementById("pl-button-link")) {
  4970. document.getElementById("pl-button-link").remove()
  4971. }
  4972. if (!pt) return;
  4973. let $toolWrap;
  4974. let $button = $(`<div id="pl-button-link" class="ant-dropdown-trigger pl-button-init"><button type="button" class="quark-button ant-btn btn-file ant-btn-primary" style="height: 40px;"><img class="quark-btn-icon" src="` + svg + `"><span>点我点亮</span></button></div>`);
  4975. $button.css({ "margin-right": "10px", "display": "inline-block" });
  4976. if (pt === 'home') {
  4977. base.listenElement(pan.btn.home, function () {
  4978. $toolWrap = $(pan.btn.home);
  4979. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  4980. })
  4981. }
  4982. if (pt === 'share') {
  4983. base.listenElement(pan.btn.share, function () {
  4984. $toolWrap = $(pan.btn.share);
  4985. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  4986. })
  4987. }
  4988. $button.click(function () { base.initDialog() });
  4989. },
  4990.  
  4991. async getPCSLink() {
  4992. selectList = this.getSelectedList();
  4993. if (selectList.length === 0) {
  4994. return message.error('提示:<br/>请先勾选要下载的文件哦~');
  4995. }
  4996. if (this.isOnlyFolder()) {
  4997. return message.error('提示:<br/>请打开文件夹后再勾选文件~');
  4998. }
  4999. let fids = [];
  5000. for (const val of selectList) {
  5001. fids.push(val.fid);
  5002. }
  5003. if (pt === 'home') {
  5004. let res = await base.post(pan.pcs[0], {
  5005. "fids": fids
  5006. }, { "content-type": "application/json;charset=utf-8", "user-agent": pan.ua });
  5007. if (res.code === 31001) {
  5008. return message.error('提示:<br/>请先登录网盘~<br/>代码:' + res.code);
  5009. }
  5010. if (res.code !== 0) {
  5011. return message.error('提示:<br/>获取链接失败了~<br/>代码:' + res.code);
  5012. }
  5013. let html = this.generateDom(res.data);
  5014. this.showMainDialog(pan[mode][0], html, pan[mode][1]);
  5015. } else {
  5016. let dialog = await Swal.fire({
  5017. toast: true,
  5018. icon: 'info',
  5019. title: `提示:<br/>请将文件<span class="tag-danger">[保存到网盘]</span>后再👉前往<span class="tag-danger">[我的网盘]</span>中下载哦!`,
  5020. showConfirmButton: true,
  5021. confirmButtonText: '点击保存',
  5022. position: 'top',
  5023. });
  5024. if (dialog.isConfirmed) {
  5025. $('.file-info_r')[0].click();
  5026. return;
  5027. }
  5028. }
  5029. },
  5030.  
  5031. generateDom(list) {
  5032. let content = '<div class="pl-main">';
  5033. let alinkAllText = '';
  5034. list.forEach((v, i) => {
  5035. if (v.file === false) return;
  5036. let filename = v.file_name;
  5037. let fid = v.fid;
  5038. let size = base.sizeFormat(v.size);
  5039. let dlink = v.download_url;
  5040. if (mode === 'api') {
  5041. content += `<div class="pl-item">
  5042. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5043. <a class="pl-item-link listener-link-api" data-fid="${fid}" data-filename="${filename}" data-link="${dlink}" data-index="${i}">${dlink}<br/>下载 ${filename}</a>
  5044. </div>`;
  5045. }
  5046. if (mode === 'aria') {
  5047. let alink = this.convertLinkToAria(dlink, filename, navigator.userAgent);
  5048. alinkAllText += alink + '\r\n';
  5049. content += `<div class="pl-item">
  5050. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5051. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制aria2c链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  5052. }
  5053. if (mode === 'rpc') {
  5054. content += `<div class="pl-item">
  5055. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5056. <button class="pl-item-link listener-link-rpc pl-btn-primary pl-btn-info" data-filename="${filename}" data-link="${dlink}"><em class="icon icon-device"></em><span style="margin-left: 5px;">将 ${filename} 推送到 RPC 下载器</span></button></div>`;
  5057. }
  5058. if (mode === 'curl') {
  5059. let alink = this.convertLinkToCurl(dlink, filename, navigator.userAgent);
  5060. alinkAllText += alink + '\r\n';
  5061. content += `<div class="pl-item">
  5062. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5063. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制curl链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  5064. }
  5065. if (mode === 'bc') {
  5066. let alink = this.convertLinkToBC(dlink, filename, navigator.userAgent);
  5067. content += `<div class="pl-item">
  5068. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5069. <a class="pl-item-link" href="${decodeURIComponent(alink)}" title="点击用比特彗星下载" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>下载 ${filename}</a> </div>`;
  5070. }
  5071. });
  5072. content += '</div>';
  5073. if (mode === 'aria')
  5074. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部命令行</button></div>`;
  5075. if (mode === 'rpc') {
  5076. let rpc = base.getValue('setting_rpc_domain') + ':' + base.getValue('setting_rpc_port') + base.getValue('setting_rpc_path');
  5077. content += `<div class="pl-extra"><button class="pl-btn-primary listener-send-rpc">发送全部链接</button><button title="${rpc}" class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px">设置 RPC 参数(当前为:${rpc})</button><button class="pl-btn-primary pl-btn-success listener-rpc-task" style="margin-left: 10px;display: none">查看下载任务</button></div>`;
  5078. }
  5079. if (mode === 'curl')
  5080. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部链接</button><button class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px;">设置终端类型(当前为:${terminalType[base.getValue('setting_terminal_type')]})</button></div>`;
  5081. return content;
  5082. },
  5083.  
  5084. async sendLinkToRPC(filename, link) {
  5085. let rpc = {
  5086. domain: base.getValue('setting_rpc_domain'),
  5087. port: base.getValue('setting_rpc_port'),
  5088. path: base.getValue('setting_rpc_path'),
  5089. token: base.getValue('setting_rpc_token'),
  5090. dir: base.getValue('setting_rpc_dir'),
  5091. };
  5092.  
  5093. let url = `${rpc.domain}:${rpc.port}${rpc.path}`;
  5094. let rpcData = {
  5095. id: new Date().getTime(),
  5096. jsonrpc: '2.0',
  5097. method: 'aria2.addUri',
  5098. params: [`token:${rpc.token}`, [link], {
  5099. dir: rpc.dir,
  5100. out: filename,
  5101. header: [`Cookie: ${document.cookie}`]
  5102. }]
  5103. };
  5104. try {
  5105. let res = await base.post(url, rpcData, { "Cookie": document.cookie }, '');
  5106. if (res.result) return 'success';
  5107. return 'fail';
  5108. } catch (e) {
  5109. return 'fail';
  5110. }
  5111. },
  5112.  
  5113. getSelectedList() {
  5114. try {
  5115. let selectedList = [];
  5116. let reactDom = document.getElementsByClassName('file-list')[0];
  5117. let reactObj = base.findReact(reactDom);
  5118. let props = reactObj.props;
  5119. if (props) {
  5120. let fileList = props.list || [];
  5121. let selectedKeys = props.selectedRowKeys || [];
  5122. fileList.forEach(function (val) {
  5123. if (selectedKeys.includes(val.fid)) {
  5124. selectedList.push(val);
  5125. }
  5126. });
  5127. }
  5128. return selectedList;
  5129. } catch (e) {
  5130. return [];
  5131. }
  5132. },
  5133.  
  5134. detectPage() {
  5135. let path = location.pathname;
  5136. if (/^\/(list)/.test(path)) return 'home';
  5137. if (/^\/(s|share)\//.test(path)) return 'share';
  5138. return '';
  5139. },
  5140.  
  5141. isOnlyFolder() {
  5142. for (let i = 0; i < selectList.length; i++) {
  5143. if (selectList[i].file) return false;
  5144. }
  5145. return true;
  5146. },
  5147.  
  5148. showMainDialog(title, html, footer) {
  5149. Swal.fire({
  5150. title,
  5151. html,
  5152. footer,
  5153. allowOutsideClick: false,
  5154. showCloseButton: true,
  5155. position: 'center',
  5156. width,
  5157. padding: '15px 20px 5px',
  5158. customClass,
  5159. confirmButtonText: '关闭',
  5160. });
  5161. },
  5162.  
  5163. async initPanLinker() {
  5164. pt = this.detectPage();
  5165. base.createTip();
  5166. base.registerMenuCommand();
  5167. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  5168. let res = await base.post(`https://api.youxiaohou.com/config/quark/?ver=${version}&a=${author}`, {}, {}, 'text');
  5169. pan = JSON.parse(base.decode(res));
  5170. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  5171. let res = await base.post(`https://api.youxiaohou.com/config/v2/quark/?ver=${version}&a=${author}`, {}, {}, 'text');
  5172. pan = JSON.parse(base.decode(res));
  5173. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  5174. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/quark.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  5175. pan = JSON.parse(res);
  5176. } else {
  5177. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/quark.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  5178. pan = JSON.parse(res);
  5179. base.setValue('setting_youxiaohou_server', 'v2');
  5180. }
  5181. Object.freeze && Object.freeze(pan);
  5182. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  5183. this.addButton();
  5184. this.addPageListener();
  5185. } else {
  5186. this.addInitButton();
  5187. }
  5188. base.createDownloadIframe();
  5189. }
  5190. };
  5191.  
  5192. //中国移动云盘/和彩云
  5193. let yidong = {
  5194.  
  5195. convertLinkToAria(link, filename, ua) {
  5196. filename = base.fixFilename(filename);
  5197. return encodeURIComponent(`aria2c "${link}" --out "${filename}"`);
  5198. },
  5199.  
  5200. convertLinkToBC(link, filename, ua) {
  5201. let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}ZZ`;
  5202. return encodeURIComponent(`bc://http/${base.encode(bc)}`);
  5203. },
  5204.  
  5205. convertLinkToCurl(link, filename, ua) {
  5206. let terminal = base.getValue('setting_terminal_type');
  5207. filename = base.fixFilename(filename);
  5208. return encodeURIComponent(`${terminal !== 'wp' ? 'curl' : 'curl.exe'} -L -C - "${link}" -o "${filename}"`);
  5209. },
  5210.  
  5211. addPageListener() {
  5212. /*
  5213. 防止代码因其他原因被执行多次
  5214. 这段代码出自 Via轻插件,作者谷花泰
  5215. */
  5216. const key = encodeURIComponent('(改)网盘直链下载助手:移动云盘');
  5217. if (window[key]) return;
  5218. window[key] = true;
  5219.  
  5220. doc.on('click', '.pl-button-mode', function (e) {
  5221. mode = e.target.dataset.mode;
  5222. if (!mode) return;
  5223. Swal.fire({
  5224. heightAuto: false,
  5225. scrollbarPadding: false,
  5226. showConfirmButton: false,
  5227. html: `链接获取中`,
  5228. willOpen: function () {
  5229. Swal.showLoading();
  5230. }
  5231. });
  5232. yidong.getPCSLink();
  5233. });
  5234. doc.on('click', '.listener-link-api', async function (e) {
  5235. e.preventDefault();
  5236. $('#downloadIframe').attr('src', e.currentTarget.dataset.link);
  5237. });
  5238. doc.on('click', '.listener-link-aria, .listener-copy-all', function (e) {
  5239. e.preventDefault();
  5240. base.setClipboard(decodeURIComponent(e.target.dataset.link));
  5241. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  5242. setTimeout(
  5243. function () {
  5244. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  5245. }, 2000
  5246. )
  5247. });
  5248. doc.on('click', '.listener-copy-all-api', function (e) {
  5249. e.preventDefault();
  5250. base.setClipboard(decodeURIComponent(e.target.dataset.link));
  5251. $(e.target).text('复制成功').animate({ opacity: '0.5' }, "slow");
  5252. setTimeout(
  5253. function () {
  5254. $(e.target).text('重新复制').animate({ opacity: '1' }, "slow");
  5255. }, 2000
  5256. )
  5257. });
  5258. doc.on('click', '.listener-link-rpc', async function (e) {
  5259. e.preventDefault();
  5260. let target = $(e.currentTarget);
  5261.  
  5262. target.find('.icon').remove();
  5263. target.find('.pl-loading').remove();
  5264. target.prepend(base.createLoading());
  5265.  
  5266. let res = await yidong.sendLinkToRPC(e.currentTarget.dataset.filename, e.currentTarget.dataset.link);
  5267. if (res === 'success') {
  5268. $('.listener-rpc-task').show();
  5269. target.removeClass('pl-btn-danger').html('发送成功了!快去看看吧~').animate({ opacity: '0.5' }, "slow");
  5270. } else if (res === 'assistant') {
  5271. target.addClass('pl-btn-danger').html(`${pan.init[5]}👉<a href="${pan.assistant}" target="_blank" class="pl-a">点击此处安装</a>👈`);
  5272. } else {
  5273. target.addClass('pl-btn-danger').text('发送失败,检查一下您的RPC配置信息哦!').animate({ opacity: '0.5' }, "slow");
  5274. }
  5275. });
  5276. doc.on('click', '.listener-send-rpc', function (e) {
  5277. $('.listener-link-rpc').click();
  5278. $(e.target).text('发送完成,发送结果见上方按钮哦~').animate({ opacity: '0.5' }, "slow");
  5279. });
  5280. doc.on('click', '.listener-open-setting', function () {
  5281. base.showSetting();
  5282. });
  5283. doc.on('click', '.listener-open-updatelog', function () {
  5284. base.showUpdateLog();
  5285. });
  5286. doc.on('click', '.listener-rpc-task', function () {
  5287. let rpc = JSON.stringify({
  5288. domain: base.getValue('setting_rpc_domain'),
  5289. port: base.getValue('setting_rpc_port'),
  5290. }), url = `${pan.d}/?rpc=${base.encode(rpc)}#${base.getValue('setting_rpc_token')}`;
  5291. GM_openInTab(url, { active: true });
  5292. });
  5293. },
  5294.  
  5295. removeAD() {
  5296. base.waitForKeyElements(".adv_swiper_menu", function (tag) {
  5297. tag.fadeToggle();
  5298. });
  5299. base.waitForKeyElements(".client-bubble", function (tag) {
  5300. tag.fadeToggle();
  5301. });
  5302. base.waitForKeyElements(".avs-box", function (tag) {
  5303. tag.fadeToggle();
  5304. });
  5305. base.waitForKeyElements(".top-adv-swiper", function (tag) {
  5306. tag.fadeToggle();
  5307. });
  5308. base.waitForKeyElements(".client_download_icon", function (tag) {
  5309. tag.fadeToggle();
  5310. });
  5311. base.waitForKeyElements(".document_top_memberCenter", function (tag) {
  5312. $(tag[0]).click(function () {
  5313. Swal.fire({
  5314. html: `<iframe style="height: 700px; width: 420px; border: 0;" src="https://vip.yun.139.com/vip/"></iframe>`,
  5315. allowOutsideClick: false,
  5316. showCloseButton: true,
  5317. showConfirmButton: false,
  5318. heightAuto: false,
  5319. scrollbarPadding: false,
  5320. });
  5321. });
  5322. }, true);
  5323. },
  5324.  
  5325. addButton() {
  5326. if (document.getElementById("pl-button-link")) {
  5327. document.getElementById("pl-button-link").remove()
  5328. }
  5329. if (!pt) return;
  5330. let $toolWrap;
  5331. let $button = $(`<div class="yidong-button pl-button btn-top" id="pl-button-link"><span class="yidong-btn">下载助手</span><ul class="pl-dropdown-menu" style="top: 36px; letter-spacing: normal;"><li class="pl-dropdown-menu-item pl-button-mode" data-mode="api">API下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="aria" >Aria下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="rpc">RPC下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="curl">cURL下载</li><li class="pl-dropdown-menu-item pl-button-mode" data-mode="bc" >BC下载</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-setting">助手设置</li><li class="pl-dropdown-menu-item pl-button-mode listener-open-updatelog">更新日志</li></ul></div>`);
  5332. if (pt === 'home') {
  5333. base.listenElement(pan.btn.home, function () {
  5334. $toolWrap = $(pan.btn.home);
  5335. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  5336. })
  5337. }
  5338. if (pt === 'share') {
  5339. $button.removeClass('yidong-button').addClass('yidong-share-button');
  5340. base.listenElement(pan.btn.share, function () {
  5341. $toolWrap = $(pan.btn.share);
  5342. $('.pl-button').length === 0 && $toolWrap.prepend($button);
  5343. })
  5344. }
  5345. base.createDownloadIframe();
  5346. },
  5347.  
  5348. addInitButton() {
  5349. if (document.getElementById("pl-button-link")) {
  5350. document.getElementById("pl-button-link").remove()
  5351. }
  5352. if (!pt) return;
  5353. let $toolWrap;
  5354. let $button = $(`<div class="yidong-button pl-button-init btn-top" id="pl-button-link"><span class="yidong-btn">点我点亮</span></div>`);
  5355. if (pt === 'home') {
  5356. base.listenElement(pan.btn.home, function () {
  5357. $toolWrap = $(pan.btn.home);
  5358. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  5359. })
  5360. }
  5361. if (pt === 'share') {
  5362. $button.removeClass('yidong-button').addClass('yidong-share-button');
  5363. base.listenElement(pan.btn.share, function () {
  5364. $toolWrap = $(pan.btn.share);
  5365. $('.pl-button-init').length === 0 && $toolWrap.prepend($button);
  5366. })
  5367. }
  5368. $button.click(function () { base.initDialog() });
  5369. },
  5370.  
  5371. getRandomString(len) {
  5372. len = len || 16;
  5373. let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
  5374. let maxPos = $chars.length;
  5375. let pwd = '';
  5376. for (let i = 0; i < len; i++) {
  5377. pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  5378. }
  5379. return pwd;
  5380. },
  5381.  
  5382. utob(str) {
  5383. const u = String.fromCharCode;
  5384. return str.replace(/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, function (t) {
  5385. if (t.length < 2) {
  5386. let e = t.charCodeAt(0);
  5387. return e < 128 ? t : e < 2048 ? u(192 | e >>> 6) + u(128 | 63 & e) : u(224 | e >>> 12 & 15) + u(128 | e >>> 6 & 63) + u(128 | 63 & e);
  5388. }
  5389. e = 65536 + 1024 * (t.charCodeAt(0) - 55296) + (t.charCodeAt(1) - 56320);
  5390. return u(240 | e >>> 18 & 7) + u(128 | e >>> 12 & 63) + u(128 | e >>> 6 & 63) + u(128 | 63 & e);
  5391. });
  5392. },
  5393.  
  5394. getSign(e, t, a, n) {
  5395. let r = "",
  5396. i = "";
  5397. if (t) {
  5398. let s = Object.assign({}, t);
  5399. i = JSON.stringify(s),
  5400. i = i.replace(/\s*/g, ""),
  5401. i = encodeURIComponent(i);
  5402. let c = i.split(""),
  5403. u = c.sort();
  5404. i = u.join("");
  5405. }
  5406. let A = md5(base.encode(this.utob(i)));
  5407. let l = md5(a + ":" + n);
  5408. return md5(A + l).toUpperCase();
  5409. },
  5410.  
  5411. async getFileUrlByOnce(item, index) {
  5412. try {
  5413. if (item.downloadUrl) return {
  5414. index,
  5415. downloadUrl: item.downloadUrl
  5416. };
  5417.  
  5418. if (this.detectPage() === 'home') {
  5419. let body = {
  5420. "contentID": item.contentID,
  5421. "commonAccountInfo": { "account": item.owner, "accountType": 1 },
  5422. "operation": "0",
  5423. "inline": "0",
  5424. "extInfo": { "isReturnCdnDownloadUrl": "1" }
  5425. };
  5426. let time = new Date(+new Date() + 8 * 3600 * 1000).toJSON().substr(0, 19).replace('T', ' ');
  5427. let key = this.getRandomString(16);
  5428. let sign = this.getSign(undefined, body, time, key);
  5429.  
  5430. let res = await base.post(pan.pcs[0], body, {
  5431. 'authorization': base.getCookie('authorization'),
  5432. 'x-huawei-channelSrc': '10000034',
  5433. 'x-inner-ntwk': '2',
  5434. 'mcloud-channel': '1000101',
  5435. 'mcloud-client': '10701',
  5436. 'mcloud-sign': time + "," + key + "," + sign,
  5437. 'content-type': "application/json;charset=UTF-8",
  5438. 'caller': 'web',
  5439. 'CMS-DEVICE': 'default',
  5440. 'x-DeviceInfo': '||9|7.12.0|chrome|119.0.0.0|||windows 10||zh-CN|||',
  5441. 'x-SvcType': '1',
  5442. });
  5443. if (res.success) {
  5444. return {
  5445. index,
  5446. downloadUrl: res.data.downloadURL
  5447. };
  5448. } else {
  5449. return {
  5450. index,
  5451. downloadUrl: '获取下载地址失败,刷新后再试试吧~'
  5452. };
  5453. }
  5454. }
  5455. if (this.detectPage() === 'share') {
  5456. let vueDom = document.querySelector(".main_file_list").__vue__;
  5457.  
  5458. let res = await base.post(pan.pcs[1], `linkId=${vueDom.linkID}&contentIds=${item.path}&catalogIds=`, {
  5459. 'Content-Type': 'application/x-www-form-urlencoded',
  5460. });
  5461. if (res.code === 0) {
  5462. return {
  5463. index,
  5464. downloadUrl: res.data.redrUrl
  5465. };
  5466. } else {
  5467. return {
  5468. index,
  5469. downloadUrl: '获取下载地址失败,刷新后再试试吧~'
  5470. };
  5471. }
  5472. }
  5473. } catch (e) {
  5474. return {
  5475. index,
  5476. downloadUrl: '获取下载地址失败,刷新后再试试吧~'
  5477. };
  5478. }
  5479. },
  5480.  
  5481. async getPCSLink() {
  5482. selectList = this.getSelectedList();
  5483. if (selectList.length === 0) {
  5484. return message.error('提示:<br/>请先勾选要下载的文件哦~');
  5485. }
  5486. if (this.isOnlyFolder()) {
  5487. return message.error('提示:<br/>请打开文件夹后再勾选文件~');
  5488. }
  5489.  
  5490. let queue = [];
  5491. for (const [index, item] of selectList.entries()) {
  5492. queue.push(this.getFileUrlByOnce(item, index));
  5493. }
  5494.  
  5495. const res = await Promise.all(queue);
  5496. res.forEach(val => {
  5497. selectList[val.index].downloadUrl = val.downloadUrl;
  5498. });
  5499.  
  5500. let html = this.generateDom(selectList);
  5501. this.showMainDialog(pan[mode][0], html, pan[mode][1]);
  5502. },
  5503.  
  5504. generateDom(list) {
  5505. let content = '<div class="pl-main">';
  5506. let alinkAllText = '';
  5507. list.forEach((v, i) => {
  5508. if (v.dirEtag || v.caName) return;
  5509. let filename = v.contentName || v.coName;
  5510. let size = base.sizeFormat(v.contentSize || v.coSize);
  5511. let dlink = v.downloadUrl;
  5512. if (mode === 'api') {
  5513. alinkAllText += dlink + '\r\n';
  5514. content += `<div class="pl-item">
  5515. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5516. <a class="pl-item-link listener-link-api" data-filename="${filename}" data-link="${dlink}" data-index="${i}">${dlink}<br/>下载 ${filename}</a>
  5517. <button class="pl-item-copy pl-btn-primary listener-copy-all" href="${dlink}" title="点击复制链接" data-filename="${filename}" data-link="${dlink}">复制链接</button>
  5518. </div>`;
  5519. }
  5520. if (mode === 'aria') {
  5521. let alink = this.convertLinkToAria(dlink, filename, navigator.userAgent);
  5522. alinkAllText += alink + '\r\n';
  5523. content += `<div class="pl-item">
  5524. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5525. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制aria2c链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  5526. }
  5527. if (mode === 'rpc') {
  5528. content += `<div class="pl-item">
  5529. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5530. <button class="pl-item-link listener-link-rpc pl-btn-primary pl-btn-info" data-filename="${filename}" data-link="${dlink}"><em class="icon icon-device"></em><span style="margin-left: 5px;">将 ${filename} 推送到 RPC 下载器</span></button></div>`;
  5531. }
  5532. if (mode === 'curl') {
  5533. let alink = this.convertLinkToCurl(dlink, filename, navigator.userAgent);
  5534. alinkAllText += alink + '\r\n';
  5535. content += `<div class="pl-item">
  5536. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5537. <a class="pl-item-link listener-link-aria" href="${alink}" title="点击复制curl链接" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>复制 ${filename} 下载命令行</a> </div>`;
  5538. }
  5539. if (mode === 'bc') {
  5540. let alink = this.convertLinkToBC(dlink, filename, navigator.userAgent);
  5541. content += `<div class="pl-item">
  5542. <div class="pl-item-name listener-tip" data-size="${size}">${filename}</div>
  5543. <a class="pl-item-link" href="${decodeURIComponent(alink)}" title="点击用比特彗星下载" data-filename="${filename}" data-link="${alink}">${decodeURIComponent(alink)}<br/>下载 ${filename}</a> </div>`;
  5544. }
  5545. });
  5546. content += '</div>';
  5547. if (mode === 'api') {
  5548. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all-api" data-link="${alinkAllText}">复制全部链接</button></div>`;
  5549. }
  5550. if (mode === 'aria')
  5551. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部命令行</button></div>`;
  5552. if (mode === 'rpc') {
  5553. let rpc = base.getValue('setting_rpc_domain') + ':' + base.getValue('setting_rpc_port') + base.getValue('setting_rpc_path');
  5554. content += `<div class="pl-extra"><button class="pl-btn-primary listener-send-rpc">发送全部链接</button><button title="${rpc}" class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px">设置 RPC 参数(当前为:${rpc})</button><button class="pl-btn-primary pl-btn-success listener-rpc-task" style="margin-left: 10px;display: none">查看下载任务</button></div>`;
  5555. }
  5556. if (mode === 'curl')
  5557. content += `<div class="pl-extra"><button class="pl-btn-primary listener-copy-all" data-link="${alinkAllText}">复制全部链接</button><button class="pl-btn-primary pl-btn-warning listener-open-setting" style="margin-left: 10px;">设置终端类型(当前为:${terminalType[base.getValue('setting_terminal_type')]})</button></div>`;
  5558. return content;
  5559. },
  5560.  
  5561. async sendLinkToRPC(filename, link) {
  5562. let rpc = {
  5563. domain: base.getValue('setting_rpc_domain'),
  5564. port: base.getValue('setting_rpc_port'),
  5565. path: base.getValue('setting_rpc_path'),
  5566. token: base.getValue('setting_rpc_token'),
  5567. dir: base.getValue('setting_rpc_dir'),
  5568. };
  5569.  
  5570. let url = `${rpc.domain}:${rpc.port}${rpc.path}`;
  5571. let rpcData = {
  5572. id: new Date().getTime(),
  5573. jsonrpc: '2.0',
  5574. method: 'aria2.addUri',
  5575. params: [`token:${rpc.token}`, [link], {
  5576. dir: rpc.dir,
  5577. out: filename,
  5578. header: []
  5579. }]
  5580. };
  5581. try {
  5582. let res = await base.post(url, rpcData, {}, '');
  5583. if (res.result) return 'success';
  5584. return 'fail';
  5585. } catch (e) {
  5586. return 'fail';
  5587. }
  5588. },
  5589.  
  5590. getSelectedList() {
  5591. try {
  5592. return document.querySelector(".main_file_list").__vue__.selectList.map(val => val.item);
  5593. } catch (e) {
  5594. let vueDom = document.querySelector(".home-page").__vue__;
  5595. let fileList = vueDom._computedWatchers.fileList.value;
  5596. let dirList = vueDom._computedWatchers.dirList.value;
  5597. let selectedFileIndex = vueDom.selectedFile;
  5598. let selectedDirIndex = vueDom.selectedDir;
  5599. let selectFileList = fileList.filter((v, i) => {
  5600. return selectedFileIndex.includes(i);
  5601. });
  5602. let selectDirList = dirList.filter((v, i) => {
  5603. return selectedDirIndex.includes(i);
  5604. });
  5605. return [...selectFileList, ...selectDirList];
  5606. }
  5607. },
  5608.  
  5609. detectPage() {
  5610. let path = location.pathname;
  5611. if (/^\/w/.test(path)) return 'home';
  5612. if (/^\/link|shareweb/.test(path)) return 'share';
  5613. return '';
  5614. },
  5615.  
  5616. isOnlyFolder() {
  5617. for (let i = 0; i < selectList.length; i++) {
  5618. if (selectList[i].fileEtag || selectList[i].coName) return false;
  5619. }
  5620. return true;
  5621. },
  5622.  
  5623. showMainDialog(title, html, footer) {
  5624. Swal.fire({
  5625. title,
  5626. html,
  5627. footer,
  5628. allowOutsideClick: false,
  5629. showCloseButton: true,
  5630. position: 'center',
  5631. width,
  5632. padding: '15px 20px 5px',
  5633. customClass,
  5634. confirmButtonText: '关闭',
  5635. });
  5636. },
  5637.  
  5638. async initPanLinker() {
  5639. pt = this.detectPage();
  5640. base.createTip();
  5641. base.registerMenuCommand();
  5642. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  5643. let res = await base.post(`https://api.youxiaohou.com/config/yidong/?ver=${version}&a=${author}`, {}, {}, 'text');
  5644. pan = JSON.parse(base.decode(res));
  5645. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  5646. let res = await base.post(`https://api.youxiaohou.com/config/v2/yidong/?ver=${version}&a=${author}`, {}, {}, 'text');
  5647. pan = JSON.parse(base.decode(res));
  5648. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  5649. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/yidong.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  5650. pan = JSON.parse(res);
  5651. } else {
  5652. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/yidong.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  5653. pan = JSON.parse(res);
  5654. base.setValue('setting_youxiaohou_server', 'v2');
  5655. }
  5656. Object.freeze && Object.freeze(pan);
  5657. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  5658. this.addButton();
  5659. this.addPageListener();
  5660. } else {
  5661. this.addInitButton();
  5662. }
  5663. }
  5664. };
  5665.  
  5666. // 油小猴
  5667. let youxiaohou = {
  5668. async initPanLinker() {
  5669. base.createTip();
  5670. base.registerMenuCommand();
  5671. if (base.getValue('setting_youxiaohou_server') === 'v1') {
  5672. let res = await base.post(`https://api.youxiaohou.com/config/?ver=${version}&a=${author}`, {}, {}, 'text');
  5673. pan = JSON.parse(base.decode(res));
  5674. } else if (base.getValue('setting_youxiaohou_server') === 'v2') {
  5675. let res = await base.post(`https://api.youxiaohou.com/config/v2/?ver=${version}&a=${author}`, {}, {}, 'text');
  5676. pan = JSON.parse(base.decode(res));
  5677. } else if (base.getValue('setting_youxiaohou_server') === "no") {
  5678. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  5679. pan = JSON.parse(res);
  5680. } else {
  5681. let res = await base.get(`https://gcore.jsdelivr.net/gh/hmjz100/Online-disk-direct-link-download-assistant@main/config/config.json?version=${realversion}`, { 'Cache-Control': 'no-cache' }, "text", {});
  5682. pan = JSON.parse(res);
  5683. base.setValue('setting_youxiaohou_server', 'v2');
  5684. }
  5685. Object.freeze && Object.freeze(pan);
  5686. if (pan.num === base.getValue('setting_init_code') || pan.license === base.getValue('license')) {
  5687. this.addButton();
  5688. } else {
  5689. this.addInitButton();
  5690. }
  5691. },
  5692. addButton() {
  5693. let $button = `
  5694. <div class="nav-item">
  5695. <div class="dropdown-wrapper">
  5696. <button type="button" aria-label="(改)下载助手" class="dropdown-title">
  5697. <span class="title">(改)下载助手⬇️</span>
  5698. <span class="arrow down"></span>
  5699. </button>
  5700. <button type="button" aria-label="(改)下载助手" class="mobile-dropdown-title">
  5701. <span class="title">(改)下载助手⬇️</span>
  5702. <span class="arrow right"></span>
  5703. </button>
  5704. <ul class="nav-dropdown" style="display:none;">
  5705. <li class="dropdown-item">
  5706. <h4>
  5707. 助手
  5708. </h4>
  5709. <ul class="dropdown-subitem-wrapper">
  5710. <li class="dropdown-subitem">
  5711. <a href="javascript:void(0)" class="listener-open-info nav-link">
  5712. 🛠️ 调试(查看暗号/协议)
  5713. </a>
  5714. </li>
  5715. </ul>
  5716. </li>
  5717. <li class="dropdown-item">
  5718. <h4>
  5719. 选项
  5720. </h4>
  5721. <ul class="dropdown-subitem-wrapper">
  5722. <li class="dropdown-subitem">
  5723. <a href="javascript:void(0)" class="listener-open-setting nav-link">
  5724. ⚙️ 助手设置
  5725. </a>
  5726. </li>
  5727. <li class="dropdown-subitem">
  5728. <a href="javascript:void(0)" class="listener-open-updatelog nav-link">
  5729. 📃 更新日志
  5730. </a>
  5731. </li>
  5732. </ul>
  5733. </li>
  5734. </ul>
  5735. </div>
  5736. </div>
  5737. `;
  5738. doc.on('click', '.listener-open-setting', function () {
  5739. base.showSetting();
  5740. });
  5741. doc.on('click', '.listener-open-updatelog', function () {
  5742. base.showUpdateLog();
  5743. });
  5744. doc.on('click', '.listener-open-info', function () {
  5745. base.showDebug();
  5746. });
  5747.  
  5748. document.querySelectorAll(".nav-links").forEach(function (element) {
  5749. element.innerHTML += $button
  5750. })
  5751. },
  5752. addInitButton() {
  5753. let $button = `
  5754. <div class="nav-item">
  5755. <div class="dropdown-wrapper">
  5756. <a class="nav-link listener-open-init">(改)点我点亮⬇️</a>
  5757. </div>
  5758. </div>
  5759. `;
  5760. doc.on('click', '.listener-open-init', function () {
  5761. base.initDialog();
  5762. });
  5763.  
  5764. document.querySelectorAll(".nav-links").forEach(function (element) {
  5765. element.innerHTML += $button
  5766. })
  5767. }
  5768. }
  5769.  
  5770. // 主代码
  5771. let main = {
  5772. async init() {
  5773. // 先加载默认设置
  5774. base.initDefaultConfig();
  5775. // 然后获取原脚本的 GreasyFork 信息,确保油小猴服务器信任
  5776. await base.get('https://greasyfork.org/zh-CN/scripts/436446.json', { "referer": "https://greasyfork.org/" }, 'json', '').then(res => {
  5777. base.setValue('setting_script_version', res.version);
  5778. base.setValue('setting_script_author', 'YouXiaoHou');
  5779. base.setValue('setting_script_name', res.name);
  5780. })
  5781. // 再加载网页样式
  5782. base.addPanLinkerStyle();
  5783. // 最后判断页面地址并加载对应的initPanLinker
  5784. if (/(pan|yun).baidu.com/.test(location.host)) {
  5785. baidu.initPanLinker();
  5786. baidu.removeAD();
  5787. }
  5788. if (/openapi.baidu.com\/oauth/.test(location.href)) {
  5789. baidu.initAuthorize()
  5790. }
  5791. if (/www.(aliyundrive|alipan).com/.test(location.host)) {
  5792. ali.initPanLinker();
  5793. ali.removeAD();
  5794. }
  5795. if (/cloud.189.cn/.test(location.host)) {
  5796. tianyi.initPanLinker();
  5797. tianyi.removeAD();
  5798. }
  5799. if (/pan.xunlei.com/.test(location.host)) {
  5800. xunlei.initPanLinker();
  5801. }
  5802. if (/pan.quark.cn/.test(location.host)) {
  5803. quark.initPanLinker();
  5804. quark.removeAD();
  5805. }
  5806. if (/(yun|caiyun).139.com/.test(location.host)) {
  5807. yidong.initPanLinker();
  5808. yidong.removeAD();
  5809. }
  5810. if (/www.youxiaohou.com/.test(location.host)) {
  5811. youxiaohou.initPanLinker();
  5812. }
  5813. },
  5814. async downloadConfig() {
  5815. // 定义要下载的链接数组及对应的文件名
  5816. let urlsAndFilenames = [
  5817. { url: `https://api.youxiaohou.com/config/v2/?ver=${version}&a=${author}`, filename: 'config.json' },
  5818. { url: `https://api.youxiaohou.com/config/v2/ali/?ver=${version}&a=${author}`, filename: 'ali.json' },
  5819. { url: `https://api.youxiaohou.com/config/v2/tianyi/?ver=${version}&a=${author}`, filename: 'tianyi.json' },
  5820. { url: `https://api.youxiaohou.com/config/v2/xunlei/?ver=${version}&a=${author}`, filename: 'xunlei.json' },
  5821. { url: `https://api.youxiaohou.com/config/v2/quark/?ver=${version}&a=${author}`, filename: 'quark.json' },
  5822. { url: `https://api.youxiaohou.com/config/v2/yidong/?ver=${version}&a=${author}`, filename: 'yidong.json' },
  5823. ];
  5824.  
  5825. // 发送多个 POST 请求并等待所有请求完成
  5826. let responses = await Promise.all(urlsAndFilenames.map(obj => base.post(obj.url, {}, {}, 'text')));
  5827.  
  5828. // 遍历所有响应并进行处理
  5829. responses.forEach((res, index) => {
  5830. let url = urlsAndFilenames[index].url;
  5831. let filename = urlsAndFilenames[index].filename;
  5832.  
  5833. // 解析响应内容(假设响应内容是 JSON 格式)
  5834. let panData = JSON.parse(base.decode(res));
  5835.  
  5836. // 创建 Blob 对象
  5837. let blob = new Blob([JSON.stringify(panData)], { type: 'application/json' });
  5838.  
  5839. // 下载 Blob 对象
  5840. base.blobDownload(blob, filename);
  5841. });
  5842. }
  5843. };
  5844. // 将函数暴露到全局作用域以便在控制台中调用
  5845. unsafeWindow.Panlinker = main;
  5846. main.init();
  5847. })();