From 0be7dce0d8548e33ebf75c98bb9ebe06f43507a1 Mon Sep 17 00:00:00 2001 From: Hmjz100 <98228280+hmjz100@users.noreply.github.com> Date: Thu, 31 Jul 2025 00:18:21 +0800 Subject: [PATCH] v1.1.1.6-fix3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 百度网盘 Aria2 命令多一个 `"` --- (改)网盘直链下载助手.user.js | 830 +++++---------------------------- 1 file changed, 113 insertions(+), 717 deletions(-) diff --git a/(改)网盘直链下载助手.user.js b/(改)网盘直链下载助手.user.js index 1ca8faf..9b42af1 100644 --- a/(改)网盘直链下载助手.user.js +++ b/(改)网盘直链下载助手.user.js @@ -5,6 +5,7 @@ // @author Hmjz100、油小猴 // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4Ij48cGF0aCBkPSJNMTAzLjYgMTA3LjRjMy41LTIuMiA4LjktNi4xIDEzLjgtMTIuNXM3LjMtMTIuNSA4LjUtMTYuNWMuNS0xLjcgMi4yLTcuNSAyLjItMTQuNyAwLTEwLjEtMy4zLTI1LjEtMTUuNC0zNi44LTE0LjUtMTQtMzIuMS0xNC4zLTM1LjctMTQuMy04IDAtMTUuNyAxLjktMjIuNiA1LjJDNDQgMjMgMzUuNyAzMS40IDMwLjggNDEuN2MtMS4zIDIuOC00IDQuNy03LjEgNS00IC4zLTcuNSA0LjQtOC45IDkuNi0uNSAxLjktMS42IDMuNS0zLjEgNC43QzQuNCA2Ni44IDAgNzUuNyAwIDg1YzAgNi44IDIuMyAxMy4xIDYuMSAxOC4yIDUuNSA3LjQgMTQuMiAxMi4yIDI0IDEyLjJoNDcuMWM0LjQgMCAxMS0uNSAxOC4zLTMuNSAzLjItMS40IDUuOS0zIDguMS00LjV6IiBmaWxsPSIjQTA5OUYwIi8+PHBhdGggZD0iTTExOS44IDY0LjNjLjEtMTcuMS0xMC40LTI4LTEyLjUtMzAuMUM5NSAyMi4xIDc5LjkgMjEuOCA3Ni45IDIxLjhjLTE3LjYgMC0zMy4zIDEwLjUtMzkuOSAyNi43LS42IDEuMy0xLjggMi4zLTMuNCAyLjNoLS40Yy01LjggMC0xMC42IDQuOC0xMC42IDEwLjd2LjVjMCAxLjQtLjggMi42LTEuOSAzLjNDMTMuNCA2OSA4LjggNzYuOCA4LjggODVjMCAxMi4yIDkuOSAyMi4zIDIyLjIgMjIuM2g0NS4yYzMuNi0uMSAxNy42LS45IDI5LjYtMTIgMi45LTIuOCAxMy45LTEzLjcgMTQtMzF6IiBmaWxsPSIjNTc0QUI4Ii8+PHBhdGggZD0iTTExMC44IDU3LjRsLjIgMy4zYzAgMS4zLTEuMSAyLjQtMi4zIDIuNC0xLjMgMC0yLjMtMS4xLTIuMy0yLjRsLS4xLTIuOHYtLjNjMC0xLjIuOS0yLjIgMi4xLTIuM2guM2MuNyAwIDEuMy4zIDEuNy43LS4yLjEuMy41LjQgMS40em0tMy4zLTEwLjNjMCAxLjItMSAyLjMtMi4yIDIuM2gtLjFjLS44IDAtMS42LS41LTItMS4yLTQuNi04LjMtMTMuMy0xMy41LTIyLjgtMTMuNS0xLjIgMC0yLjMtMS0yLjMtMi4ydi0uMWMwLTEuMiAxLTIuMyAyLjItMi4zaC4xYTMwLjM3IDMwLjM3IDAgMCAxIDE1LjggNC40YzQuNiAyLjggOC40IDYuOCAxMS4xIDExLjUuMS4zLjIuNy4yIDEuMXpNODguMyA3My44TDczLjUgOTMuMmMtMS41IDEuOS0zLjUgMy4xLTUuNyAzLjVoLS4yYy0uNC4xLS44LjEtMS4yLjEtLjYgMC0xLjEtLjEtMS42LS4yLTIuMi0uNC00LjItMS43LTUuNi0zLjVMNDQuMyA3My45Yy0yLTIuNi0yLjUtNS40LTEuNC03LjcuMS0uMS4xLS4yLjItLjIgMS4yLTIgMy41LTMuMiA2LjQtMy4yaDYuNnYtNS43YzAtNi44IDQuNy0xMiAxMC45LTEyIDQuOCAwIDguNSAyLjYgMTAuMyA3LjIuNSAxLjMtLjIgMi43LTEuNSAzLjJzLTIuOC0uMS0zLjMtMS40Yy0xLjEtMi43LTIuOS00LTUuNS00LTMuNSAwLTYgMy02IDd2OC4xYzAgLjUtLjIgMS0uNiAxLjQtLjYuNy0xLjcgMS4xLTIuNiAxLjFoLTguNGMtMS4zIDAtMiAuNC0yLjEuNy0uMi40IDAgMS4zLjkgMi40TDYzLjEgOTBjLjkgMS4yIDIuMSAxLjggMy4zIDEuOHMyLjMtLjYgMy4xLTEuN2wxNC44LTE5LjNjLjktMS4xIDEuMS0yIC45LTIuNC0uMi0uMy0uOS0uNy0yLjEtLjdoLTcuNmMtLjkgMC0xLjctLjUtMi4xLTEuMi0uMy0uNC0uNC0uOC0uNC0xLjMgMC0xLjQgMS4xLTIuNSAyLjUtMi41aDcuNmMzLjEgMCA1LjUgMS4zIDYuNiAzLjVsLjMuN2MuNyAyLjEuMSA0LjYtMS43IDYuOXoiIGZpbGw9IiNmZmYiLz48L3N2Zz4= // @description (。>ᴗ•)✧《也许同类型中最好用?》系列 - 一个基于 JavaScript 的网盘文件下载地址获取工具✨,基于【网盘直链下载助手】修改 | 支持 百度网盘 / 阿里云盘 / 中国移动云盘 / 天翼云盘 / 迅雷云盘 / 夸克网盘 / UC网盘 / 123云盘 八大网盘 | 开源・自用・去广 | 改界面・添功能・修Bug | 既超越原版,亦是同类中最好用版本!👋 +// @description:zh-CN (。>ᴗ•)✧《也许同类型中最好用?》系列 - 一个基于 JavaScript 的网盘文件下载地址获取工具✨,基于【网盘直链下载助手】修改 | 支持 百度网盘 / 阿里云盘 / 中国移动云盘 / 天翼云盘 / 迅雷云盘 / 夸克网盘 / UC网盘 / 123云盘 八大网盘 | 开源・自用・去广 | 改界面・添功能・修Bug | 既超越原版,亦是同类中最好用版本!👋 // @description:zh-TW (。>ᴗ•)✧《也許同類型中最好用?》系列 - 一個基於 JavaScript 的網盤檔案下載地址獲取工具✨,基於【網盤直鏈下載助手】改編 | 支援 百度網盤 / 阿里雲盤 / 中國移動雲盤 / 天翼雲盤 / 迅雷雲盤 / 夸克網盤 / UC網盤 / 123雲盤 八大平台 | 開源・自用・除廣 | 改介面・擴功能・修Bug | 既超越原版,亦是同類中最好用版本!👋 // @description:zh-HK (。>ᴗ•)✧《也許同類型中最好用?》系列 - 一個基於 JavaScript 的網盤檔案下載地址獲取工具✨,基於【網盤直鏈下載助手】改編 | 支援 百度網盤 / 阿里雲盤 / 中國移動雲盤 / 天翼雲盤 / 迅雷雲盤 / 夸克網盤 / UC網盤 / 123雲盤 八大平台 | 開源・自用・除廣 | 改介面・擴功能・修Bug | 既超越原版,亦是同類中最好用版本!👋 // @license AGPL-3.0-or-later @@ -93,7 +94,6 @@ // @compatible Safari // @compatible Opera // ==/UserScript== - /** * @name LinkSwift * @template (改)网盘直链下载助手 @@ -104,15 +104,13 @@ * 支持 百度网盘/阿里云盘/中国移动云盘/天翼云盘/迅雷云盘/夸克网盘/UC网盘/123云盘 八大网盘 * @version 1.1.1.6 * @license AGPL-3.0-or-later - * @see{@link https://github.com/hmjz100/LinkSwift/ Github 仓库} + * @see {@link https://github.com/hmjz100/LinkSwift/ Github 仓库} */ (function linkSwift() { // 严格模式,确保代码安全执行,不越界 'use strict'; - - // unsafeWindow 检测 + // unsafeWindow 检测,适用于 Via 这类无 unsafeWindow 的浏览器 if (typeof (unsafeWindow) === 'undefined') window.unsafeWindow = window; - /* 防止代码因其他原因被执行多次 代码出自 “Via 轻插件”,作者谷花泰 @@ -120,7 +118,6 @@ let key = encodeURIComponent('LinkSwift:主代码'); if (window[key]) return; window[key] = true; - /* 网盘直链下载助手 代码改自 “网盘直链下载助手”,作者油小猴 @@ -139,7 +136,6 @@ let $doc = $(document); let temp = { pege: "", - shareParams: {}, mode: [], links: [], color: "", @@ -165,7 +161,6 @@ mt: "Apple MacOS 终端" } }; - /** * SweetAlert2 的 Toast 提示框基础配置 * @author 油小猴 @@ -190,7 +185,6 @@ }); } }); - /** * 消息提示工具类 * @author 油小猴 @@ -214,7 +208,6 @@ toast.fire({ title: text, icon: 'question' }); } }; - /** * 基础配置集合 * @author 油小猴 @@ -225,32 +218,31 @@ num: "865746", license: "AGPL3", service: { - account: "https://pic.rmb.bdstatic.com/bjh/8b9e14345b3cdf96aedac2f3971adcb02681.png", - rpc: "http://d.youxiaohou.com" + account: "https://pic.rmb.bdstatic.com/bjh/8b9e14345b3cdf96aedac2f3971adcb02681.png" }, dom: { - footer: `
o(≧▽≦)o 十分感谢您的支持!来给此项目一个 Star 吧~
`, + footer: `o(≧▽≦)o 十分感谢您的支持!来给此项目一个 Star 吧~`, button: { api: { title: "API 下载", - footer: `
适用于 IDMNDM 以及浏览器自带下载
` + footer: `

