(改)网盘直链下载助手

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

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

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