(改)网盘直链下载助手

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

当前为 2024-07-28 提交的版本,查看 最新版本

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