(改)网盘直链下载助手

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

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

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