适用于 IDMNDM 以及浏览器自带下载

` }, aria2: { title: "Aria2 下载", - footer: `
RPC 适用于 MotrixAria2 ToolsAriaNgGUI
-
命令行适用于 XDownLinux Shell 命令行
` + footer: `

RPC 适用于 MotrixAria2 ToolsAriaNgGUI

+

命令行适用于 XDownLinux Shell 命令行

` }, curl: { title: "cURL 下载", - footer: `
适用于 Windows,Linux,MacOS 终端
` + footer: `

适用于 Windows,Linux,MacOS 终端

` }, bitcomet: { title: "比特彗星下载", - footer: `
适用于 比特彗星
` + footer: `

适用于 比特彗星

` }, abdm: { title: "ABDM 下载", - footer: `
适用于 AB Download Manager
` + footer: `

适用于 AB Download Manager

` } }, theme: [ @@ -415,7 +407,6 @@ } } } - /** * 基础工具集合 * @author 油小猴 @@ -442,7 +433,6 @@ base.showDebug(); }); }, - /** * 判断 JavaScript 对象类型 * @author 油小猴 @@ -456,7 +446,6 @@ isType(obj) { return Object.prototype.toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase(); }, - /** * 获取 GreaseMonkey-Compatible-Manager 存储的值 * @author 油小猴 @@ -466,7 +455,6 @@ getValue(name) { return GM_getValue(name); }, - /** * 设置 GreaseMonkey-Compatible-Manager 存储的值 * @author 油小猴 @@ -489,7 +477,6 @@ current[path[path.length - 1]] = value; GM_setValue(key, obj); }, - /** * 删除 GreaseMonkey-Compatible-Manager 存储的值 * @author 油小猴 @@ -498,7 +485,6 @@ delValue(key) { return GM_deleteValue(key); }, - /** * 从 localStorage 获取存储值 * @description 自动解析 JSON 格式内容 @@ -513,7 +499,6 @@ return localStorage.getItem(key); } }, - /** * 设置 localStorage 存储值 * @author 油小猴 @@ -527,7 +512,6 @@ } return localStorage.setItem(key, value); }, - /** * 删除 localStorage 存储值 * @author 油小猴 @@ -537,7 +521,6 @@ delStorage(key) { return localStorage.removeItem(key); }, - /** * 剪贴板写入 * @author 油小猴 @@ -546,7 +529,6 @@ setClipboard(text) { GM_setClipboard(text, 'text'); }, - /** * Base64-URI 编码处理 * @author 油小猴 @@ -559,7 +541,6 @@ try { str = btoa(str) } catch { } return str; }, - /** * Base64-URI 解码处理 * @author 油小猴 @@ -574,7 +555,6 @@ try { str = decodeURIComponent(str) } catch { } return str; }, - /** * 数字补零格式化 * @author hmjz100 @@ -589,7 +569,6 @@ return i; } }, - /** * 获取文件扩展名并转为大写 * @author 油小猴 @@ -604,7 +583,6 @@ } return ""; }, - /** * 文件大小格式化 * @author hmjz100 @@ -627,7 +605,6 @@ } return ""; }, - /** * 将剩余时间(秒)格式化为可读的时间字符串 * @@ -651,16 +628,12 @@ if (!Number.isFinite(remainingTimeSeconds) || remainingTimeSeconds < 0) { return '计算中...'; } - let remainingDays = Math.floor(remainingTimeSeconds / (60 * 60 * 24)); remainingTimeSeconds %= (60 * 60 * 24); - let remainingHours = Math.floor(remainingTimeSeconds / (60 * 60)); remainingTimeSeconds %= (60 * 60); - let remainingMinutes = Math.floor(remainingTimeSeconds / 60); let remainingSeconds = Math.floor(remainingTimeSeconds % 60); - if (remainingDays > 0) { return `${remainingDays}天 ${base.timeFormat(remainingHours)}时:${base.timeFormat(remainingMinutes)}分:${base.timeFormat(remainingSeconds)}秒`; } else if (remainingHours > 0) { @@ -673,7 +646,6 @@ return '即将完成'; } }, - /** * 文件列表排序 * @author 油小猴 @@ -691,7 +663,6 @@ }; arr.sort(handle()); }, - /** * 文件名安全处理 * @author 油小猴 @@ -703,7 +674,6 @@ let replace = /[!?&|`"'*\/:<>\\]/g return name.replace(replace, '_'); }, - /** * 生成 cURL 下载命令 * @author 油小猴 @@ -748,7 +718,6 @@ let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}${headers ? ("&" + headers) : ""}ZZ`; return `bc://http/${base.encodeBase(bc)}`; }, - /** * 发送链接到 Aria2 下载器 * @author 油小猴 @@ -769,7 +738,6 @@ dir: selected.dir, token: selected.token }; - let url = `${rpc.domain}:${rpc.port}${rpc.path}`; let dir = (rpc.dir !== null && rpc.dir !== "") ? rpc.dir : undefined; let data = { @@ -790,7 +758,6 @@ return 'fail'; } }, - /** * 发送链接到比特彗星下载器 * @author hmjz100 @@ -811,26 +778,22 @@ authName: selected.authName, authPass: selected.authPass, }; - let url = `${rpc.domain}:${rpc.port}${rpc.path}`; let data = new URLSearchParams(); data.append('url', link); if (rpc.dir !== null && rpc.dir !== "") data.append('save_path', rpc.dir); data.append('file_name', filename); data.append('connection', 200); - if (headers && base.isType(headers) === 'object') { for (const [key, value] of Object.entries(headers)) { data.append(key, value); } } - try { let res = await base.post(url, data, { "Authorization": `Basic ${base.encodeBase(rpc.authName + ":" + rpc.authPass)}`, "Content-Type": "application/x-www-form-urlencoded" }, "blob"); - if (res.response && res?.responseText?.includes('Add task failed!')) { return 'fail'; } else { @@ -840,7 +803,6 @@ return "success"; } }, - /** * 发送链接到 AB Download Manager 下载器 * @author hmjz100 @@ -856,7 +818,6 @@ newHeaders[key.toLowerCase().split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('-')] = headers[key]; } headers = { "User-Agent": navigator.userAgent, "Origin": location.origin, "Referer": `${location.origin}/`, "DNT": "1", ...newHeaders }; - let list = base.getValue('setting_abdm_rpc'); let selected = list.find(i => i.default); let rpc = { @@ -864,7 +825,6 @@ port: selected.port, dir: selected.dir }; - let url = `${rpc.domain}:${rpc.port}/start-headless-download`; let data = { "downloadSource": { @@ -877,7 +837,6 @@ "name": filename } if (rpc.dir) data.folder = rpc.dir; - try { let res = await base.post(url, data, { "Content-Type": "text/plain;charset=UTF-8" }, "text"); if (res === "OK") return "success"; @@ -886,7 +845,6 @@ return 'fail'; } }, - /** * Blob 文件下载 * @author 油小猴 @@ -904,7 +862,6 @@ URL.revokeObjectURL(url); } }, - /** * 可跨域 xmlhttpRequest 请求 * @author hmjz100 @@ -916,7 +873,6 @@ let request = (base.isType(GM_xmlhttpRequest) !== "undefined") ? GM_xmlhttpRequest : GM.xmlHttpRequest; if (request && base.isType(request) === 'function') return request(option); }, - /** * 发送 POST 请求 * @author 油小猴 @@ -935,13 +891,11 @@ } else if (this.isType(data) === 'urlsearchparams') { exampleData = Object.fromEntries(data); } - let newHeaders = {}; for (let key in headers) { newHeaders[key.toLowerCase().split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('-')] = headers[key]; } headers = { "Content-Type": "application/json;charset=utf-8", "User-Agent": navigator.userAgent, "Origin": location.origin, "Referer": `${location.origin}/`, "DNT": "1", ...newHeaders }; - return new Promise((resolve, reject) => { let sendRequest = () => { base.xmlHttpRequest({ @@ -964,7 +918,6 @@ sendRequest(); // 初始请求 }); }, - /** * 发送 GET 请求 * @author 油小猴 @@ -1011,7 +964,7 @@ temp.idm[extra.index] = true; return; } - if (extra && extra.filename && extra.index) { + if (extra && res.loaded && res.total && extra.filename && extra.index) { res.total > 0 ? temp.progress[extra.index] = (res.loaded * 100 / res.total) : temp.progress[extra.index] = 0.00; } }, @@ -1031,13 +984,11 @@ }, }); }; - sendRequest(); // 初始请求 }); }, - /** - * 获取最终重定向 URL(手动处理 30x 跳转) + * 获取最终重定向 URL * @author 油小猴 * @author hmjz100 * @description 手动追踪 HTTP 30x 重定向,返回最终访问地址 @@ -1058,7 +1009,6 @@ }, onload: function (res) { console.log('【LinkSwift】Get(load) FinalUrl\n请求地址:' + res.finalUrl + '\n响应状态:' + res.status); - let status = res.status; if (status >= 300 && status < 400) { base.getFinalUrl(res.finalUrl, headers, maxRetries, currentRetry + 1).then(resolve).catch(reject); @@ -1081,7 +1031,6 @@ }, onload: function (res) { console.log('【LinkSwift】Head(load) FinalUrl\n请求地址:' + res.finalUrl + '\n响应状态:' + res.status); - let status = res.status; if (status >= 300 && status < 400) { base.getFinalUrl(res.finalUrl, headers, maxRetries, currentRetry + 1).then(resolve).catch(reject); @@ -1097,7 +1046,6 @@ } }); }, - /** * Aria2 RPC 服务测试 * @author hmjz100 @@ -1140,7 +1088,6 @@ }); }); }, - /** * AB Download Manager RPC 服务测试 * @author hmjz100 @@ -1171,7 +1118,6 @@ }); }); }, - /** * 重置请求相关数据 * @author 油小猴 @@ -1189,7 +1135,6 @@ temp.ins = {}; temp.request = {}; }, - /** * 重置请求相关数据 * @author 油小猴 @@ -1201,7 +1146,6 @@ temp.progress[i] = 0; temp.idm[i] = false; }, - /** * 将对象转换为 URL 编码字符串 * @author 油小猴 @@ -1225,7 +1169,6 @@ } return str.slice(0, -1); // 去掉末尾的 "&" }, - /** * 动态注入样式表 * @author 油小猴 @@ -1244,12 +1187,11 @@ rel: 'stylesheet', id: id }); - tag === 'style' ? $style.html(css.trim().replace(/\t/g, '').replace(/\r\n|\n\r|\n|\r/g, '\n').replace(/\n+/g, '\n')) : $style.attr('href', css); + tag === 'style' ? $style.html(css.trim().replace(/\t/g, "").replace(/\r\n|\n\r|\n|\r/g, '\n').replace(/\n+/g, '\n')) : $style.attr('href', css); if ($styleDom.length) { $styleDom.replaceWith($style); return true; } - if (position === "before") { element.before($style); } else if (position === "after") { @@ -1262,7 +1204,6 @@ return true; }, true); }, - /** * 十六进制颜色转 RGBA * @author hmjz100 @@ -1290,7 +1231,6 @@ // 返回 rgba 格式字符串 return r + ', ' + g + ', ' + b + a; }, - /** * RGBA 颜色转十六进制 * @author hmjz100 @@ -1301,26 +1241,21 @@ rgbaToHex(rgba) { // 去掉前缀 "rgba" 或 "rgb" 并移除空格 rgba = rgba.replace(/^(rgba?|RGBA?)\(/, "").replace(/\s+/g, "").replace(')', ""); - // 将颜色值分割为数组 let [r, g, b, a] = rgba.split(','); - // 将 RGB 转换为十六进制 r = parseInt(r).toString(16).padStart(2, '0'); g = parseInt(g).toString(16).padStart(2, '0'); b = parseInt(b).toString(16).padStart(2, '0'); - // 如果存在 alpha 通道,处理透明度值 if (a !== undefined) { // 将 alpha 转换为 0 到 255 的十六进制 a = Math.round(parseFloat(a) * 255).toString(16).padStart(2, '0'); return `#${r}${g}${b}${a}`; } - // 如果没有 alpha 通道,返回标准六位的十六进制颜色 return `#${r}${g}${b}`; }, - /** * 自适应 CSS 颜色替换 * @author hmjz100 @@ -1333,7 +1268,6 @@ */ adaptiveStyleOverride(cssText, baseURI, type, colorMap) { if (!cssText) return ""; - if (baseURI) { // 替换相对路径资源为绝对路径 cssText = cssText.replace(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/g, (match, quote, url) => { @@ -1348,30 +1282,25 @@ return match; }); } - // 处理默认颜色列表 config.base.dom.theme.forEach(item => { let oldColor = item.color; cssText = cssText.replace(new RegExp(base.hexToRgba(oldColor), 'ig'), base.hexToRgba(temp.color)); cssText = cssText.replace(new RegExp(oldColor, 'ig'), temp.color); }); - // 处理 colorMap if (type === 'other') { colorMap.forEach(function (colorPair) { let oldColor = colorPair[0]; let newColor = colorPair[1]; - // 生成旧颜色的三种形式:原样、全大写、全小写 const variants = [ oldColor, oldColor.toUpperCase(), oldColor.toLowerCase() ]; - // 使用 Set 去重 const uniqueVariants = [...new Set(variants)]; - uniqueVariants.forEach(variant => { const regex = new RegExp(variant, 'g'); cssText = cssText.replace(regex, newColor); @@ -1379,28 +1308,23 @@ }); return cssText; } - if (colorMap) { colorMap.forEach(function (colorPair) { let oldColor = colorPair[0]; let newColor = colorPair[1]; - // 生成三种形式 const variants = [ oldColor, oldColor.toUpperCase(), oldColor.toLowerCase() ]; - const uniqueVariants = [...new Set(variants)]; - if (oldColor.includes("#")) { // 替换带属性块的情况(添加 transition) uniqueVariants.forEach(variant => { const regexWithBlock = new RegExp(variant + '(.*?)}', 'gi'); cssText = cssText.replace(regexWithBlock, newColor + '$1; transition:all.2s}'); }); - // 最后再统一替换剩下的 uniqueVariants.forEach(variant => { cssText = cssText.replace(new RegExp(variant, 'gi'), newColor); @@ -1413,10 +1337,8 @@ } }); } - return cssText; }, - /** * 自适应全局主题颜色修改器 * @author hmjz100 @@ -1489,7 +1411,6 @@ } }); }, true); - base.waitForKeyElements(`[style]:not([id^="${mount}-"],[class*="listener-"])`, function (element) { if (element.attr("data-pl-colored") === temp.color) return; let originalStyle = element.attr("style"); @@ -1503,7 +1424,6 @@ temp.colored = true; } }, - /** * 延时执行 * @author 油小猴 @@ -1514,7 +1434,6 @@ sleep(time) { return new Promise(resolve => setTimeout(resolve, time)); }, - /** * 判断版本号新旧 * @author hmjz100 @@ -1532,13 +1451,11 @@ for (let i = 0; i < maxLength; i++) { let numA = partsA[i] || 0; let numB = partsB[i] || 0; - if (numA > numB) return true; if (numA < numB) return false; } return false; }, - /** * 提取版本号主版本 * @author 油小猴 @@ -1549,7 +1466,6 @@ let [major] = (version || "").split('.'); return /^\d+$/.test(major) ? major : null; }, - /** * 查找 React 组件实例 * @author 油小猴 @@ -1565,7 +1481,6 @@ }); let domFiber = dom[key]; if (domFiber == null) return null; - if (domFiber._currentElement) { let compFiber = domFiber._currentElement._owner; for (let i = 0; i < traverseUp; i++) { @@ -1573,7 +1488,6 @@ } return compFiber._instance; } - let GetCompFiber = fiber => { let parentFiber = fiber.return; while (base.isType(parentFiber.type) == "string") { @@ -1587,7 +1501,6 @@ } return compFiber.stateNode || compFiber; }, - /** * 迁移旧版本配置 * @author hmjz100 @@ -1652,7 +1565,6 @@ console.error("【LinkSwift】迁移旧版本配置到新配置时出错", e); } }, - /** * 初始化默认配置 * @author 油小猴 @@ -1734,11 +1646,9 @@ value: "1" } ]; - function cloneDeep(item) { return JSON.parse(JSON.stringify(item)); } - function fillMissingFields(target, source) { // 如果 target 不存在,直接返回 source 的深拷贝 if (target === null || target === undefined) { @@ -1809,13 +1719,12 @@ } }); }, - /** * 显示设置界面 * @author 油小猴 * @author hmjz100 * @description 构建包含 RPC 配置、终端类型等设置项的交互界面 - * @see{@link https://www.youxiaohou.com/zh-cn/motrix.html#使用指南 RPC 配置说明}、{@link https://www.youxiaohou.com/zh-cn/curl.html cURL 使用教程} + * @see {@link https://www.youxiaohou.com/zh-cn/motrix.html#使用指南 RPC 配置说明}、 {@link https://www.youxiaohou.com/zh-cn/curl.html cURL 使用教程} */ showSetting(event) { let setting = $(`
@@ -1850,7 +1759,7 @@ allowOutsideClick: false, showCloseButton: true, showConfirmButton: false, - footer: `
LinkSwifthmjz100 制作
${config.base.dom.footer}
`, + footer: `

LinkSwifthmjz100 制作

${config.base.dom.footer}

`, didOpen: (toast) => { let element = $(toast); if (event && Object.keys($(event.currentTarget).data()).some(key => key.startsWith('backTo'))) element.find('.swal2-close').addClass('listener-tip').attr('data-title', '返回上页').css({ "left": "0", "right": "auto" }).text("◃"); @@ -1861,12 +1770,11 @@ }, }); }, - /** * 显示 Aria2 服务设置界面 * @author hmjz100 * @description 包含 RPC 配置的交互界面 - * @see{@link https://www.youxiaohou.com/zh-cn/motrix.html#使用指南 RPC 配置说明} + * @see {@link https://www.youxiaohou.com/zh-cn/motrix.html#使用指南 RPC 配置说明} */ showAria2Setting(event) { let AriaList = base.getValue('setting_aria2_rpc'); @@ -1887,7 +1795,7 @@
`; }).join("") } - function changeTheme() { let themeList = [ { name: '百度网盘', key: '$baidu' }, @@ -2115,7 +2019,6 @@ `; }).join(""); } - let beautify = $(`
带星号的美化项目将在网页刷新后生效
@@ -2129,7 +2032,6 @@ .pl-input[type=checkbox]{height:20px;width:20px;padding:0!important;background-image:none!important}
`) - Swal.fire({ ...temp.swalDefault, title: '(✿ᴗ‿ᴗ) 助手美化', @@ -2139,10 +2041,9 @@ allowOutsideClick: false, showCloseButton: true, showConfirmButton: false, - footer: `
LinkSwifthmjz100 制作
${config.base.dom.footer}
`, + footer: `

LinkSwifthmjz100 制作

${config.base.dom.footer}

`, }); }, - /** * 显示调试信息面板 * @description 展示脚本运行时环境、版本信息及依赖状态 @@ -2153,17 +2054,15 @@ showDebug() { let debugInfo = ""; debugInfo += `以下内容均为脚本自检信息
本页面仅作为调试使用`; - debugInfo += ``; - debugInfo += ``; - debugInfo += ``; - debugInfo += ``; - debugInfo += ``; - - debugInfo += ``; - debugInfo += ``; - + debugInfo += ``; + debugInfo += ``; + debugInfo += ``; + debugInfo += ``; + debugInfo += ``; + debugInfo += ``; + debugInfo += ``; + debugInfo += ``; debugInfo = '
' + debugInfo + '
'; - Swal.fire({ ...temp.swalDefault, icon: 'info', @@ -2171,9 +2070,9 @@ html: debugInfo, allowOutsideClick: false, showCloseButton: true, + footer: `

LinkSwifthmjz100 制作

${config.base.dom.footer}

`, }); }, - /** * 显示版本更新日志 * @author hmjz100 @@ -2658,30 +2557,25 @@ confirmButtonText: ' 我已阅', }); }, - /** * 创建浮动提示框 * @description 监听元素悬停事件,动态显示带文件大小的提示框 * @author 油小猴 * @author hmjz100 * @fires .listener-tip - 鼠标移动事件触发提示框定位 - * @see{@link temp.color} 使用全局主题色渲染文件大小信息 + * @see {@link temp.color} 使用全局主题色渲染文件大小信息 */ createTip() { let tooltip = $('
'); - this.waitForKeyElements(`.${mount}`, (element) => { if ($('.pl-tooltip').length <= 0) element.append(tooltip); return true; }, true); - // 提取公共显示逻辑 const showTooltip = (target, x, y) => { if (!target.data("title") && !target.data("size") && !target.text()) return; - - let tip = ''; + let tip = ""; let title = target.data("title"); - if (title) { tip += `${title}`; } else { @@ -2692,14 +2586,12 @@ tip += `${size}`; } } - tooltip.html(tip).css({ left: x + 10 + 'px', top: y + 20 + 'px', display: 'flex' }); }; - // 鼠标/触摸移动时更新位置 $doc.on('mousemove touchmove', '.listener-tip', function (e) { const isTouch = e.type.startsWith('touch'); @@ -2707,7 +2599,6 @@ const pageY = isTouch ? e.originalEvent.touches[0].pageY : e.pageY; showTooltip($(e.currentTarget), pageX, pageY); }); - // 触摸开始时立即显示 $doc.on('touchstart', '.listener-tip', function (e) { // 阻止滚动避免干扰 @@ -2715,29 +2606,24 @@ const touch = e.originalEvent.touches[0]; showTooltip($(e.currentTarget), touch.pageX, touch.pageY); }); - // 统一隐藏逻辑 $doc.on('mouseleave touchend touchcancel', '.listener-tip, .pl-tooltip', function (e) { - tooltip.css({ display: '' }); + tooltip.css({ display: "" }); }); - // 增强跨事件类型检测 $doc.on('mousemove touchmove', function (e) { const $tooltip = tooltip; if (!$tooltip.is(':visible')) return; - const isTouch = e.type.startsWith('touch'); const touch = isTouch ? e.originalEvent.touches[0] : null; const target = isTouch ? document.elementFromPoint(touch.clientX, touch.clientY) : e.target; - if (!$(target).closest('.listener-tip, .pl-tooltip').length) { - $tooltip.css({ display: '' }); + $tooltip.css({ display: "" }); } }); }, - /** * 创建加载状态弹窗 * @author 油小猴 @@ -2746,7 +2632,6 @@ createLoading() { return $('
'); }, - /** * 创建用于下载的隐藏 iframe * @author 油小猴 @@ -2759,7 +2644,6 @@ element.append(iframe); }, true) }, - /** * 创建用于下载页面的 HTML * @author 油小猴 @@ -2772,7 +2656,6 @@ if (base.isType(configs) !== "array" && configs.length !== 2) return message.error('提示:
配置解析失败~'); let list = (Array.isArray(configs[0]) ? configs[0] : []); if (!list.length) return message.error('提示:
获取下载链接失败,刷新网页后再试试吧~'); - let { isFolder, getFileName, @@ -2782,7 +2665,6 @@ convert = {}, tooltip = {} } = (base.isType(configs[1]) === 'object' ? configs[1] : {}); - let content = $(`
`); let allLink = []; list.forEach((v, i) => { @@ -2804,7 +2686,7 @@ - +