// ==UserScript== // @name LinkSwift // @namespace github.com/hmjz100 // @version 1.1.1 // @author Hmjz100、油小猴 // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4Ij48cGF0aCBkPSJNMTAzLjYgMTA3LjRjMy41LTIuMiA4LjktNi4xIDEzLjgtMTIuNXM3LjMtMTIuNSA4LjUtMTYuNWMuNS0xLjcgMi4yLTcuNSAyLjItMTQuNyAwLTEwLjEtMy4zLTI1LjEtMTUuNC0zNi44LTE0LjUtMTQtMzIuMS0xNC4zLTM1LjctMTQuMy04IDAtMTUuNyAxLjktMjIuNiA1LjJDNDQgMjMgMzUuNyAzMS40IDMwLjggNDEuN2MtMS4zIDIuOC00IDQuNy03LjEgNS00IC4zLTcuNSA0LjQtOC45IDkuNi0uNSAxLjktMS42IDMuNS0zLjEgNC43QzQuNCA2Ni44IDAgNzUuNyAwIDg1YzAgNi44IDIuMyAxMy4xIDYuMSAxOC4yIDUuNSA3LjQgMTQuMiAxMi4yIDI0IDEyLjJoNDcuMWM0LjQgMCAxMS0uNSAxOC4zLTMuNSAzLjItMS40IDUuOS0zIDguMS00LjV6IiBmaWxsPSIjQTA5OUYwIi8+PHBhdGggZD0iTTExOS44IDY0LjNjLjEtMTcuMS0xMC40LTI4LTEyLjUtMzAuMUM5NSAyMi4xIDc5LjkgMjEuOCA3Ni45IDIxLjhjLTE3LjYgMC0zMy4zIDEwLjUtMzkuOSAyNi43LS42IDEuMy0xLjggMi4zLTMuNCAyLjNoLS40Yy01LjggMC0xMC42IDQuOC0xMC42IDEwLjd2LjVjMCAxLjQtLjggMi42LTEuOSAzLjNDMTMuNCA2OSA4LjggNzYuOCA4LjggODVjMCAxMi4yIDkuOSAyMi4zIDIyLjIgMjIuM2g0NS4yYzMuNi0uMSAxNy42LS45IDI5LjYtMTIgMi45LTIuOCAxMy45LTEzLjcgMTQtMzF6IiBmaWxsPSIjNTc0QUI4Ii8+PHBhdGggZD0iTTExMC44IDU3LjRsLjIgMy4zYzAgMS4zLTEuMSAyLjQtMi4zIDIuNC0xLjMgMC0yLjMtMS4xLTIuMy0yLjRsLS4xLTIuOHYtLjNjMC0xLjIuOS0yLjIgMi4xLTIuM2guM2MuNyAwIDEuMy4zIDEuNy43LS4yLjEuMy41LjQgMS40em0tMy4zLTEwLjNjMCAxLjItMSAyLjMtMi4yIDIuM2gtLjFjLS44IDAtMS42LS41LTItMS4yLTQuNi04LjMtMTMuMy0xMy41LTIyLjgtMTMuNS0xLjIgMC0yLjMtMS0yLjMtMi4ydi0uMWMwLTEuMiAxLTIuMyAyLjItMi4zaC4xYTMwLjM3IDMwLjM3IDAgMCAxIDE1LjggNC40YzQuNiAyLjggOC40IDYuOCAxMS4xIDExLjUuMS4zLjIuNy4yIDEuMXpNODguMyA3My44TDczLjUgOTMuMmMtMS41IDEuOS0zLjUgMy4xLTUuNyAzLjVoLS4yYy0uNC4xLS44LjEtMS4yLjEtLjYgMC0xLjEtLjEtMS42LS4yLTIuMi0uNC00LjItMS43LTUuNi0zLjVMNDQuMyA3My45Yy0yLTIuNi0yLjUtNS40LTEuNC03LjcuMS0uMS4xLS4yLjItLjIgMS4yLTIgMy41LTMuMiA2LjQtMy4yaDYuNnYtNS43YzAtNi44IDQuNy0xMiAxMC45LTEyIDQuOCAwIDguNSAyLjYgMTAuMyA3LjIuNSAxLjMtLjIgMi43LTEuNSAzLjJzLTIuOC0uMS0zLjMtMS40Yy0xLjEtMi43LTIuOS00LTUuNS00LTMuNSAwLTYgMy02IDd2OC4xYzAgLjUtLjIgMS0uNiAxLjQtLjYuNy0xLjcgMS4xLTIuNiAxLjFoLTguNGMtMS4zIDAtMiAuNC0yLjEuNy0uMi40IDAgMS4zLjkgMi40TDYzLjEgOTBjLjkgMS4yIDIuMSAxLjggMy4zIDEuOHMyLjMtLjYgMy4xLTEuN2wxNC44LTE5LjNjLjktMS4xIDEuMS0yIC45LTIuNC0uMi0uMy0uOS0uNy0yLjEtLjdoLTcuNmMtLjkgMC0xLjctLjUtMi4xLTEuMi0uMy0uNC0uNC0uOC0uNC0xLjMgMC0xLjQgMS4xLTIuNSAyLjUtMi41aDcuNmMzLjEgMCA1LjUgMS4zIDYuNiAzLjVsLjMuN2MuNyAyLjEuMSA0LjYtMS43IDYuOXoiIGZpbGw9IiNmZmYiLz48L3N2Zz4= // @description (。>ᴗ•)✧《也许同类型中最好用?》系列 - 一个基于 JavaScript 的网盘文件下载地址获取工具✨,基于【网盘直链下载助手】修改 | 支持 百度网盘 / 阿里云盘 / 中国移动云盘 / 天翼云盘 / 迅雷云盘 / 夸克网盘 / UC网盘 / 123云盘 八大网盘 | 开源・自用・去广 | 改界面・添功能・修Bug | 既超越原版,亦是同类中最好用版本!👋 // @description:zh-TW (。>ᴗ•)✧《也許同類型中最好用?》系列 - 一個基於 JavaScript 的網盤檔案下載地址獲取工具✨,基於【網盤直鏈下載助手】改編 | 支援 百度網盤 / 阿里雲盤 / 中國移動雲盤 / 天翼雲盤 / 迅雷雲盤 / 夸克網盤 / UC網盤 / 123雲盤 八大平台 | 開源・自用・除廣 | 改介面・擴功能・修Bug | 既超越原版,亦是同類中最好用版本!👋 // @description:zh-HK (。>ᴗ•)✧《也許同類型中最好用?》系列 - 一個基於 JavaScript 的網盤檔案下載地址獲取工具✨,基於【網盤直鏈下載助手】改編 | 支援 百度網盤 / 阿里雲盤 / 中國移動雲盤 / 天翼雲盤 / 迅雷雲盤 / 夸克網盤 / UC網盤 / 123雲盤 八大平台 | 開源・自用・除廣 | 改介面・擴功能・修Bug | 既超越原版,亦是同類中最好用版本!👋 // @license AGPL-3.0-or-later // @homepage https://github.com/hmjz100/LinkSwift/ // @support https://github.com/hmjz100/LinkSwift/issues // @supportURL https://github.com/hmjz100/LinkSwift/issues // @require https://unpkg.com/jquery@3.6.0/dist/jquery.min.js // @require https://unpkg.com/sweetalert2@11.4.8/dist/sweetalert2.min.js // @resource SwalLigt https://unpkg.com/sweetalert2@11.4.8/dist/sweetalert2.min.css // @resource SwalDark https://unpkg.com/@sweetalert2/theme-dark@5.0.26/dark.min.css // @require https://unpkg.com/js-md5@0.7.3/build/md5.min.js // @run-at document-start // @match *://pan.baidu.com/disk/home* // @match *://yun.baidu.com/disk/home* // @match *://pan.baidu.com/disk/timeline* // @match *://yun.baidu.com/disk/timeline* // @match *://pan.baidu.com/disk/main* // @match *://yun.baidu.com/disk/main* // @match *://pan.baidu.com/youth/pan/main* // @match *://yun.baidu.com/youth/pan/main* // @match *://pan.baidu.com/disk/base* // @match *://yun.baidu.com/disk/base* // @match *://pan.baidu.com/disk/timeline* // @match *://yun.baidu.com/disk/timeline* // @match *://pan.baidu.com/pfile/* // @match *://yun.baidu.com/pfile/* // @match *://pan.baidu.com/s/* // @match *://pan.baidu.com/aipan/* // @match *://yun.baidu.com/s/* // @match *://yun.baidu.com/aipan/* // @match *://pan.baidu.com/share/* // @match *://yun.baidu.com/share/* // @match *://pan.baidu.com/embed/* // @match *://yun.baidu.com/embed/* // @match *://openapi.baidu.com/* // @match *://www.aliyundrive.com/s/* // @match *://www.aliyundrive.com/drive* // @match *://www.alipan.com/s/* // @match *://www.alipan.com/drive* // @match *://cloud.189.cn/web/* // @match *://pan.xunlei.com/* // @match *://pan.quark.cn/* // @match *://drive.uc.cn/* // @match *://yun.139.com/* // @match *://caiyun.139.com/* // @match *://*.123pan.com/* // @match *://*.123pan.cn/* // @match *://*.123684.com/* // @match *://*.123865.com/* // @match *://*.123952.com/* // @match *://*.123912.com/* // @connect baidu.com // @connect baidupcs.com // @connect aliyundrive.com // @connect aliyundrive.net // @connect alipan.com // @connect alicloudccp.com // @connect aliyundrive.cloud // @connect 189.cn // @connect xunlei.com // @connect quark.cn // @connect uc.cn // @connect 123pan.com // @connect 123pan.cn // @connect 123684.com // @connect 123865.com // @connect 123952.com // @connect 123912.com // @connect cjjd19.com // @connect localhost // @connect * // @grant unsafeWindow // @grant window.close // @grant GM_xmlhttpRequest // @grant GM.xmlhttpRequest // @grant GM_setClipboard // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_openInTab // @grant GM_info // @grant GM_registerMenuCommand // @grant GM_cookie // @grant GM_getResourceText // @compatible Chrome // @compatible Edge // @compatible Firefox // @compatible Safari // @compatible Opera // @downloadURL none // ==/UserScript== /** * @name LinkSwift * @template (改)网盘直链下载助手 * @author 油小猴 * @author hmjz100 * @namespace github.com/hmjz100 * @description 一个基于 JavaScript 盘的文件下载地址获取工具 * 支持 百度网盘/阿里云盘/中国移动云盘/天翼云盘/迅雷云盘/夸克网盘/UC网盘/123云盘 八大网盘 * @version 1.1.1 * @license AGPL-3.0-or-later * @see{@link https://github.com/hmjz100/LinkSwift/ Github 仓库} */ (function linkSwift() { // 严格模式,确保代码安全执行,不越界 'use strict'; // unsafeWindow 检测 if (typeof (unsafeWindow) === 'undefined') { window.unsafeWindow = window; } /* 防止代码因其他原因被执行多次 代码出自 “Via 轻插件”,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:主代码'); if (window[key]) return; window[key] = true; /* 网盘直链下载助手 代码改自 “网盘直链下载助手”,作者油小猴 有增添新代码 */ /* 全局参数 */ let mount = idontknow("LinkSwift"); let info = { author: GM_info.script?.author, name: GM_info.script?.name, version: (GM_info.script?.version?.toString() || "1.1.1"), icon: (GM_info.script?.icon || "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4Ij48cGF0aCBkPSJNMTAzLjYgMTA3LjRjMy41LTIuMiA4LjktNi4xIDEzLjgtMTIuNXM3LjMtMTIuNSA4LjUtMTYuNWMuNS0xLjcgMi4yLTcuNSAyLjItMTQuNyAwLTEwLjEtMy4zLTI1LjEtMTUuNC0zNi44LTE0LjUtMTQtMzIuMS0xNC4zLTM1LjctMTQuMy04IDAtMTUuNyAxLjktMjIuNiA1LjJDNDQgMjMgMzUuNyAzMS40IDMwLjggNDEuN2MtMS4zIDIuOC00IDQuNy03LjEgNS00IC4zLTcuNSA0LjQtOC45IDkuNi0uNSAxLjktMS42IDMuNS0zLjEgNC43QzQuNCA2Ni44IDAgNzUuNyAwIDg1YzAgNi44IDIuMyAxMy4xIDYuMSAxOC4yIDUuNSA3LjQgMTQuMiAxMi4yIDI0IDEyLjJoNDcuMWM0LjQgMCAxMS0uNSAxOC4zLTMuNSAzLjItMS40IDUuOS0zIDguMS00LjV6IiBmaWxsPSIjQTA5OUYwIi8+PHBhdGggZD0iTTExOS44IDY0LjNjLjEtMTcuMS0xMC40LTI4LTEyLjUtMzAuMUM5NSAyMi4xIDc5LjkgMjEuOCA3Ni45IDIxLjhjLTE3LjYgMC0zMy4zIDEwLjUtMzkuOSAyNi43LS42IDEuMy0xLjggMi4zLTMuNCAyLjNoLS40Yy01LjggMC0xMC42IDQuOC0xMC42IDEwLjd2LjVjMCAxLjQtLjggMi42LTEuOSAzLjNDMTMuNCA2OSA4LjggNzYuOCA4LjggODVjMCAxMi4yIDkuOSAyMi4zIDIyLjIgMjIuM2g0NS4yYzMuNi0uMSAxNy42LS45IDI5LjYtMTIgMi45LTIuOCAxMy45LTEzLjcgMTQtMzF6IiBmaWxsPSIjNTc0QUI4Ii8+PHBhdGggZD0iTTExMC44IDU3LjRsLjIgMy4zYzAgMS4zLTEuMSAyLjQtMi4zIDIuNC0xLjMgMC0yLjMtMS4xLTIuMy0yLjRsLS4xLTIuOHYtLjNjMC0xLjIuOS0yLjIgMi4xLTIuM2guM2MuNyAwIDEuMy4zIDEuNy43LS4yLjEuMy41LjQgMS40em0tMy4zLTEwLjNjMCAxLjItMSAyLjMtMi4yIDIuM2gtLjFjLS44IDAtMS42LS41LTItMS4yLTQuNi04LjMtMTMuMy0xMy41LTIyLjgtMTMuNS0xLjIgMC0yLjMtMS0yLjMtMi4ydi0uMWMwLTEuMiAxLTIuMyAyLjItMi4zaC4xYTMwLjM3IDMwLjM3IDAgMCAxIDE1LjggNC40YzQuNiAyLjggOC40IDYuOCAxMS4xIDExLjUuMS4zLjIuNy4yIDEuMXpNODguMyA3My44TDczLjUgOTMuMmMtMS41IDEuOS0zLjUgMy4xLTUuNyAzLjVoLS4yYy0uNC4xLS44LjEtMS4yLjEtLjYgMC0xLjEtLjEtMS42LS4yLTIuMi0uNC00LjItMS43LTUuNi0zLjVMNDQuMyA3My45Yy0yLTIuNi0yLjUtNS40LTEuNC03LjcuMS0uMS4xLS4yLjItLjIgMS4yLTIgMy41LTMuMiA2LjQtMy4yaDYuNnYtNS43YzAtNi44IDQuNy0xMiAxMC45LTEyIDQuOCAwIDguNSAyLjYgMTAuMyA3LjIuNSAxLjMtLjIgMi43LTEuNSAzLjJzLTIuOC0uMS0zLjMtMS40Yy0xLjEtMi43LTIuOS00LTUuNS00LTMuNSAwLTYgMy02IDd2OC4xYzAgLjUtLjIgMS0uNiAxLjQtLjYuNy0xLjcgMS4xLTIuNiAxLjFoLTguNGMtMS4zIDAtMiAuNC0yLjEuNy0uMi40IDAgMS4zLjkgMi40TDYzLjEgOTBjLjkgMS4yIDIuMSAxLjggMy4zIDEuOHMyLjMtLjYgMy4xLTEuN2wxNC44LTE5LjNjLjktMS4xIDEuMS0yIC45LTIuNC0uMi0uMy0uOS0uNy0yLjEtLjdoLTcuNmMtLjkgMC0xLjctLjUtMi4xLTEuMi0uMy0uNC0uNC0uOC0uNC0xLjMgMC0xLjQgMS4xLTIuNSAyLjUtMi41aDcuNmMzLjEgMCA1LjUgMS4zIDYuNiAzLjVsLjMuN2MuNyAyLjEuMSA0LjYtMS43IDYuOXoiIGZpbGw9IiNmZmYiLz48L3N2Zz4="), mhandler: GM_info.scriptHandler, mversion: GM_info.version, }; let temp = { pege: "", selectList: [], shareParams: {}, mode: [], color: "", doc: $(document), progress: {}, request: {}, ins: {}, idm: {}, colored: false, swalDefault: { heightAuto: false, scrollbarPadding: false, confirmButtonText: ` 确认`, denyButtonText: ` 拒绝`, cancelButtonText: ` 取消`, }, terminalType: { wc: "Microsoft Windows 命令提示符", wp: "Microsoft Windows PowerShell", lt: "Linux 终端", ls: "Linux Shell", mt: "Apple MacOS 终端", } }; /** * SweetAlert2 的 Toast 提示框基础配置 * @author 油小猴 * @author hmjz100 * @description 创建一个全局通用的 Toast 提示框实例,支持自动关闭、鼠标悬停暂停、右上角弹出等特性。 * * @type{Sweetalert2.Toast} */ let toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 3500, timerProgressBar: true, showCloseButton: true, didOpen: function (toast) { toast.addEventListener('mouseenter', () => { Swal.stopTimer(); }); toast.addEventListener('mouseleave', () => { Swal.resumeTimer(); }); } }); /** * 消息提示工具类 * @author 油小猴 * @description 提供统一的提示信息展示方法,基于 SweetAlert2 的 Toast 实现; * 包含 success / error / warning / info / question 等类型。 */ let message = { success: function (text) { toast.fire({ title: text, icon: 'success' }); }, error: function (text) { toast.fire({ title: text, icon: 'error' }); }, warning: function (text) { toast.fire({ title: text, icon: 'warning' }); }, info: function (text) { toast.fire({ title: text, icon: 'info' }); }, question: function (text) { toast.fire({ title: text, icon: 'question' }); } }; /** * 基础配置集合 * @author 油小猴 * @author hmjz100 */ let config = { base: { num: "865746", license: "AGPL3", service: { account: "https://pic.rmb.bdstatic.com/bjh/8b9e14345b3cdf96aedac2f3971adcb02681.png", rpc: "http://d.youxiaohou.com" }, dom: { footer: `
o(≧▽≦)o 十分感谢您的支持!来给此项目一个 Star 吧~
`, button: { api: { title: "API 下载", footer: `
适用于 IDMNDM 以及浏览器自带下载
` }, aria2: { title: "Aria2 下载", footer: `
RPC 适用于 MotrixAria2 ToolsAriaNgGUI
命令行适用于 XDownLinux Shell 命令行
` }, curl: { title: "cURL 下载", footer: `
适用于 Windows,Linux,MacOS 终端
` }, bitcomet: { title: "比特彗星下载", footer: `
适用于 比特彗星
` } } } }, $baidu: { api: { ua: { downloadLink: "pan.baidu.com" }, getAccessToken: "https://openapi.baidu.com/oauth/2.0/authorize?response_type=token&scope=basic,netdisk&client_id=IlLqBbU3GjQ0t46TRwFateTprHWl39zF&redirect_uri=oob&confirm_login=0", getLink: "https://pan.baidu.com/rest/2.0/xpan/multimedia?method=filemetas&dlink=1", getFiles: "https://pan.baidu.com/rest/2.0/xpan/file?method=list&showempty=1", getShareLink: "https://pan.baidu.com/api/sharedownload?channel=chunlei&clienttype=0&web=1&app_id=250528", getShareInfo: "https://pan.baidu.com/share/tplconfig?fields=sign,timestamp&channel=chunlei&web=1&app_id=250528&clienttype=0", getShareFiles: "https://pan.baidu.com/rest/2.0/xpan/share?method=list&showempty=1" }, mount: { home: ".frame-main>div>div>div>div:has(.g-dropdown-button.g-new-create)", main: ".wp-s-agile-tool-bar__header", share: ".module-share-top-bar .x-button-box .g-dropdown-button.tools-more" }, dom: { enhance: `+
此方式下载有可能会被 IDM 捕获下载链接`, normal: `+
此方式下载有可能会被 IDM 捕获下载链接`, copy: `不建议使用本功能,在百度网盘中单独复制链接并粘贴下载可能会导致服务器回报 403 错误
如仍需使用,请搭配此用户代理进行下载:pan.baidu.com` } }, $aliyun: { api: { getLink: "https://api.aliyundrive.com/v2/file/get_download_url", getShareLink: "https://api.aliyundrive.com/v2/file/get_share_link_download_url" }, mount: { home: "[class^=\"header--\"]>[class^=\"actions--\"]", share: "[class^=\"banner--\"]>[class^=\"right--\"]", list: "[class^=\"node-list-table-view--\"]", grid: "[class^=\"node-list-grid-view--\"]", switch: "[class^=\"switch-wrapper--\"]" }, dom: { enhance: `+
此方式下载不会被 IDM 捕获下载链接`, normal: `+
此方式下载有可能会被 IDM 捕获下载链接`, copy: `不建议使用本功能,在阿里云盘中单独复制链接并粘贴下载可能会导致服务器回报 403 错误`, filename: `阿里云盘于下载高峰期时可能不会显示文件名称,这时需要手动复制文件名称到下载工具中` } }, $mcloud: { api: { getLink: "https://personal-kd-njs.yun.139.com/hcy/file/getDownloadUrl" }, mount: { home: ".top_button", share: ".top-btns" }, dom: { enhance: `+
此方式下载不会被 IDM 捕获下载链接`, normal: `+
此方式下载有可能会被 IDM 捕获下载链接` } }, $tcloud: { api: { getAccessToken: "https://api.cloud.189.cn/open/oauth2/ssoH5.action", getLink: "https://api.cloud.189.cn/open/file/getFileDownloadUrl.action" }, mount: { home: "[class*=\"FileHead_file-head-left\"]", share: ".nav-opea" }, dom: { enhance: `+
此方式下载不会被 IDM 捕获下载链接`, normal: `+
此方式下载有可能会被 IDM 捕获下载链接` } }, $xunlei: { api: { mirror: [ "vod0007-h05-vip-lixian.xunlei.com", "vod0008-h05-vip-lixian.xunlei.com", "vod0009-h05-vip-lixian.xunlei.com", "vod0010-h05-vip-lixian.xunlei.com", "vod0011-h05-vip-lixian.xunlei.com", "vod0012-h05-vip-lixian.xunlei.com", "vod0013-h05-vip-lixian.xunlei.com", "vod0014-h05-vip-lixian.xunlei.com", "vod0067-aliyun08-vip-lixian.xunlei.com", "vod0254-aliyun08-vip-lixian.xunlei.com", "vod0255-aliyun08-vip-lixian.xunlei.com", "vod0256-aliyun08-vip-lixian.xunlei.com", "vod0257-aliyun08-vip-lixian.xunlei.com", "vod0258-aliyun08-vip-lixian.xunlei.com", "vod0259-aliyun08-vip-lixian.xunlei.com", "vod0260-aliyun08-vip-lixian.xunlei.com", "vod0261-aliyun08-vip-lixian.xunlei.com", "vod0262-aliyun08-vip-lixian.xunlei.com", "vod0263-aliyun08-vip-lixian.xunlei.com", "vod0264-aliyun08-vip-lixian.xunlei.com", "vod0265-aliyun08-vip-lixian.xunlei.com", "vod0266-aliyun08-vip-lixian.xunlei.com", "vod0267-aliyun08-vip-lixian.xunlei.com", "vod0554-aliyun06-vip-lixian.xunlei.com", "vod0555-aliyun06-vip-lixian.xunlei.com", "vod0556-aliyun06-vip-lixian.xunlei.com", "vod0680-aliyun08-vip-lixian.xunlei.com", "vod0681-aliyun08-vip-lixian.xunlei.com", "vod0682-aliyun08-vip-lixian.xunlei.com", "vod0683-aliyun08-vip-lixian.xunlei.com", "vod0684-aliyun08-vip-lixian.xunlei.com", "vod0685-aliyun08-vip-lixian.xunlei.com", "vod0686-aliyun08-vip-lixian.xunlei.com", "vod0687-aliyun08-vip-lixian.xunlei.com", "vod0688-aliyun08-vip-lixian.xunlei.com", "vod0689-aliyun08-vip-lixian.xunlei.com", "vod0690-aliyun08-vip-lixian.xunlei.com", "vod0724-aliyun08-vip-lixian.xunlei.com", "vod0725-aliyun08-vip-lixian.xunlei.com", "vod0726-aliyun08-vip-lixian.xunlei.com", "vod0727-aliyun08-vip-lixian.xunlei.com", "vod0728-aliyun08-vip-lixian.xunlei.com", "vod0075.aliyun06.vip.lixian.xunlei.com", "vod0076.aliyun06.vip.lixian.xunlei.com", "vod0077.aliyun06.vip.lixian.xunlei.com", "vod0779-aliyun04-vip-lixian.xunlei.com", "vod0078.aliyun06.vip.lixian.xunlei.com", "vod0780-aliyun04-vip-lixian.xunlei.com", "vod0781-aliyun04-vip-lixian.xunlei.com", "vod0079.aliyun06.vip.lixian.xunlei.com", "vod0080.aliyun06.vip.lixian.xunlei.com", "vod0117.aliyun04.vip.lixian.xunlei.com", "vod0118.aliyun04.vip.lixian.xunlei.com", "vod0119.aliyun04.vip.lixian.xunlei.com", "vod1284-aliyun06-vip-lixian.xunlei.com", "vod1285-aliyun06-vip-lixian.xunlei.com", "vod1363-aliyun06-vip-lixian.xunlei.com", "vod1371-aliyun06-vip-lixian.xunlei.com", "vod1372-aliyun06-vip-lixian.xunlei.com", "vod1426-aliyun06-vip-lixian.xunlei.com", "vod1427-aliyun06-vip-lixian.xunlei.com", "vod1428-aliyun06-vip-lixian.xunlei.com", "vod1429-aliyun06-vip-lixian.xunlei.com", "vod1442-aliyun06-vip-lixian.xunlei.com", "vod1443-aliyun06-vip-lixian.xunlei.com", "vod1444-aliyun06-vip-lixian.xunlei.com", "vod1445-aliyun06-vip-lixian.xunlei.com", "vod1446-aliyun06-vip-lixian.xunlei.com", "vod1447-aliyun06-vip-lixian.xunlei.com", "vod1469-aliyun06-vip-lixian.xunlei.com", "vod1470-aliyun06-vip-lixian.xunlei.com", "vod1471-aliyun06-vip-lixian.xunlei.com", "vod1489-aliyun06-vip-lixian.xunlei.com", "vod1490-aliyun06-vip-lixian.xunlei.com", "vod1491-aliyun06-vip-lixian.xunlei.com", "vod1492-aliyun06-vip-lixian.xunlei.com", "vod1493-aliyun06-vip-lixian.xunlei.com", "vod0215.aliyun06.vip.lixian.xunlei.com", "vod0216.aliyun06.vip.lixian.xunlei.com", "vod0217.aliyun06.vip.lixian.xunlei.com", "vod0218.aliyun06.vip.lixian.xunlei.com", "vod0219.aliyun06.vip.lixian.xunlei.com", "vod0220.aliyun06.vip.lixian.xunlei.com", "vod0241.aliyun08.vip.lixian.xunlei.com", "vod0244.aliyun08.vip.lixian.xunlei.com", "vod0251.aliyun08.vip.lixian.xunlei.com", "vod0252.aliyun08.vip.lixian.xunlei.com", "vod0253.aliyun08.vip.lixian.xunlei.com", "vod0254.aliyun08.vip.lixian.xunlei.com", "vod0255.aliyun08.vip.lixian.xunlei.com", "vod0256.aliyun08.vip.lixian.xunlei.com", "vod0257.aliyun08.vip.lixian.xunlei.com", "vod0260.aliyun08.vip.lixian.xunlei.com", "vod0261.aliyun08.vip.lixian.xunlei.com", "vod0262.aliyun08.vip.lixian.xunlei.com", "vod0263.aliyun08.vip.lixian.xunlei.com", "vod0264.aliyun08.vip.lixian.xunlei.com", "vod0265.aliyun08.vip.lixian.xunlei.com", "vod0266.aliyun08.vip.lixian.xunlei.com", "vod0267.aliyun08.vip.lixian.xunlei.com", "vod3379-aliyun04-vip-lixian.xunlei.com", "vod3380-aliyun04-vip-lixian.xunlei.com", "vod3429-aliyun04-vip-lixian.xunlei.com", "vod3458-aliyun04-vip-lixian.xunlei.com", "vod3459-aliyun04-vip-lixian.xunlei.com", "vod3496-aliyun04-vip-lixian.xunlei.com", "vod3497-aliyun04-vip-lixian.xunlei.com", "vod3498-aliyun04-vip-lixian.xunlei.com", "vod3499-aliyun04-vip-lixian.xunlei.com", "vod3500-aliyun04-vip-lixian.xunlei.com", "vod3501-aliyun04-vip-lixian.xunlei.com", "vod3522-aliyun04-vip-lixian.xunlei.com", "vod3523-aliyun04-vip-lixian.xunlei.com", "vod3533-aliyun04-vip-lixian.xunlei.com", "vod3534-aliyun04-vip-lixian.xunlei.com", "vod3535-aliyun04-vip-lixian.xunlei.com", "vod3536-aliyun04-vip-lixian.xunlei.com", "vod3549-aliyun04-vip-lixian.xunlei.com", "vod3550-aliyun04-vip-lixian.xunlei.com", "vod3551-aliyun04-vip-lixian.xunlei.com", "vod3552-aliyun04-vip-lixian.xunlei.com", "vod3553-aliyun04-vip-lixian.xunlei.com", "vod3554-aliyun04-vip-lixian.xunlei.com", "vod3555-aliyun04-vip-lixian.xunlei.com", "vod0551.aliyun06.vip.lixian.xunlei.com", "vod0552.aliyun06.vip.lixian.xunlei.com", "vod0553.aliyun06.vip.lixian.xunlei.com", "vod0554.aliyun06.vip.lixian.xunlei.com", "vod0555.aliyun06.vip.lixian.xunlei.com", "vod0556.aliyun06.vip.lixian.xunlei.com", "vod0686.aliyun08.vip.lixian.xunlei.com", "vod0687.aliyun08.vip.lixian.xunlei.com", "vod0688.aliyun08.vip.lixian.xunlei.com", "vod0689.aliyun08.vip.lixian.xunlei.com", "vod0724.aliyun08.vip.lixian.xunlei.com", "vod0725.aliyun08.vip.lixian.xunlei.com", "vod0726.aliyun08.vip.lixian.xunlei.com", "vod0727.aliyun08.vip.lixian.xunlei.com", "vod0728.aliyun08.vip.lixian.xunlei.com", "vod0759.aliyun04.vip.lixian.xunlei.com", "vod0760.aliyun04.vip.lixian.xunlei.com", "vod0769.aliyun04.vip.lixian.xunlei.com", "vod0770.aliyun04.vip.lixian.xunlei.com", "vod0771.aliyun04.vip.lixian.xunlei.com", "vod0772.aliyun04.vip.lixian.xunlei.com", "vod0773.aliyun04.vip.lixian.xunlei.com", "vod0774.aliyun04.vip.lixian.xunlei.com", "vod0775.aliyun04.vip.lixian.xunlei.com", "vod0776.aliyun04.vip.lixian.xunlei.com", "vod0777.aliyun04.vip.lixian.xunlei.com", "vod0778.aliyun04.vip.lixian.xunlei.com", "vod0779.aliyun04.vip.lixian.xunlei.com", "vod0780.aliyun04.vip.lixian.xunlei.com", "vod0781.aliyun04.vip.lixian.xunlei.com", "vod3522.aliyun04.vip.lixian.xunlei.com", "vod3523.aliyun04.vip.lixian.xunlei.com", "vod3533.aliyun04.vip.lixian.xunlei.com", "vod3535.aliyun04.vip.lixian.xunlei.com", "vod3550.aliyun04.vip.lixian.xunlei.com", "vod3551.aliyun04.vip.lixian.xunlei.com", "vod3552.aliyun04.vip.lixian.xunlei.com", "vod3553.aliyun04.vip.lixian.xunlei.com", "vod3554.aliyun04.vip.lixian.xunlei.com", "vod3555.aliyun04.vip.lixian.xunlei.com" ], getLink: "https://api-pan.xunlei.com/drive/v1/files/" }, mount: { home: "[class^=\"FileMenu__menu--\"]", share: "[class^=\"Share__batchActionBox--\"]" }, dom: { enhance: `+
此方式下载不会被 IDM 捕获下载链接,但可以自动命名`, normal: `+
此方式下载不会被 IDM 捕获下载链接`, filename: `迅雷云盘下载时可能不会回报文件名称给下载工具,这时需要手动复制文件名称到下载工具中` } }, $quark: { api: { ua: { downloadLink: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch" }, getLink: "https://drive.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc" }, mount: { home: ".btn-operate .btn-main", share: ".share-btns" }, dom: { enhance: `+
此方式下载不会被 IDM 捕获下载链接`, normal: `+
此方式下载有可能会被 IDM 捕获下载链接` } }, $uc: { api: { ua: { downloadLink: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) uc-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch" }, getLink: "https://pc-api.uc.cn/1/clouddrive/file/download?pr=UCBrowser&fr=pc" }, mount: { home: ".btn-operate .btn-main", share: ".file-info-share-buttom" }, dom: { enhance: `+
此方式下载不会被 IDM 捕获下载链接`, normal: `+
此方式下载有可能会被 IDM 捕获下载链接` } }, $123pan: { api: { getLink: "https://www.123pan.com/api/file/download_info", getShareLink: "https://www.123pan.com/api/share/download/info" }, mount: { home: "main.ant-layout-content .site-layout-background .homeClass .wenserh", share: ".conter .rightInfo .qrcode_btn" }, dom: { enhance: `+
此方式下载不会被 IDM 捕获下载链接`, normal: `+
此方式下载有可能会被 IDM 捕获下载链接` } } } /** * 基础工具集合 * @author 油小猴 * @author hmjz100 */ let base = { /** * 注册 GreaseMonkey-Compatible-Manager 扩展菜单命令 * @author 油小猴 * @author hmjz100 * @description 包含 "设置"、"美化"、"更新" 和 "调试" 四个功能入口 */ registerMenuCommand() { GM_registerMenuCommand('⚙️ 设置', () => { base.showSetting(); }); GM_registerMenuCommand('🍃️ 美化', () => { base.showBeautify(); }); GM_registerMenuCommand('📃 更新', () => { base.showUpdate(); }); GM_registerMenuCommand('🛠️ 调试', () => { base.showDebug(); }); }, /** * 判断 JavaScript 对象类型 * @author 油小猴 * @description 通过 Object.prototype.toString 精确识别对象类型 * @param {*} obj - 待检测对象 * @returns {string} 类型名称(全小写),如:array/number/null/date 等 * @example * isType([]) // => "array" * isType(null) // => "null" */ isType(obj) { return Object.prototype.toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase(); }, /** * 获取 GreaseMonkey-Compatible-Manager 存储的值 * @author 油小猴 * @param {string} name - 存储键名 * @returns {*} 存储的值 */ getValue(name) { return GM_getValue(name); }, /** * 设置 GreaseMonkey-Compatible-Manager 存储的值 * @author 油小猴 * @param {string|array} path - 存储键名或路径数组 * @param {*} value - 要存储的值 */ setValue(path, value) { if (base.isType(path) === 'string') { GM_setValue(path, value); return; } let key = path[0]; let obj = this.getValue(key) || {}; let current = obj; for (let i = 1; i < path.length - 1; i++) { let keyPart = path[i]; if (!current[keyPart]) current[keyPart] = ""; current = current[keyPart]; } current[path[path.length - 1]] = value; GM_setValue(key, obj); }, /** * 删除 GreaseMonkey-Compatible-Manager 存储的值 * @author 油小猴 * @param {string|array} key - 单个键名 */ delValue(key) { return GM_deleteValue(key); }, /** * 从 localStorage 获取存储值 * @description 自动解析 JSON 格式内容 * @author 油小猴 * @param {string} key - 存储键名 * @returns {*} 存储的原始值或解析后的对象 */ getStorage(key) { try { return JSON.parse(localStorage.getItem(key)); } catch (e) { return localStorage.getItem(key); } }, /** * 设置 localStorage 存储值 * @author 油小猴 * @description 自动 `JSON.stringify` `对象` `数组` 类型的数据 * @param {string} key - 存储键名 * @param {*} value - 要存储的值 */ setStorage(key, value) { if (this.isType(value) === 'object' || this.isType(value) === 'array') { return localStorage.setItem(key, JSON.stringify(value)); } return localStorage.setItem(key, value); }, /** * 删除 localStorage 存储值 * @author 油小猴 * @description 没什么特别的 * @param {string} key - 存储键名 */ delStorage(key) { return localStorage.removeItem(key); }, /** * 剪贴板写入 * @author 油小猴 * @param {string} text - 要复制的文本内容 */ setClipboard(text) { GM_setClipboard(text, 'text'); }, /** * Base64-URI 编码处理 * @author 油小猴 * @author hmjz100 * @description 自动执行 URI 兼容性编码转换 * @param {string} str - 待编码的字符串 * @returns {string} Base64 编码结果字符串 */ encodeBase(str) { try { str = btoa(str) } catch { } return str; }, /** * Base64-URI 解码处理 * @author 油小猴 * @author hmjz100 * @description 自动执行 URI 兼容性解码转换 * @param {string} str - Base64 编码字符串 * @returns {string} 解码后的原始字符串 */ decodeBase(str) { try { str = decodeURIComponent(str) } catch { } try { str = atob(str) } catch { } try { str = decodeURIComponent(str) } catch { } return str; }, /** * 数字补零格式化 * @author hmjz100 * @description 对 1-9 的数字自动补前导零 * @param {number} i - 待格式化的数字 * @returns {string} 格式化后的字符串(如"05") */ timeFormat(i) { if (i >= 0 && i <= 9) { return "0" + i; } else { return i; } }, /** * 获取文件扩展名并转为大写 * @author 油小猴 * @param {string} name - 完整文件名 * @returns {string} 大写的文件扩展名(如 `TXT`) */ getExtension(name) { let reg = /(?!\.)\w+$/; if (reg.test(name)) { let match = name.match(reg); return match[0].toUpperCase(); } return ""; }, /** * 文件大小格式化 * @author hmjz100 * @description 自动转换单位到最合适的存储单位(如 `1.2MB`) * @param {number} value - 文件字节大小 * @returns {string} 可读格式的大小描述 */ sizeFormat(value = 0) { try { value = Number(value) } catch { } if (value === +value) { let unit = ["字节(B)", "千字节(KB)", "兆字节(MB)", "吉字节(GB)", "太字节(TB)", "拍字节(PB)", "艾字节(EB)", "泽字节(ZB)", "尧字节(YB)"]; if (value === 0) { return "0字节(B)"; } else { let index = Math.floor(Math.log(value) / Math.log(1024)); let size = value / Math.pow(1024, index); size = size.toFixed(1); return size + unit[index]; } } return ""; }, /** * 将剩余时间(秒)格式化为可读的时间字符串 * * @param {number} remainingTimeSeconds 剩余总秒数(支持小数) * @returns {string} 格式化后的时间字符串,包含以下可能格式: * - "X天 HH时:MM分:SS秒"(超过1天) * - "HH时:MM分:SS秒"(超过1小时) * - "MM分:SS秒"(超过1分钟) * - "SS秒"(1分钟内) * - "即将完成"(0秒时) * - "计算中..."(无效输入时) * * @example * formatRemainingTime(86400) // "1天 00时:00分:00秒" * formatRemainingTime(3661.5) // "01时:01分:01秒" * formatRemainingTime(0) // "即将完成" * formatRemainingTime(-5) // "计算中..." * formatRemainingTime(NaN) // "计算中..." */ rtimeFormat(remainingTimeSeconds) { 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) { return `${base.timeFormat(remainingHours)}时:${base.timeFormat(remainingMinutes)}分:${base.timeFormat(remainingSeconds)}秒`; } else if (remainingMinutes > 0) { return `${base.timeFormat(remainingMinutes)}分:${base.timeFormat(remainingSeconds)}秒`; } else if (remainingSeconds > 0) { return `${remainingSeconds}秒`; } else { return '即将完成'; } }, /** * 文件列表排序 * @author 油小猴 * @description 按中文拼音顺序对文件数组进行排序 * @param {Array} arr - 包含文件对象的数组 * @param {string} arr[].filename - 文件名属性(兼容 server_filename) */ sortByName(arr) { let handle = () => { return (a, b) => { let p1 = a.filename ? a.filename : a.server_filename; let p2 = b.filename ? b.filename : b.server_filename; return p1.localeCompare(p2, "zh-CN"); }; }; arr.sort(handle()); }, /** * 文件名安全处理 * @author 油小猴 * @description 替换非法字符为下划线 * @param {string} name - 原始文件名 * @returns {string} 修正后的安全文件名 */ fixFilename(name) { let replace = /[!?&|`"'*\/:<>\\]/g return name.replace(replace, '_'); }, /** * 获取 Cookie 值 * @author 油小猴 * @param {string} name - Cookie名称 * @returns {string} 对应的 Cookie 值 */ getCookie(name) { let cname = name + "="; let ca = document.cookie.split(';'); for (let i = 0; i < ca.length; i++) { let c = ca[i].trim(); if (c.indexOf(cname) == 0) return c.substring(cname.length, c.length); } return ""; }, /** * 生成 cURL 下载命令 * @author 油小猴 * @author hmjz100 * @description 根据终端类型生成对应 curl 命令,支持断点续传,自动处理文件名特殊字符 * @param {string} link - 下载链接 * @param {string} filename - 文件名 * @param {string} [header] - 自定义请求头参数(可选) * @returns {string} 编码后的 curl 命令字符串 */ convertLinkToCurl(link, filename, header) { let terminal = base.getValue('setting_curl_terminal'); filename = base.fixFilename(filename); return `${terminal !== 'wp' ? 'curl' : 'curl.exe'} -L -C - "${link}" -o "${filename}"${header ? (" " + header) : ""}`; }, /** * 生成 Aria2 下载命令 * @author 油小猴 * @author hmjz100 * @description 将链接转换为 Aria2 格式命令,自动处理文件名特殊字符 * @param {string} link - 下载链接 * @param {string} filename - 文件名 * @param {string} [header] - 自定义请求头参数(可选) * @returns {string} 编码后的 aria2c 命令字符串 */ convertLinkToAria2(link, filename, header) { filename = base.fixFilename(filename); return `aria2c "${link}" --out "${filename}"${header ? (" " + header) : ""}`; }, /** * 生成 BC 协议下载链接 * @author 油小猴 * @author hmjz100 * @description 将链接转换为 BC 协议格式,自动处理 URL 编码 * @param {string} link - 下载链接 * @param {string} filename - 文件名 * @param {string} [header] - 自定义请求头参数(可选) * @returns {string} 编码后的 BC 协议 URL */ convertLinkToBitComet(link, filename, header) { filename = base.fixFilename(filename); let bc = `AA/${encodeURIComponent(filename)}/?url=${encodeURIComponent(link)}${header ? ("&" + header) : ""}ZZ`; return `bc://http/${base.encodeBase(bc)}`; }, /** * 发送链接到 Aria2 下载器 * @author 油小猴 * @author hmjz100 * @description Aria2 下载必备 * @param {string} link - 下载链接 * @param {string} filename - 文件名 * @param {string} [header] - 自定义请求头参数(可选) * @returns {Promise<'success'|'fail'>} 发送态结果 */ async sendLinkToAria2(link, filename, header) { let list = base.getValue('setting_aria2_rpc'); let selected = list.find(i => i.default); let rpc = { domain: selected.domain, port: selected.port, path: selected.path, dir: selected.dir, token: selected.token }; let url = `${rpc.domain}:${rpc.port}${rpc.path}`; let data = { id: new Date().getTime(), jsonrpc: '2.0', method: 'aria2.addUri', params: [`token:${rpc.token}`, [link], { dir: rpc.dir, out: filename, header }] }; try { let res = await base.post(url, data, {}, ""); if (res.result) return 'success'; return 'fail'; } catch (e) { return 'fail'; } }, /** * 发送链接到比特彗星下载器 * @author hmjz100 * @description 比特彗星下载必备 * @param {string} link - 下载链接 * @param {string} filename - 文件名 * @param {string} [header] - 自定义请求头参数(可选) * @returns {Promise<'success'|'fail'>} 发送态结果 */ async sendLinkToBitcomet(link, filename, header) { let list = base.getValue('setting_bitcomet_rpc'); let selected = list.find(i => i.default); let rpc = { domain: selected.domain, port: selected.port, path: selected.path, dir: selected.dir, authName: selected.authName, authPass: selected.authPass, }; let url = `${rpc.domain}:${rpc.port}${rpc.path}`; let data = new URLSearchParams(); data.append('url', link); data.append('save_path', rpc.dir); data.append('file_name', filename); data.append('connection', 200); if (header && base.isType(header) === 'object') { for (const [key, value] of Object.entries(header)) { 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 { return "success"; } } catch (e) { return "success"; } }, /** * Blob 文件下载 * @author 油小猴 * @description 通过创建临时链接实现文件下载 * @param {Blob} blob - 要下载的 Blob 对象 * @param {string} filename - 下载时提示保存的文件名 */ blobDownload(blob, filename) { if (blob instanceof Blob) { let url = URL.createObjectURL(blob); let a = document.createElement('a'); a.href = url; a.download = filename; a.click(); URL.revokeObjectURL(url); } }, /** * 可跨域 xmlhttpRequest 请求 * @author hmjz100 * @description 封装 `GreaseMonkey-Compatible_xmlhttpRequest` 实现的跨域请求,与原始函数参数相同 * @param {Object} option - 请求配置对象 * @returns {XMLHttpRequest} 请求对象实例 */ xmlHttpRequest(option) { let request = (typeof GM_xmlhttpRequest !== "undefined") ? GM_xmlhttpRequest : GM.xmlHttpRequest; if (request && base.isType(request) === 'function') { return request(option); } }, /** * 发送 POST 请求 * @author 油小猴 * @author hmjz100 * @description 支持自动重试和数据格式化,内置错误处理,请求数据自动 `JSON.stringify` * @param {string} url - 请求地址 * @param {Object|string} data - 请求数据 * @param {Object} headers - 请求头配置 * @param {string} [type='json'] - 响应类型(支持 `json`, `blob` 等) * @returns {Promise} 包含响应数据的 `Promise` 对象 */ post(url, data, headers, type = "json") { let exampleData = data; if (this.isType(data) === 'object') { data = JSON.stringify(data); } else if (this.isType(data) === 'urlsearchparams') { exampleData = Object.fromEntries(data); } return new Promise((resolve, reject) => { let sendRequest = () => { base.xmlHttpRequest({ method: "POST", url, headers, data, responseType: type, onloadstart() { console.log('【LinkSwift】Post(start)\n请求地址:' + url + '\n请求头部:', headers, '\n请求数据:', exampleData); }, onload: function (res) { // 尝试格式化请求结果以方便调试 if (res.response) { try { res.decodedResponse = JSON.parse(res.response); } catch (e) { } try { res.decodedResponse = JSON.parse(base.decodeBase(res.response)); } catch (e) { } } if (res.responseText) { try { res.decodedResponseText = JSON.stringify(JSON.parse(res.responseText)); } catch (e) { } try { res.decodedResponseText = JSON.stringify(base.decodeBase(res.responseText)); } catch (e) { } } console.log('【LinkSwift】Post(load)\n请求地址:' + url, '\n请求结果:', res); type === 'blob' ? resolve(res) : resolve(res.response || res.responseText); }, onerror: async function (err) { console.error('【LinkSwift】Post(error)\n请求出现错误,可能是网络问题。', err); reject(err); }, }); }; sendRequest(); // 初始请求 }); }, /** * 发送 GET 请求 * @author 油小猴 * @author hmjz100 * @description 支持进度监控、文件下载和自动重试,可处理被下载工具捕获特殊逻辑 * @param {string} url - 请求地址 * @param {Object} headers - 请求头配置 * @param {string} [type='json'] - 响应类型 * @param {Object} [extra] - 附加参数(需包含 `filename` 和 `index` 属性) * @returns {Promise} 包含响应数据的 `Promise` 对象 */ get(url, headers, type, extra) { return new Promise((resolve, reject) => { let sendRequest = () => { let requestObj = base.xmlHttpRequest({ method: "GET", url, headers, responseType: type || 'json', onload: function (res) { if (res.status === 204) { console.log('【LinkSwift】Get(load)\n\x1B[31m该请求已被某个下载工具捕获。' + (res.statusText ? ("\n\x1B[0m工具提示:\x1B[31m" + res.statusText) : "") + '\x1B[0m\n请求地址:' + url + '\n请求头部:', headers, '\n请求结果:', res); requestObj.abort(); temp.idm[extra.index] = true; return; } if (type === 'blob') { console.log('【LinkSwift】Get(load) Blob\n请求地址:' + url, '\n请求结果:', res); res.status === 200 && base.blobDownload(res.response, extra.filename); resolve(res); } else { // 尝试格式化请求结果以方便调试 if (res.response) { try { res.decodedResponse = JSON.parse(res.response); } catch (e) { } try { res.decodedResponse = JSON.parse(base.decodeBase(res.response)); } catch (e) { } } if (res.responseText) { try { res.decodedResponseText = JSON.stringify(JSON.parse(res.responseText)); } catch (e) { } try { res.decodedResponseText = JSON.stringify(base.decodeBase(res.responseText)); } catch (e) { } } console.log('【LinkSwift】Get(load)\n请求地址:' + url + '\n请求头部:', headers, '\n请求结果:', res); resolve(res.response || res.responseText); } }, onprogress: function (res) { if (res.status === 204) { console.log('【LinkSwift】Get(progress)\n\x1B[31m该请求已被某个下载工具捕获。' + (res.statusText ? ("\n\x1B[0m工具提示:\x1B[31m" + res.statusText) : "") + '\x1B[0m\n请求地址:' + url + '\n请求头部:', headers, '\n请求结果:', res); requestObj.abort(); temp.idm[extra.index] = true; return; } if (extra && extra.filename && extra.index) { res.total > 0 ? temp.progress[extra.index] = (res.loaded * 100 / res.total).toFixed(2) : temp.progress[extra.index] = 0.00; } }, onloadstart(res) { if (res.status === 204) { console.log('【LinkSwift】Get(start)\n\x1B[31m该请求已被某个下载工具捕获。' + (res.statusText ? ("\n\x1B[0m工具提示:\x1B[31m" + res.statusText) : "") + '\x1B[0m\n请求地址:' + url + '\n请求头部:', headers, '\n请求结果:', res); requestObj.abort(); temp.idm[extra.index] = true; return; } console.log('【LinkSwift】Get(start)\n请求地址:' + url + '\n请求头部:', headers); if (extra && extra.filename && extra.index) temp.request[extra.index] = requestObj; }, onerror: async function (err) { console.error('【LinkSwift】Get(error)\n请求出现错误,可能是网络问题。', err); reject(err); }, }); }; sendRequest(); // 初始请求 }); }, /** * 获取最终重定向 URL(手动处理 30x 跳转) * @author 油小猴 * @author hmjz100 * @description 手动追踪 HTTP 30x 重定向,返回最终访问地址 * @param {string} url - 初始请求地址 * @param {Object} headers - 请求头配置 * @param {boolean} unLimit - 是否完整请求整个文件而不是仅请求请求头 * @returns {Promise} 最终 URL 地址 */ getFinalUrl(url, headers, unLimit) { return new Promise((resolve, reject) => { if (unLimit === true) { base.xmlHttpRequest({ method: "GET", url: url, headers: headers, onloadstart: () => { console.log('【LinkSwift】Get(start) FinalUrl\n请求地址:' + url + '\n请求头部:', headers); }, 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); } else { resolve(res.finalUrl); } }, onerror: async function (err) { console.error('【LinkSwift】Get(error) FinalUrl\n请求出现错误,可能是网络问题。', err); reject(err); } }); } else { base.xmlHttpRequest({ method: "HEAD", url: url, headers: headers, onloadstart: () => { console.log('【LinkSwift】Head(start) FinalUrl\n请求地址:' + url + '\n请求头部:', headers); }, 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); } else { resolve(res.finalUrl); } }, onerror: async function (err) { console.error('【LinkSwift】Head(error) FinalUrl\n请求出现错误,可能是网络问题。', err); reject(err); } }); } }); }, /** * RPC 服务测试 * @author hmjz100 * @description 验证 `JSON-RPC` 接口可用性 * @param {string} domain - 服务域名 * @param {string} port - 服务端口 * @param {string} path - RPC 路径 * @param {string} token - 认证令牌 * @returns {Promise<'success'|'fail'>} 连接状态结果 */ async testConnectToAria2(domain, port, path, token) { return new Promise((resolve, reject) => { let rpc = { domain, port, path, token }; let url = `${rpc.domain}:${rpc.port}${rpc.path}`; let rpcData = { id: new Date().getTime(), jsonrpc: '2.0', method: 'aria2.getVersion', params: [`token:${rpc.token}`] }; base.xmlHttpRequest({ method: "POST", url, headers: {}, data: JSON.stringify(rpcData), responseType: 'json', onloadstart() { console.log('【LinkSwift】Post(start) Aria2Test\n请求地址:' + url + '\n请求内容:', rpcData); }, onload: function (res) { console.log('【LinkSwift】Post(load) Aria2Test\n请求地址:' + url + '\n请求结果:', res); if (!res.response) return resolve("fail"); if (res.response?.error) { resolve("fail"); } else { resolve("success"); } }, onerror: function (err) { console.error('【LinkSwift】Post(error) Aria2Test\n请求失败', err); resolve("fail"); }, }); }); }, /** * 重置请求相关数据 * @author 油小猴 * @description 中止所有进行中的请求,清除进度记录和定时器 */ _resetAllData() { temp.progress = {}; $.each(temp.request, function (key) { (temp.request[key]).abort(); }); $.each(temp.ins, function (key) { clearInterval(temp.ins[key]); }); temp.idm = {}; temp.ins = {}; temp.request = {}; }, /** * 重置请求相关数据 * @author 油小猴 * @description 中止指定的进行中的请求,清除进度记录和定时器 */ _resetData(i) { temp.ins[i] && clearInterval(temp.ins[i]); temp.request[i] && temp.request[i].abort(); temp.progress[i] = 0; temp.idm[i] = false; }, /** * 将对象转换为 URL 编码字符串 * @author 油小猴 * @description 递归处理嵌套数组,自动进行 URI 编码 * @param {Object} obj - 待转换的键值对对象 * @returns {string} URL 编码格式字符串(如`key1=value1&key2=value2`) */ stringify(obj) { let str = ""; for (let key in obj) { if (obj.hasOwnProperty(key)) { let value = obj[key]; if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { str += encodeURIComponent(key) + '=' + encodeURIComponent(value[i]) + '&'; } } else { str += encodeURIComponent(key) + '=' + encodeURIComponent(value) + '&'; } } } return str.slice(0, -1); // 去掉末尾的 "&" }, /** * 动态注入样式表 * @author 油小猴 * @author hmjz100 * @description 支持 `样式标签` `外链CSS` 注入,提供精准的 DOM 定位和插入位置控制 * @param {string} id - 样式元素 ID * @param {'style'|'link'} tag - 标签类型(`style` 或 `link`) * @param {string} css - CSS 内容或外链 URL * @param {string} [element='.{mount}'] - 定位基准元素选择器 * @param {'before'|'after'|'prepend'|'append'} [position='append'] - 插入位置 */ addStyle(id, tag = 'style', css, element = `.${mount}`, position = "append") { base.waitForKeyElements(element, (element) => { let $styleDom = $(`#${id}`); let $style = $(`<${tag}>`, { rel: 'stylesheet', id: id }); tag === 'style' ? $style.html(css) : $style.attr('href', css); if ($styleDom.length) { $styleDom.replaceWith($style); return true; } if (position === "before") { element.before($style); } else if (position === "after") { element.after($style); } else if (position === "prepend") { element.prepend($style); } else { element.append($style); } return true; }, true); }, /** * 十六进制颜色转 RGBA * @author hmjz100 * @description 支持 4 位和 8 位十六进制格式,自动解析透明度通道 * @param {string} hex - 十六进制颜色值(如 `#09f` 或 `#0099ffaa` ) * @returns {string} RGBA 格式字符串(如 `15, 170, 255, 0.67`) */ hexToRgba(hex) { // 去掉 # 号 hex = hex.replace(/^#/, ""); // 如果是四位十六进制颜色值,转换为八位 if (hex.length === 4) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]; } // 解析 RGB 分量 let r = parseInt(hex.substring(0, 2), 16); let g = parseInt(hex.substring(2, 4), 16); let b = parseInt(hex.substring(4, 6), 16); let a = ""; // 如果是八位十六进制颜色值,解析 alpha 通道 if (hex.length === 8) { a = parseInt(hex.substring(6, 8), 16) / 255; // 将 alpha 值转换为 0 到 1 之间的小数 a = ',' + a } // 返回 rgba 格式字符串 return r + ', ' + g + ', ' + b + a; }, /** * RGBA 颜色转十六进制 * @author hmjz100 * @description 支持透明度转换,自动补全缩写格式 * @param {string} rgba - RGBA 格式颜色值(如 `rgba(15,170,255,0.67)`) * @returns {string} 十六进制颜色值(如 `#09aaffaa`) */ 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 * @description 支持全局样式替换和资源路径修正,处理颜色渐变过渡效果 * @param {string} cssText - 原始 CSS 内容 * @param {string} baseURI - 资源基础路径 * @param {'default'|'other'} type - 替换模式(默认模式包含过渡效果) * @param {Array<[string, string]>} colorMap - 颜色映射表(旧颜色 → 新颜色) * @returns {string} 处理后的 CSS 内容 */ replaceColors(cssText, baseURI, type, colorMap) { if (!cssText) return ""; let 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'] // 处理默认颜色列表 colorList.forEach(function (oldColor) { 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); }); }); 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); }); } else { // 普通字符串替换 uniqueVariants.forEach(variant => { cssText = cssText.replace(new RegExp(variant, 'gi'), newColor); }); } }); } if (baseURI) { // 替换相对路径资源为绝对路径 cssText = cssText.replace(/url$\s*(['"]?)([^'"]*?)\1\s*$/ig, (match, quote, url) => { if (url && !/^(data:|https?:|\/\/)/i.test(url)) { try { let absoluteURL = new URL(url, baseURI).href; return `url(${absoluteURL})`; } catch (e) { return match; } } return match; }); } return cssText; }, /** * 全局主题颜色设置 * @author hmjz100 * @description 自动遍历并替换 `页面所有样式表` `SVG 元素` 的颜色值 * @param {Array<[string, string]>} colorMap - 颜色映射表 * @param {'default'|'other'} type - 替换模式 */ setColors(colorMap, type) { base.waitForKeyElements(`[id^="${mount}-ColorUI-"]`, function (tag) { if (tag.html() === base.replaceColors(tag.text(), "", type, colorMap)) return; let cssText = base.replaceColors(tag.text(), "", type, colorMap); base.addStyle(tag.attr("id"), 'style', cssText, tag[0]); return true; }, true) base.waitForKeyElements(`[data-pl-viewed]`, function (tag) { let originalStyle = tag.attr("style"); if (!originalStyle) return; let newStyle = base.replaceColors(originalStyle, "", type, colorMap); if (newStyle !== originalStyle) { tag.attr("style", newStyle); } return true; }, true); let count = 0; if (!temp.colored) { base.waitForKeyElements('link[rel="stylesheet"]', function (tag) { if (!tag.parent().length || !tag.attr('href')) return; let href = tag.attr('href'); try { href = new URL(href, location.href).href; } catch (e) { return; } fetch(href) .then(response => response.text()) .then(responseText => { let id = `${mount}-ColorUI-` + href.replace(/[^\w]/g, "_"); let cssText = base.replaceColors(responseText, href, type, colorMap); if (responseText === base.replaceColors(responseText, "", type, colorMap)) return; base.addStyle(id, 'style', cssText, tag[0], "after"); }) }, true); base.waitForKeyElements(`style:not([id^="${mount}-"],[id^="swal-pub"],[class^="darkreader"])`, function (tag) { let id = tag.attr("id"); let text = tag.html() if (tag.data("styles") === text) return; tag.data("styles", text); // 替换颜色并添加样式 let cssText = base.replaceColors(text, "", type, colorMap); if (text === cssText) return; id = id ? id : `${mount}-ColorUI-${count++}` base.addStyle(id, 'style', cssText, tag[0], "after"); }, true) base.waitForKeyElements('svg', function (element) { element.find('*').each((index, element) => { let fill = $(element).attr('fill'); let stroke = $(element).attr('stroke'); if (fill) { let newFill = base.replaceColors(fill, "", type, colorMap); if (newFill !== fill) { $(element).attr('fill', newFill); } } if (stroke) { let newStroke = base.replaceColors(stroke, "", type, colorMap); if (newStroke !== stroke) { $(element).attr('stroke', newStroke); } } }); }, true); base.waitForKeyElements(`[style]:not([id^="${mount}-"],[class*="listener-"],[data-pl-viewed])`, function (element) { let originalStyle = element.attr("style"); if (!originalStyle) return; let newStyle = base.replaceColors(originalStyle, "", type, colorMap); if (newStyle !== originalStyle) { element.attr("style", newStyle); element.attr("data-pl-viewed", "true"); } }, true); temp.colored = true; } }, /** * 延时执行 * @author 油小猴 * @param {number} time - 等待时间(毫秒) * @returns {Promise} 延时完成的 `Promise` */ sleep(time) { return new Promise(resolve => setTimeout(resolve, time)); }, /** * 判断版本号新旧 * @author hmjz100 * @description 该函数将版本号按 `.` 分割为数字数组,逐段比较大小。 * 若某段 a 的数字大于 b,则 a 更新; * 若所有段均相等,则版本相等(返回 false)。 * @param {string} a - 待比较的版本号 * @param {string} b - 基准版本号(如 "1.0.9.7") * @returns {boolean} - 若 a 比 b 更新,返回 true;否则返回 false */ isNewerVersion(a, b) { let partsA = a.split('.').map(Number); let partsB = b.split('.').map(Number); let maxLength = Math.max(partsA.length, partsB.length); 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 油小猴 * @param {string} version - 完整版本号(如 `1.2.3`) * @returns {string|null} 主版本号(如 `1`)或 `null`(格式错误时) */ getMajorVersion(version) { let [major] = (version || "").split('.'); return /^\d+$/.test(major) ? major : null; }, /** * 查找 React 组件实例 * @author 油小猴 * @description 支持 Fiber 架构遍历,可指定向上查找层级 * @param {HTMLElement} dom - 起始 DOM 元素 * @param {number} [traverseUp=0] - 向上遍历层级 * @returns {Object|null} React 组件实例或 `null` */ findReact(dom, traverseUp = 0) { let key = Object.keys(dom).find(key => { return key.startsWith("__reactFiber$") || key.startsWith("__reactInternalInstance$"); }); let domFiber = dom[key]; if (domFiber == null) return null; if (domFiber._currentElement) { let compFiber = domFiber._currentElement._owner; for (let i = 0; i < traverseUp; i++) { compFiber = compFiber._currentElement._owner; } return compFiber._instance; } let GetCompFiber = fiber => { let parentFiber = fiber.return; while (base.isType(parentFiber.type) == "string") { parentFiber = parentFiber.return; } return parentFiber; }; let compFiber = GetCompFiber(domFiber); for (let i = 0; i < traverseUp; i++) { compFiber = GetCompFiber(compFiber); } return compFiber.stateNode || compFiber; }, /** * 迁移旧版本配置 * @author hmjz100 * @description 将旧版配置项目迁移到新版配置 */ initConfigMigration(latest) { try { if (latest === 1) { let mapping = { 'setting_rpc_domain': ['setting_aria2_rpc', 0, 'domain'], 'setting_rpc_port': ['setting_aria2_rpc', 0, 'port'], 'setting_rpc_path': ['setting_aria2_rpc', 0, 'path'], 'setting_rpc_token': ['setting_aria2_rpc', 0, 'token'], 'setting_rpc_dir': ['setting_aria2_rpc', 0, 'dir'], 'setting_terminal_type': ['setting_curl_terminal'], 'setting_init_code': ['setting_init', 'code'], 'setting_init_license': ['setting_init', 'license'], 'setting_init_version': ['setting_init', 'version'], 'setting_theme_color': ['setting_ui_theme', 'color'], 'setting_theme_baidu': ['setting_ui_theme', 'custom', '$baidu'], 'setting_theme_ali': ['setting_ui_theme', 'custom', '$aliyun'], 'setting_theme_mcloud': ['setting_ui_theme', 'custom', '$mcloud'], 'setting_theme_tcloud': ['setting_ui_theme', 'custom', '$tcloud'], 'setting_theme_xunlei': ['setting_ui_theme', 'custom', '$xunlei'], 'setting_theme_quark': ['setting_ui_theme', 'custom', '$quark'], 'setting_theme_uc': ['setting_ui_theme', 'custom', '$uc'], 'setting_theme_123': ['setting_ui_theme', 'custom', '$123pan'] }; // 旧版配置执行迁移 for (let oldKey in mapping) { let val = base.getValue(oldKey); if (val === undefined || val === null) continue; val = (val === 'no' ? false : val === 'yes' ? true : val); let path = mapping[oldKey]; if (path.length === 1) { base.setValue(path[0], val); } else { let [root, ...keys] = path; let obj = base.getValue(root); if (obj === undefined || obj === null) { let firstKeyType = typeof keys[0]; let isIndex = firstKeyType === 'number' || (firstKeyType === 'string' && /^\d+$/.test(keys[0])); obj = isIndex ? [] : {}; } let ref = obj; for (let i = 0; i < keys.length - 1; i++) { let key = keys[i]; if (!ref[key]) { let nextKey = keys[i + 1]; let hasNextIndex = nextKey !== undefined && (base.isType(nextKey === 'number' || (typeof nextKey) === 'string' && /^\d+$/.test(nextKey))); ref[key] = hasNextIndex ? [] : {}; } ref = ref[key]; } ref[keys.slice(-1)[0]] = val; base.setValue(root, obj); } base.delValue(oldKey); } } } catch (e) { console.error("【LinkSwift】迁移旧版本配置到新配置时出错", e); } }, /** * 初始化默认配置 * @author 油小猴 * @author hmjz100 * @description 创建基础配置、主题设置等存储项(仅当不存在时) */ initDefaultConfig() { if (base.getValue('setting_config_version') !== '1') base.initConfigMigration(1); // 设置新结构的默认值(仅当未设置时) let defaults = [ { name: 'setting_aria2_rpc', value: [ { domain: 'http://localhost', port: '16800', path: '/jsonrpc', token: "", dir: 'D:\\Downloads\\', default: true } ] }, { name: 'setting_bitcomet_rpc', value: [ { domain: 'http://localhost', port: '8080', path: '/panel/task_add_httpftp_result', authName: "", authPass: "", dir: 'D:\\Downloads\\', default: true } ] }, { name: 'setting_curl_terminal', value: 'wc' }, { name: 'setting_init', value: { code: "", license: "", version: "" } }, { name: 'setting_ui_theme', value: { color: '#574AB8', custom: { $baidu: false, $aliyun: false, $mcloud: false, $tcloud: false, $xunlei: false, $quark: false, $uc: false, $123pan: false } } }, { name: 'setting_config_version', value: '1' } ]; function cloneDeep(item) { return JSON.parse(JSON.stringify(item)); } function fillMissingFields(target, source) { // 如果 target 不存在,直接返回 source 的深拷贝 if (target === null || target === undefined) { return cloneDeep(source); } // 如果类型不同,直接替换为 source if (typeof source !== typeof target) { return cloneDeep(source); } // 如果 source 是对象 if (base.isType(source) === 'object' && !Array.isArray(source)) { if (typeof target !== 'object' || Array.isArray(target)) { return cloneDeep(source); } let result = { ...target }; for (let key in source) { if (!source.hasOwnProperty(key)) continue; // 跳过 default 的自动合并 if (key === 'default') continue; result[key] = fillMissingFields(target[key], source[key]); } return result; } // 如果 source 是数组 if (Array.isArray(source)) { if (!Array.isArray(target)) { return cloneDeep(source); } let result = [...target]; if (source.length > 0 && base.isType(source[0]) === 'object' && source[0] !== null) { let template = source[0]; // 填充字段 for (let i = 0; i < result.length; i++) { if (base.isType(result[i]) === 'object' && result[i] !== null) { result[i] = fillMissingFields(result[i], template); } else { result[i] = cloneDeep(template); } } // 找到第一个 default:true let firstDefaultIndex = -1; for (let i = 0; i < result.length; i++) { let item = result[i]; if (base.isType(item === 'object' && item !== null && item.default) === true) { firstDefaultIndex = i; break; } } // 删除所有其他项的 default for (let i = 0; i < result.length; i++) { let item = result[i]; if (base.isType(item) === 'object' && item !== null) { if (i !== firstDefaultIndex && 'default' in item) { let { default: _, ...rest } = item; result[i] = rest; } } } // 如果没有任何 default:true,则在第一个元素中添加 if (firstDefaultIndex === -1 && result.length > 0) { result[0] = { ...result[0], default: true }; } } return result; } // 基本类型,保留原始值 return target; } defaults.forEach(({ name, value }) => { let current = base.getValue(name); if ( current === null || current === undefined || (Array.isArray(current) && current.length === 0) ) { base.setValue(name, cloneDeep(value)); } else { base.setValue(name, fillMissingFields(current, value)); } }); }, /** * 显示设置界面 * @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 使用教程} */ showSetting() { let setting = $(`
带星号的设置项目将在网页刷新后生效
cURL使用教程,适用于 cURL 下载👆
`); Swal.fire({ ...temp.swalDefault, title: '(。•ᴗ•。) 助手设置', html: setting.html(), icon: 'info', iconHtml: '⚙︎', allowOutsideClick: false, showCloseButton: true, showConfirmButton: false, footer: `
LinkSwifthmjz100 制作
${config.base.dom.footer}
`, }); }, /** * 显示 Aria2 服务设置界面 * @author hmjz100 * @description 包含 RPC 配置的交互界面 * @see{@link https://www.youxiaohou.com/zh-cn/motrix.html#使用指南 RPC 配置说明} */ showAria2Setting(event) { let AriaList = base.getValue('setting_aria2_rpc'); let AriaOptions = AriaList.map((item, index) => { return ``; }).join(""); let AriaSelected = AriaList.find(i => i.default); let Aria2Setting = $(`
RPC配置说明,适用于 Aria2 推送下载
`); Swal.fire({ ...temp.swalDefault, title: 'Aria2 服务设置', html: Aria2Setting.html(), icon: 'info', iconHtml: '⚙︎', allowOutsideClick: false, showCloseButton: true, showConfirmButton: false, footer: `
LinkSwifthmjz100 制作
${config.base.dom.footer}
`, didOpen: () => { if (AriaSelected) { $('.listener-rpc-input').each(function () { let type = $(this).data('type').split(".")[1]; $(this).val(AriaSelected[type] || ""); }); } else { AriaList[0].default = true; base.setValue('setting_aria2_rpc', AriaList); AriaSelected = AriaList[0]; } }, willClose: () => { if ($(event.currentTarget).data("back-to-setting")) base.showSetting(); }, }); }, /** * 显示比特彗星服务设置界面 * @author hmjz100 * @description 包含 RPC 配置的交互界面 */ showBitcometSetting(event) { let BCList = base.getValue('setting_bitcomet_rpc'); let BCOptions = BCList.map((item, index) => { return ``; }).join(""); let BCSelected = BCList.find(i => i.default); let Bitcomet2Setting = $(`
适用于比特彗星推送下载
`); Swal.fire({ ...temp.swalDefault, title: '比特彗星服务设置', html: Bitcomet2Setting.html(), icon: 'info', iconHtml: '⚙︎', allowOutsideClick: false, showCloseButton: true, showConfirmButton: false, footer: `
LinkSwifthmjz100 制作
${config.base.dom.footer}
`, didOpen: () => { if (BCSelected) { $('.listener-rpc-input').each(function () { let type = $(this).data('type').split(".")[1]; $(this).val(BCSelected[type] || ""); }); } else { BCSelected[0].default = true; base.setValue('setting_bitcomet_rpc', BCSelected); BCSelected = BCList[0]; } }, willClose: () => { if ($(event.currentTarget).data("back-to-setting")) base.showSetting(); }, }); }, /** * 显示美化设置界面 * @author hmjz100 * @description 提供主题颜色选择器和各网盘界面美化配置 * @fires .listener-color - 主题色选择事件 * @fires .listener-theme - 网盘主题配置变更事件 */ showBeautify() { function changeColor() { let colorList = [ { color: '#09AAFF', name: '度盘|经典蓝' }, { color: '#cc3235', name: '度盘|平安红' }, { color: '#518c17', name: '度盘|盎然绿' }, { color: '#ed944b', name: '度盘|周年橙' }, { color: '#f969a5', name: '度盘|幸会粉' }, { color: '#bca280', name: '度盘|午后棕' }, { color: '#b673ab', name: '度盘|物语紫' }, { color: '#574AB8', name: '度盘|星空紫' }, { color: '#1d2327', name: 'OpenAI|默认黑' }, { color: '#18a497', name: 'OpenAI|默认青' }, { color: '#637dff', name: '度里叁|霞光紫' }, { color: '#0d53ff', name: '夸克|极简蓝' }, { color: '#3181f9', name: '移动|彩云蓝' }, { color: '#f8d800', name: '果核|柠檬黄' }, { color: '#0396ff', name: '果核|默认蓝' }, { color: '#32ccbc', name: '果核|碧波绿' }, { color: '#f6416c', name: '果核|玫瑰红' }, { color: '#2271b1', name: '文派|默认蓝' }, { color: '#59524c', name: '文派|咖啡灰' }, { color: '#ff679a', name: '哔哩|少女粉' }, { color: '#f44236', name: '哔哩|高能红' }, { color: '#fec107', name: '哔哩|咸蛋黄' }, { color: '#8bc24a', name: '哔哩|早苗绿' }, { color: '#2594ed', name: '哔哩|宝石蓝' }, { color: '#9c28b1', name: '哔哩|罗兰紫' } ]; temp.color = base.getValue('setting_ui_theme').color; return colorList.map(item => { return `
${item.name.split('|').map(part => `
${part}
`).join("")} ${item.color === temp.color ? '
' : ""}
`; }).join("") } function changeTheme() { let themeList = [ { name: '百度网盘', key: '$baidu' }, { name: '阿里云盘', key: '$aliyun' }, { name: '移动云盘', key: '$mcloud' }, { name: '天翼云盘', key: '$tcloud' }, { name: '迅雷云盘', key: '$xunlei' }, { name: '夸克网盘', key: '$quark' }, { name: 'UC 网盘', key: '$uc' }, { name: '123 云盘', key: '$123pan' } ]; return themeList.map(item => { return ``; }).join(""); } let beautify = $(`
带星号的美化项目将在网页刷新后生效
替换界面配色为主题颜色*
${changeTheme()}
`) Swal.fire({ ...temp.swalDefault, title: '(✿ᴗ‿ᴗ) 助手美化', html: beautify.html(), icon: 'success', iconHtml: '🍃︎', allowOutsideClick: false, showCloseButton: true, showConfirmButton: false, footer: `
LinkSwifthmjz100 制作
${config.base.dom.footer}
`, }); }, /** * 显示调试信息面板 * @description 展示脚本运行时环境、版本信息及依赖状态 * @author hmjz100 * @property{string} manageHandler - 外部管理器名称 * @property{string} manageVersion - 外部管理器版本 */ showDebug() { let debugInfo = ""; debugInfo += `以下内容均为脚本自检信息
本页面仅作为调试使用`; debugInfo += ``; debugInfo += ``; debugInfo += ``; debugInfo += ``; debugInfo += ``; debugInfo += ``; debugInfo += ``; debugInfo = '
' + debugInfo + '
'; Swal.fire({ ...temp.swalDefault, icon: 'info', title: '调试信息', html: debugInfo, allowOutsideClick: false, showCloseButton: true, }); }, /** * 显示版本更新日志 * @author hmjz100 * @description 按时间倒序展示所有历史版本更新内容 */ showUpdate() { Swal.fire({ ...temp.swalDefault, icon: 'info', title: '更新日志', html: `
风雨送春归,飞雪迎春到。已是悬崖百丈冰,犹有花枝俏。
俏也不争春,只把春来报。待到山花烂漫时,她在丛中笑。
(ノ◕ヮ◕)ノ 遇到 Bug 要记得去 Github 议题 向我报告哦~
V1.1.1
1、配置文件格式更新,支持添加、删除、切换多个服务配置
2、支持比特彗星推送下载,原 RPC 已并入 Aria2 下载
3、界面增加 Font Awesome 图标!更好看啦;
4、优化脚本代码、界面,运行更轻快;
5、修复上个版本遗存的问题。

V1.1.0.1
1、修复查看 RPC 下载任务的 Bug。
V1.1.0
1、支持 UC 网盘、123 云盘;
2、改进了网盘主题的注入方式;
3、聚合并重构了部分重复函数,对整体脚本逻辑进行了梳理和精简;
4、将脚本执行阶段从 document-body 适配为 document-start。

V1.0.9.7
1、修复移动云盘下载错误;
2、优化代码,更好的错误识别;
3、去除了游小猴云服务。
V1.0.9.6
1、支持在百度网盘中选择文件夹下载;
2、优化部分提示。
V1.0.9.5
1、修复因代码逻辑错误而无法获取链接的 Bug。
V1.0.9.4
1、修复因百度网盘 AccessToken 过期导致无法获取链接的 Bug。
V1.0.9.3
1、若网盘不支持在分享中下载,将仅显示保存网盘按钮;
2、优化下载界面,支持选择 Iframe 或 Blob 的方式来下载文件,增加按钮的提示文本;
3、优化 CSS 样式,统一了 SweetAlert2 按钮样式,同时适配了 Dark Reader 插件,界面更协调;
4、支持修改油小猴网站主题色;
5、原有主题相关设置现已移动至助手美化页面中。
V1.0.9.2
1、修复使用API 下载时有可能会导致IDM无限弹窗的Bug。
V1.0.9.1
1、修复在百度网盘旧版下脚本无法删除元素的Bug。
V1.0.9
1、跟进官方V6.2.7,修复因无法进行百度授权而导致获取直链报错 9019 的 Bug。

V1.0.8.9
1、跟进官方V6.2.3,优化保存到网盘提示,修复阿里云盘、移动云盘失效的问题;
2、优化修改网盘主题的代码,减少对页面的破坏。
V1.0.8.8
1、修复下载菜单字体过小的Bug。
V1.0.8.7
1、修复在阿里云盘分享页面下点击“未点亮”按钮时没有任何反应的Bug;
2、更新并优化网盘界面精简规则;
3、支持更换 百度网盘、阿里云盘、迅雷云盘、夸克网盘、移动云盘 界面的主题颜色。
V1.0.8.6
1、新增移动云盘会员中心页面,可在网盘中点击“会员中心”按钮查看(但无法使用第三方支付)。
V1.0.8.5
1、跟进官方V6.1.6,修复迅雷网盘分享页面无法选中文件,修复移动云盘无法判断页面。
V1.0.8.4
1、修复因重复绑定按钮而导致命令重复执行的Bug;
2、优化调试信息界面排版;
3、移除对百度网盘手机网页版的支持。
V1.0.8.3
1、适配阿里云盘新域名alipan.com。
V1.0.8.2
1、更换新图标。
V1.0.8.1
1、修复因重复绑定按钮而导致 RPC 下载会发送多条下载请求的Bug;
2、选择不使用油小猴服务器时,“用ghproxy连接Github仓库”更换为“用jsdelivr连接Github仓库”;
3、跟进官方V6.1.4版本,修复移动网盘无法获取链接,支持阿里云盘新域名alipan.com。

V1.0.8
1、修复迅雷网盘无法勾选文件。
V1.0.7.9
1、更新精简网盘元素匹配规则,防止因通知横条而导致不能点到“API 下载”以下的按钮。
V1.0.7.8
1、跟进官方V6.1.2,加入V2接口。
2、修复百度网盘下载时因为获取不到accessToken而一直转圈。
V1.0.7.7
1、修复百度网盘的按钮会因为主题不同而被改变颜色的Bug;
2、更新夸克网盘按钮与界面。
V1.0.7.6
1、修复“注入”功能;
2、黑暗模式支持随设置热切换。
V1.0.7.5
1、修复阿里云盘下载逻辑;
2、精简代码;
3、支持深色模式;
4、修改部分提示文本;
5、修改部分CSS;
6、设置可测试RPC连接。
V1.0.7.4
1、优化下载逻辑;
2、修复阿里云盘无法使用API 下载。
V1.0.7.3
1、如果出现网络请求错误时支持自动重新请求;
2、可选择是否使用油小猴服务器。
V1.0.7.2
1、修复使用 RPC 下载时会重复发送链接的Bug。
V1.0.7.1
[实验功能,不影响正常使用]支持百度网盘手机网页版,勾选文件后可在顶栏找到“下载助手”按钮。
V1.0.7
1、重构夸克网盘、阿里云盘按钮。

V1.0.6.9
1、下载窗口加入关闭按钮。
V1.0.6.8
1、修复夸克网盘按钮错位。
V1.0.6.7
1、将百度网盘界面修改为主题色,可在设置选择是否修改;
2、增加主题色名称,更改部分内容颜色;
3、移动云盘API 下载支持批量复制;
4、优化控制台输出结果;
5、百度网盘API 下载不使用IDM时可以显示剩余时间;
6、“取消点亮按钮”按钮的位置现已移动到设置页面。
7、homo特有的彩蛋又回来力(喜)。
V1.0.6.6
1、修复暗号错误。
V1.0.6.5
1、修复即使输入正确暗号也不能成功点亮按钮的服务器错误。
V1.0.6.4
1、跟进官方V6.1.1版本,修复阿里云盘获取下载链接时的问题。
V1.0.6.3
1、照顾小屏幕用户,将始终显示复制全部链接的按钮;
2、增加取消下载时的动画。
V1.0.6.2
1、修复部分界面错位,实现CSS内置;
2、百度网盘界面将变得更加简洁。
V1.0.6.1
1、新增百度云盘API 下载支持复制链接;
2、为了照顾手机浏览器用户,增大项目之间间隙,新增隐藏IDM提示选项,可在助手设置中启用;
3、修改CSS,界面会出现更多的主题色;
4、支持在游小猴官网查看暗号;
5、修复部分语法错误。
V1.0.6
1、修复了打开阿里云盘分享连接时因下载移动端广告导致只能点击 API 下载;
2、跟进官方6.0.4版本,修复夸克网盘获取下载链接失效、支持移动云盘。

V1.0.5.5
1、感谢Night-stars-1的帮助,修复因为原作者服务器导致的初始化暗号识别错误;
2、修改一些文本以及提供给服务器的信息。
V1.0.5.4
1、小修小改css,让主题色出现在更多地方;
2、修改下载链接获取失败的提示;
3、增加更多的主题色,可在助手设置查看;
4、homo彩蛋被删去力(悲)。
V1.0.5.3
1、修啦修啦,阿里云盘可以摸到下载菜单了。
V1.0.5.2
1、增加脚本信息菜单(没有用);
2、优化阿里云盘显示svg图片;
3、修改弹窗按钮颜色。
V1.0.5.1
1、修复在切换按钮主题后夸克网盘不能正常显示按钮。
V1.0.5
1、跟进官方V5.0.4版本;
2、小改动,照着官方版本更正文件名称检测;
3、保留彩蛋,但必须舍弃官方暗号。
V1.0.4
大改!
1、修复了原作者留下的夸克网盘切换文件夹就多一个“下载助手”按钮的大BUG;
2、终于来了,在下载菜单增加“助手设置”“更新日志”按钮;
【再也不用点进油猴管理再进设置了(保留油猴管理内设置)】
3、修改阿里云盘和夸克网盘下载助手按钮样式;
4、增加“取消点亮按钮”油猴菜单;
5、修改部分css,使其与选择的主题更贴切。

V1.0.3
1、增加一个小彩蛋; 提示:
homo(需在未点亮按钮状态触发)
【需要重新恢复按钮为未点亮状态请进入 已安装脚本->编辑->开发者->重置到出厂->确定】
2、修改/增加默认主题色。
V1.0.2
1、修改并加宽界面,调整部分css,使Sweetalert2界面更美观,更与原版相近;
2、修改部分提示文字,使文字更容易复制。
V1.0.1
1、去除更新提示;
2、更新Sweetalert2至11版本;
3、部分CDN节点更换为jsdelivr。
V1.0.0
1、增加“注入”功能(bushi);
2、去除广告。
`, allowOutsideClick: false, showCloseButton: true, confirmButtonText: ' 我已阅', }); }, /** * 创建浮动提示框 * @description 监听元素悬停事件,动态显示带文件大小的提示框 * @author 油小猴 * @author hmjz100 * @fires .listener-tip - 鼠标移动事件触发提示框定位 * @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 title = target.data("title"); if (title) { tip += `${title}`; } else { let name = target.find(".name").text(); let size = target.find(".size").text(); tip += `${name}`; if (size !== undefined) { tip += `${size}`; } } tooltip.html(tip).css({ left: x + 10 + 'px', top: y + 20 + 'px', display: 'flex' }); }; // 鼠标/触摸移动时更新位置 temp.doc.on('mousemove touchmove', '.listener-tip', function (e) { const isTouch = e.type.startsWith('touch'); const pageX = isTouch ? e.originalEvent.touches[0].pageX : e.pageX; const pageY = isTouch ? e.originalEvent.touches[0].pageY : e.pageY; showTooltip($(e.currentTarget), pageX, pageY); }); // 触摸开始时立即显示 temp.doc.on('touchstart', '.listener-tip', function (e) { // 阻止滚动避免干扰 e.preventDefault(); const touch = e.originalEvent.touches[0]; showTooltip($(e.currentTarget), touch.pageX, touch.pageY); }); // 统一隐藏逻辑 temp.doc.on('mouseleave touchend touchcancel', '.listener-tip, .pl-tooltip', function (e) { tooltip.css({ display: '' }); }); // 增强跨事件类型检测 temp.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: '' }); } }); }, /** * 创建加载状态弹窗 * @author 油小猴 * @description 生成包含旋转动画的加载容器 */ createLoading() { return $('
'); }, /** * 创建用于下载的隐藏 iframe * @author 油小猴 * @description 该方法会创建一个隐藏的 iframe 元素,并将其插入到指定的挂载点中,用于后续的下载操作。 * iframe 的 src 设置为 "javascript:;" 以避免加载额外资源,提升性能。 */ createDownloadIframe() { let iframe = $(''); base.waitForKeyElements(`.${mount}`, (element) => { element.append(iframe); }, true) }, /** * 创建用于下载页面的 HTML * @author 油小猴 * @author hmjz100 * @description 详见代码 */ generateDom(list, config) { if (!list) { return message.error('提示:
获取下载链接失败,刷新网页后再试试吧~'); } let { isFolder, getFileName, getFileSize, getFileLink, getFileMirror, convert = {}, tooltip = {} } = config; let content = $(`
`); let allLink = []; list.forEach((v, i) => { if (isFolder(v)) return; let filename = getFileName(v); let size = getFileSize(v); let dlink = getFileLink(v); let mirror = base.isType(getFileMirror) !== "undefined" ? getFileMirror(getFileLink(v)) : undefined; if (!dlink || !dlink.includes("http")) { content.find(".pl-main").append(`
${filename}
${base.sizeFormat(size)}
获取下载链接失败,刷新网页后再试试吧~
`) } else { if (temp.mode === "api") { allLink.push(dlink); content.find(".pl-main").append(`
${filename}
${base.sizeFormat(size)}
`); } if (temp.mode === "curl") { let finalink = base.convertLinkToCurl(dlink, filename, convert?.curl); allLink.push(finalink); content.find(".pl-main").append(`
${filename}
${base.sizeFormat(size)}
${finalink}
复制 ${filename} 下载命令行
`); } if (temp.mode === "aria2") { let finalink = base.convertLinkToAria2(dlink, filename, convert?.aria2); allLink.push(finalink); content.find(".pl-main").append(`
${filename}
${base.sizeFormat(size)}
`); } if (temp.mode === "bitcomet") { let finalink = base.convertLinkToBitComet(dlink, filename, convert?.bitcomet); allLink.push(finalink); content.find(".pl-main").append(`
${filename}
${base.sizeFormat(size)}
使用 BC 链接下载 ${mirror ? `
`); } } }); allLink = (allLink ? allLink.join("\r\n") : "") if (temp.mode === "api" && list.length >= 2) { content.find(".pl-extra").append(` `); } else if (temp.mode === "curl") { content.find(".pl-extra").append(``); if (list.length >= 2) content.find(".pl-extra").append(``); } else if (temp.mode === 'aria2') { let rpc = base.getValue("setting_aria2_rpc").find(i => i.default); content.find(".pl-extra").append(``); content.find(".pl-extra").append(``); if (list.length >= 2) content.find(".pl-extra").append(``); if (list.length >= 2) content.find(".pl-extra").append(``); } else if (temp.mode === "bitcomet") { if (list.length >= 2) content.find(".pl-extra").append(``); let rpc = base.getValue("setting_bitcomet_rpc").find(i => i.default); content.find(".pl-extra").append(``); if (list.length >= 2) content.find(".pl-extra").append(``); } function updateTooltip($element, value) { if (!value) return; $element.addClass("listener-tip"); if (value.startsWith('+')) { // 追加模式:去掉开头的 '+',然后拼接到现有 data-title const newValue = value.substring(1); const existingTitle = $element.attr("data-title") || ""; $element.attr("data-title", existingTitle + newValue); } else { // 替换模式 $element.attr("data-title", value); } } if (tooltip?.enhance) updateTooltip(content.find(".enhance"), tooltip.enhance); if (tooltip?.normal) updateTooltip(content.find(".normal"), tooltip.normal); if (tooltip?.copy) updateTooltip(content.find(".copy"), tooltip.copy); if (tooltip?.filename) updateTooltip(content.find(".filename"), tooltip.filename); let html = content.html(); content.remove(); return html; }, /** * 获取镜像列表 * @author 油小猴 * @description 根据原始链接和镜像域名列表生成多个镜像链接,支持多线程下载。 * 每个镜像地址会根据 thread 参数生成多个重复链接(通过添加 `&` 符号区分)。 * @param {string} link - 原始下载链接 * @param {Array} mirror - 镜像域名数组 * @param {number} [thread=2] - 每个镜像生成的线程数(链接重复次数),默认为 2 * @returns {string} 所有镜像链接组成的字符串,每行一个链接 * * @example * getMirrorList("https://example.com/file.zip", ["mirror1.com", "mirror2.com"], 2) * // 返回: * // https://mirror1.com/file.zip * // https://mirror1.com/file.zip& * // https://mirror2.com/file.zip * // https://mirror2.com/file.zip& */ getMirrorList(link, mirror, thread = 2) { try { let host = new URL(link).host; let mirrors = []; for (let i = 0; i < mirror.length; i++) { for (let j = 0; j < thread; j++) { let item = link.replace(host, mirror[i]) + '&'.repeat(j); mirrors.push(item); } } return mirrors.join('\n'); } catch { return undefined } }, /** * 添加页面元素监听 * @author 油小猴 * @author hmjz100 * @description 详见代码 */ addPageListener() { temp.doc.on('click', '.listener-open-setting', () => { base.showSetting(); }); temp.doc.on('click', '.listener-open-aria2-setting', (e) => { base.showAria2Setting(e); }); temp.doc.on('click', '.listener-open-bitcomet-setting', (e) => { base.showBitcometSetting(e); }); temp.doc.on('click', '.listener-open-updatelog', () => { base.showUpdate(); }); temp.doc.on('click', '.listener-open-beautify', () => { base.showBeautify(); }); temp.doc.on('click', '.listener-unregister', async function (e) { message.warning("正在“注入”设置项目..."); let list = base.getValue("setting_init"); list.code = ""; list.license = ""; base.setValue('setting_init', list); base.delValue('baidu_access_token'); if (location.host.includes("baidu")) base.delStorage('baiduyunPlugin_BDUSS'); location.reload(); }); temp.doc.on('change', '.listener-terminal', async function (e) { base.setValue('setting_curl_terminal', e.currentTarget.value); }); temp.doc.on('click', '.listener-color', async function (e) { let element = $(e.currentTarget).closest('.listener-color').length > 0 ? $(e.currentTarget).closest('.listener-color') : $(e.currentTarget); let parent = element.closest('.pl-color'); let mask = element.find(".mask"); let color = element.data('color'); if (color && parent.length > 0 && mask.length > 0) { parent.find(".this").remove(); mask.append(`
`); let list = base.getValue("setting_ui_theme") list.color = color; base.setValue("setting_ui_theme", list); base.addPanLinkerStyle(); } }); temp.doc.on('change', '.listener-theme', async function (e) { let list = base.getValue("setting_ui_theme"); list.custom[e.currentTarget.dataset.type] = e.currentTarget.checked; base.setValue("setting_ui_theme", list); }); temp.doc.on('click', '.listener-api-download.normal', async function (e) { e.preventDefault(); let dataset = e.currentTarget.dataset; let href = dataset.link; $('#downloadIframe').attr('src', href); }); temp.doc.on('click', '.listener-retry', async function (e) { let o = base._EventFactory(e); o.tip.hide(); o.link.show(); o.directLink.show(); }); temp.doc.on('click', '.listener-stop', async function (e) { let o = base._EventFactory(e); let index = o.link[0].dataset.index; if (temp.request[index]) { temp.request[index].abort(); clearInterval(temp.ins[index]); o.item.find('.pl-progress-inner-text').text('正在取消...'); o.item.find('.pl-progress-inner').css('width', 100 + '%'); await base.sleep(1050); o.tip.hide(); o.back.hide(); o.link.show(); o.directLink.show(); o.copy.show(); o.progress.hide(); o.stop.hide(); } }); temp.doc.on('click', '.listener-back', async function (e) { let o = base._EventFactory(e); o.progress.hide(); o.tip.hide(); o.link.show(); o.directLink.show(); o.copy.show(); o.stop.hide(); o.back.hide(); }); temp.doc.on('click', '.listener-download-all', async function (e) { let target = $(e.currentTarget); let originalHtml = target.html(); $('.pl-item-link.enhance').each((index, element) => { if ($(element).css('display') !== 'none') { $(element).click(); } }); target.text('下载开始,进度见上方按钮哦~').animate({ opacity: '0.5' }, "slow"); await base.sleep(2000); target.css('opacity', ""); target.html(originalHtml); }); temp.doc.on('click', '.listener-send-rpc', async function (e) { let target = $(e.currentTarget); let originalHtml = target.html(); $(`.listener-${target.data("type")}-download`).each((index, element) => { if ($(element).attr('data-processing') !== 'true') { $(element).click(); } }); target.text('发送完成,结果见上方按钮哦~').animate({ opacity: '0.5' }, "slow"); await base.sleep(2000); target.css('opacity', ""); target.html(originalHtml); }); temp.doc.on('click', '.listener-copy', async function (e) { e.preventDefault(); let target = $(e.currentTarget); let originalHtml = target.html(); let copy = target.data("copy"); if (copy) { base.setClipboard(copy) target.html(`复制成功`).animate({ opacity: '0.5' }, "slow"); await base.sleep(2000); target.css('opacity', ""); target.html(originalHtml); } }); temp.doc.on('click', '.listener-rpc-task', function (e) { let rpc = base.getValue("setting_aria2_rpc").find(i => i.default); let url = `${config.base.service.rpc}/?rpc=${base.encodeBase(JSON.stringify({ domain: rpc.domain, port: rpc.port }))}#${rpc.token}`; GM_openInTab(url, { active: true }); }); temp.doc.on('change', '.listener-rpc-select', async function (e) { let element = $(this); let selectedIndex = element.val(); let type = element.data("type"); let list = base.getValue(`setting_${type}_rpc`); if (selectedIndex === 'new') { return $('.listener-rpc-input').val(""); } else if (list[selectedIndex]) { list.forEach((item, index) => { if (item.default) { delete item.default; } }); list[selectedIndex].default = true; base.setValue(`setting_${type}_rpc`, list); $('.listener-rpc-input').each((index, element) => { let type = $(element).data('type').split(".")[1]; $(element).val(list[selectedIndex][type] || ""); }); } }); temp.doc.on('input', '.listener-rpc-input', async function (e) { let type = $(this).data("type"); if (!type) return; type = type.split(".") let list = base.getValue(`setting_${type[0]}_rpc`); let value = $(this).val(); let selectedIndex = $('.listener-rpc-select option:selected').val(); if (selectedIndex === 'new') { list.forEach((item, index) => { if (item.default) { delete item.default; } }); list.push({ domain: "", port: "", path: "", default: true }); base.setValue(`setting_${type[0]}_rpc`, list); selectedIndex = list.length - 1 } list[selectedIndex][type[1]] = value; base.setValue(`setting_${type[0]}_rpc`, list) let select = $('.listener-rpc-select'); let options = list.map((item, index) => { return ``; }).join(""); select.html(`${options}`); }); temp.doc.on('click', '.listener-rpc-delete', async function (e) { let type = $(this).data("type"); let list = base.getValue(`setting_${type}_rpc`); let selectedIndex = $('.listener-rpc-select option:selected').val(); if (selectedIndex === 'new' || !confirm('您确定要删除此项目吗?')) return; list = list.filter((_, i) => i != selectedIndex); if (list.length === 0) return alert('至少保留一个项目'); list[selectedIndex - 1].default = true; base.setValue(`setting_${type}_rpc`, list); let select = $('.listener-rpc-select'); let options = list.map((item, index) => { return ``; }).join(""); select.html(`${options}`); $('.listener-rpc-input').each(function () { let type = $(this).data('type').split("."); $(this).val(list[selectedIndex - 1][type[1]] || ""); }); }); temp.doc.on('click', '.listener-rpc-test', async function (e) { let element = $(this); let type = element.data("type"); let selectedIndex = $('.listener-rpc-select option:selected').val(); let list = base.getValue(`setting_${type}_rpc`); let text = element.find("span"); let originalHtml = text.html(); if (selectedIndex === 'new') return; if (list[selectedIndex]) { let selected = list.find(i => i.default); let domain = selected.domain, port = selected.port, path = selected.path, token = selected.token; if (element.data("testing") === "true") return; element.data("testing", "true"); text.html("等待"); element.css({ 'opacity': '0.9' }); let result = await base.testConnectToAria2(domain, port, path, token); if (result === "success") { text.html("成功"); element.css({ 'background-color': '#52c41a' }); } else { text.html("失败"); element.css({ 'background-color': '#cb1616' }); } element.css({ 'opacity': "" }); await base.sleep(3000); element.data("testing", "false"); text.html(originalHtml); element.css({ 'background-color': "" }); } }); }, /** * 创建基础样式 * @author 油小猴 * @author hmjz100 * @description 为组件添加默认的公共样式,包括浅色和深色模式适配样式。 */ addPanLinkerStyle() { temp.color = base.getValue('setting_ui_theme').color; base.addStyle('swal-pub-style', 'style', `@media (prefers-color-scheme:light){${GM_getResourceText('SwalLigt')}}`); base.addStyle('swal-pub-dark-style', 'style', `@media (prefers-color-scheme:dark){${GM_getResourceText('SwalDark').replace(/#19191a/, '#222226')}}`); base.addStyle('swal-pub-custom-style', 'style', ` .swal2-container *{vertical-align:baseline} .swal2-styled{transition:all .2s} .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:${temp.color} transparent } .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} .swal2-timer-progress-bar{width:100%;height:.25em;background:${temp.color}33 } .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:${temp.color};color:#fff;line-height:2em;text-align:center} .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:${temp.color} } .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:${temp.color}} .swal2-html-container{padding:1em 1.6em 0.3em;margin:0} .swal2-close,div:where(.swal2-container) button:where(.swal2-close){position:absolute;border-radius:10px;top:0;right:0;transition:all .2s} .swal2-close:hover,div:where(.swal2-container) button:where(.swal2-close):hover{color:${temp.color};background-color:${temp.color}30;font-size:60px} .swal2-styled{display:flex;justify-content:center;align-items:center;gap:5px} .swal2-styled.swal2-confirm,div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){background-color:${temp.color};color:#fff} .swal2-styled.swal2-confirm:focus,div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):focus{box-shadow:0 0 0 3px ${temp.color}80} .swal2-styled.swal2-deny:focus,.swal2-close:focus,div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):focus{box-shadow:0 0 0 3px #dc374180} .swal2-styled.swal2-cancel:focus,div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):focus{box-shadow:0 0 0 3px #6e788180} .swal2-styled.swal2-confirm, .swal2-styled.swal2-deny, .swal2-styled.swal2-cancel, div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm), div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny), div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel) {border-radius:50px} div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled:hover{opacity:0.7} .swal2-backdrop-show,.swal2-noanimation,div:where(.swal2-container).swal2-backdrop-show, div:where(.swal2-container).swal2-noanimation{background:rgba(25,25,26,.75);transition:backdrop-filter .2s;backdrop-filter:blur(1px)} body.swal2-toast-shown .swal2-container{backdrop-filter:none} .swal2-popup,div:where(.swal2-container) div:where(.swal2-popup){padding-bottom:1em;border-radius:10px} .swal2-title,div:where(.swal2-container) h2:where(.swal2-title){height:auto} .swal2-html-container,div:where(.swal2-container) div:where(.swal2-html-container){padding:1.3em 1.3em 0.3em;margin:0} .swal2-footer,div:where(.swal2-container) div:where(.swal2-footer){flex-direction:column;justify-content:center;align-items:center} .swal2-icon-content,div:where(.swal2-icon) .swal2-icon-content{font-family:sans-serif} .swal2-input, .swal2-file, swal2-select, .swal2-textarea, div:where(.swal2-container) input:where(.swal2-input), div:where(.swal2-container) input:where(.swal2-file), div:where(.swal2-container) input:where(.swal2-select), div:where(.swal2-container) textarea:where(.swal2-textarea) {box-shadow:none} .swal2-input:focus, .swal2-file:focus, .swal2-select:focus, .swal2-textarea:focus, .swal2-input:focus-visible, .swal2-file:focus-visible, .swal2-select:focus-visible, .swal2-textarea:focus-visible, div:where(.swal2-container) input:where(.swal2-input):focus, div:where(.swal2-container) input:where(.swal2-input):focus-visible, div:where(.swal2-container) input:where(.swal2-file):focus, div:where(.swal2-container) input:where(.swal2-file):focus-visible, div:where(.swal2-container) input:where(.swal2-select):focus, div:where(.swal2-container) input:where(.swal2-select):focus-visible, div:where(.swal2-container) textarea:where(.swal2-textarea):focus, div:where(.swal2-container) textarea:where(.swal2-textarea):focus-visible {outline:0;border:1px solid ${temp.color};box-shadow:0 0 0 3px ${temp.color}80} .swal2-checkbox, .swal2-file, .swal2-input, .swal2-radio, .swal2-select, .swal2-textarea, div:where(.swal2-container) input:where(.swal2-input), div:where(.swal2-container) input:where(.swal2-file), div:where(.swal2-container) textarea:where(.swal2-textarea), div:where(.swal2-container) select:where(.swal2-select), div:where(.swal2-container) div:where(.swal2-radio), div:where(.swal2-container) label:where(.swal2-checkbox) {margin:1em 2em}`); base.addStyle(`${mount}-main-style`, 'style', ` ::-webkit-scrollbar{width:8px;height:8px} ::-webkit-scrollbar-track{border-radius:10px;background:#fff} ::-webkit-scrollbar-thumb,::-webkit-scrollbar-thumb:hover{border-radius:10px} ::-webkit-scrollbar-thumb{background-color:${temp.color}90!important,transition:background-color .2s;will-change:background-color} ::-webkit-scrollbar-thumb:hover{background-color:${temp.color}D0!important} .swal2-popup{font-size:16px} .pl-popup{font-size:12px;min-width:70%;max-width:95%} .pl-popup a:not(.pl-btn-primary){color:${temp.color}} .pl-popup a:hover:not(.pl-btn-primary){color:${temp.color}90} .pl-header{padding:0;align-items:flex-start;border-bottom:1px solid #eee;margin:0 0 10px;padding:0 0 5px} .pl-title{font-size:18px;white-space:nowrap;text-overflow:ellipsis} .pl-content{padding:0;font-size:12px} .pl-footer{font-size:15px;text-align:center;display:block} .pl-icon{width:15px;height:15px;vertical-align:-0.15em;fill:currentColor;overflow:hidden;font-size:18px} .pl-main{background:${temp.color}15;border-radius:10px;display:flex;flex-direction:column;gap:8px;max-height:calc(${document.documentElement.clientHeight}px - 300px);overflow:auto;padding:8px 6px} .pl-a{position:relative;vertical-align:baseline;color:${temp.color};border-bottom:2px solid ${temp.color};text-decoration:none;transition:color .3s,opacity .3s;will-change:color,opacity;overflow:hidden} .pl-a::before{content:'';position:absolute;left:0;bottom:0;width:100%;height:100%;background-color:${temp.color};transform:scaleY(0);transform-origin:bottom center;transition:transform .15s, opacity .3s;will-change:transform;z-index:-1} .pl-a:hover,.pl-a:focus{color:#fff} .pl-a:hover::before,.pl-a:focus::before{transform:scaleY(1)} .pl-a:active{color:#fff;opacity:0.8} .pl-a .pl-icon{vertical-align:-0.05em;} .pl-item{display:flex;align-items:center;background:${temp.color}30;border-radius:8px;padding:5px;gap:10px} .pl-item-name{width:15%;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:default} .pl-item-name>*{text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis} .pl-item-link{flex:1;cursor:pointer} a.pl-item-link{text-align:left;white-space:nowrap;text-overflow:ellipsis;overflow:hidden} .pl-item-tip{display:flex;justify-content:space-between;flex:1} .pl-item-progress{display:flex;flex:1;align-items:center} .pl-progress{display:inline-block;vertical-align:middle;width:100%;box-sizing:border-box;line-height:1;position:relative;height:20px;margin:0 6px;flex:1} .pl-progress-outer{height:20px;border-radius:100px;background-color:#c1c1c1a1;overflow:hidden;position:relative;vertical-align:middle} .pl-progress-inner{position:absolute;left:0;top:0;background-color:${temp.color};border-radius:100px;line-height:1;white-space:nowrap;transition:width .6s;height:20px;display:inline-flex;text-align:center;align-items:center} .pl-progress-inner-text{display:inline-block;vertical-align:middle;cursor:default;color:#ffffff;font-size:12px;margin:0 5px;height:20px;width:100%} .pl-progress-inner-text:after{display:inline-block;content:"";height:100%;vertical-align:middle} .pl-ext{display:inline-block;width:44px;background:#999;color:#fff;height:16px;line-height:16px;font-size:12px;border-radius:3px} .pl-retry{padding:3px 10px;background:#cc3235;color:#fff;border-radius:3px;cursor:pointer} .pl-extra{display:flex;background-color:${temp.color}15;border-radius:10px;gap:10px} .pl-extra:has(>*){margin-top:1.25em;padding:8px 6px} .pl-extra>*{flex:1} .pl-btn-primary{color:#ffffff!important;background:${temp.color};border:0;border-radius:50px;cursor:pointer;font-size:12px;outline:none;display:flex;align-items:center;justify-content:center;gap:5px;padding:0.625em 1.1em;transition:opacity .2s,box-shadow .2s;will-change:opacity,box-shadow} .pl-btn-primary:hover{opacity:0.8} .pl-btn-primary:focus{box-shadow:0 0 0 3px ${temp.color}80} .pl-btn-success{background:#55af28} .pl-btn-success:focus{box-shadow:0 0 0 3px #55af2880} .pl-btn-info{background:#606266} .pl-btn-info:focus{box-shadow:0 0 0 3px #60626680} .pl-btn-warning{background:#da9328} .pl-btn-warning:focus{box-shadow:0 0 0 3px #da932880} .pl-btn-danger{background:#cc3235} .pl-btn-danger:focus{box-shadow:0 0 0 3px #cc323580} .pl-btn-opacity{animation:easeOpacity 1.2s 2;animation-fill-mode:forwards;will-change:opacity} @keyframes easeOpacity{ from{opacity:1} 50%{opacity:0.35} to{opacity:1} } .pl-button-mini{padding:5px 10px} .pl-button,.pl-dropdown-menu{transition:all .2s} .pl-button{position:relative} .pl-button .pl-dropdown-menu{opacity:0;pointer-events:none;will-change:opacity} .pl-button:hover .pl-dropdown-menu{opacity:1;pointer-events:auto} .pl-button-init{opacity:0.5;animation:easeInitOpacity 1.2s 5;animation-fill-mode:forwards} @keyframes easeInitOpacity{ from{opacity:0.5} 50%{opacity:1} to{opacity:0.5} } .pl-dropdown-menu{position:absolute;padding:5px 0;color:${temp.color};background:#fff;z-index:999;min-width:110px;border-radius:5px;box-shadow:0 1px 6px ${temp.color}33;-webkit-box-shadow:0 1px 6px ${temp.color}33;text-align:center;border:none} @media (prefers-color-scheme:dark){ .pl-dropdown-menu{color:#fff;background:#222226} } .pl-button-mode{height:30px;padding:0 10px!important;display:flex;align-items:center;justify-content:center;gap:5px;cursor:pointer;white-space:nowrap;transition:background-color .2s;will-change:background-color} .pl-button-mode:hover{background-color:${temp.color}33!important} header[style="display:none;"]~.pl-button{display:inline-block;position:fixed;top:0.6em;left:65%;z-index:99999} .color-button{background:${temp.color}!important;border-color:${temp.color}!important;border:1px solid ${temp.color}!important;display:inline-flex;transition:background .2s,border-color .2s;will-change:background,border-color} .color-button:hover{background:${temp.color}b0!important;border-color:${temp.color}!important} .ali-button{background:${temp.color};border:0 solid transparent;font-size:14px;margin-left:20px;padding:8px 16px;position:relative;height:32px;border-radius:100px;display:flex;align-items:center;justify-content:center;color:var(--basic_white);cursor:pointer;transition:background .2s;will-change:background} .ali-button:hover{background:${temp.color}D0} .ali-btn-icon{vertical-align:-0.2em} .mcloud-button{float:left;position:relative;margin:20px 24px 20px 0;width:110px;height:36px;background:${temp.color};border-radius:2px;font-size:14px;color:#fff;line-height:39px;text-align:center;cursor:pointer;will-change:background} .mcloud-button:hover{background:${temp.color}b0} .mcloud-share-button{display:inline-block;position:relative;font-size:14px;line-height:36px;height:36px;text-align:center;color:#fff;border:1px solid ${temp.color};border-radius:2px;padding:0 24px;background:${temp.color};will-change:background} .mcloud-share-button:hover{background:${temp.color}b0} .mcloud-btn{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAGNQTFRFAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////mkUNoAAAACF0Uk5TAAbHPP9AMRtr9PwrV8zqXfmNgDODHTLD4iJxhGJJ8Z269m0aDgAAAMZJREFUeJzd0ssOgyAQBVDUK74rWq0PFP3/ryxqTMdGqJtuvGHD5CTDTGDs3nFc17kEPcC7BH3At/Tjvk5AYbBU+NcrwghL4uQDk3gtRSF1KWCCQEpghkd+3jp/ICNQoDANU0AQCJQmWAJ3h8+q3mFdvSywQdttsGvRWGAPLReoHXrbG6WWAzBoJ+3DaCnWI39NLbcvszvLeuTB2fYoqbNBNo7sGjzk31BhMsEJitxmiKk8zSQwE8gFjBGcNuCzOmdqPrib5A2JRQ7qK9g+hQAAAABJRU5ErkJggg==");height:20px;line-height:20px;display:inline-block;background-repeat:no-repeat;background-size:20px 20px;text-indent:25px} .tcloud-button{color:#fff;border:1px solid ${temp.color};background:${temp.color};position:relative;height:30px;padding:0 12px;margin-right:12px;font-size:12px;line-height:28px;cursor:pointer;will-change:background,border-color} .tcloud-button:hover{border-color:${temp.color}b0;background:${temp.color}b0} .xunlei-button{display:inline-flex;align-items:center;justify-content:center;border:0 solid transparent;border-radius:5px;box-shadow:0 0 0 0 transparent;width:fit-content;white-space:nowrap;flex-shrink:0;font-size:14px;line-height:1.5;outline:0;touch-action:manipulation;transition:background .2s,color .2s,border .2s,box-shadow .2s;color:#fff;background:${temp.color};margin-left:12px;padding:0px 12px;position:relative;cursor:pointer;height:36px;will-change:background} .xunlei-button:hover{background:${temp.color}b0} .quark-button,.uc-button{padding:0 14px;background:${temp.color}!important;background-color:${temp.color}!important;will-change:background,background-color} .quark-button:hover,.uc-button:hover{background:${temp.color}b0!important;background-color:${temp.color}b0!important} .quark-btn-icon,.uc-btn-icon{width:20px;height:20px;vertical-align:-0.3em} .uc-button{padding:10px 20px!important} .pl-setting-item{display:flex;align-items:center;justify-content:space-between;padding-top:1em} .pl-setting-item > *:nth-child(2){max-width:80%;display:flex;justify-content:space-between;align-items:center} .pl-setting-item .pl-setting-item{padding:0;gap:5px} .pl-input{padding:8px 10px!important;border:1px solid #c2c2c2;border-radius:5px;font-size:14px!important;margin:0;-webkit-appearance:auto} .pl-setting-item > .pl-input{width:80%} .init-input{width:90%;margin:0;margin:10px 0;text-align:center;font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Ubuntu,"Helvetica Neue",sans-serif;font-weight:300} .pl-tooltip{position:absolute;z-index:110000;display:none;align-items:center;color:#ffffff;background:#333;font-size:12px;line-height:1.3;max-width:600px;border-radius:5px;word-break:break-all;will-change:display,top,left} .pl-tooltip>*{padding:5px 10px} .pl-tooltip>*:first-child{border:1px solid;border-top-left-radius:5px;border-bottom-left-radius:5px;border-top-color:#333;border-bottom-color:#333;border-left-color:#333;border-right-color:transparent} .pl-tooltip>*:last-child{border:1px solid;border-top-right-radius:5px;border-bottom-right-radius:5px;border-top-color:#333;border-bottom-color:#333;border-left-color:transparent;border-right-color:#333} .pl-loading-box>div>div{position:absolute;border-radius:50%} .pl-loading-box>div>div:nth-child(1){top:9px;left:9px;width:82px;height:82px;background:#ffffff} @keyframes load{ 0%{transform:rotate(0deg)} 100%{transform:rotate(360deg)} } .pl-loading-box>div>div:nth-child(2){top:14px;left:38px;width:25px;height:25px;background:${temp.color};animation:load 1s linear infinite;transform-origin:12px 36px} .pl-loading{width:16px;height:16px;display:inline-block;overflow:hidden;background:none} .pl-loading-box{width:100%;height:100%;position:relative;transform:translateZ(0) scale(0.16);backface-visibility:hidden;transform-origin:0 0} .pl-loading-box div{box-sizing:content-box} .pl-button-save{background-color:${temp.color}!important;color:#fff!important} .pl-button-save:hover{background-color:${temp.color}D0!important;color:#fff!important} .swal2-container{z-index:100000} body.swal2-height-auto{height:inherit} [class^="swal2-"],[class*="pl-btn"]{transition:all .2s} /* 适配(改)百度网盘会员青春版 */ a.downloadSubtitle, button.downloadSubtitle{transition:all .2s;background-color:${temp.color}} a.downloadSubtitle:hover, button.downloadSubtitle:hover{background-color:${temp.color}D0} a.downloadSubtitle:disabled, button.downloadSubtitle:disabled{background-color:${temp.color}D0} /* 哪里都没用到的 RGB! */ @keyframes RGB{ 0%{filter:hue-rotate()} to{filter:hue-rotate(-360deg)} } /* Webkit, Opera, IE9, Chrome*/ ::selection, ::-webkit-selection, ::-moz-selection, ::-ms-selection{background-color:${temp.color}!important;background:${temp.color}!important;color:white!important} `); if (/(pan|yun).baidu.com/.test(location.host) && $baidu.detectPage() !== 'home' && base.getValue('setting_ui_theme').custom.$baidu === true) { base.setColors([ ['#717fff', temp.color], ['#717FFF', temp.color], ['#06a8ff', temp.color], ['#06A8FF', temp.color], ['#06a7ff', temp.color], ['#06A7FF', temp.color], ['#dcdfe6', temp.color], ['#DCDFE6', temp.color], ['#0095ff', temp.color], ['#0095FF', temp.color], ['#09aaff', temp.color], ['#09AAFF', temp.color], ['#0ca6ff', temp.color], ['#0CA6FF', temp.color], ['#5040ff', temp.color], ['#5040FF', temp.color], ['#454d5a', temp.color], ['#454D5A', temp.color], ['#a2abbd', temp.color], ['#A2ABBD', temp.color], ['#030b1a', temp.color], ['#030B1A', temp.color], ['#afb3bf', temp.color], ['#AFB3BF', temp.color], ['#ff436a', temp.color], ['#FF436A', temp.color], ['#03081a', temp.color], ['#03081A', temp.color], ['#2974b6', temp.color], ['#2974B6', temp.color], ['#0596e6', temp.color], ['#0596E6', temp.color], ['#C3EAFF', temp.color], ['#c0d9fe', `${temp.color}50`], ['#0098EA', `${temp.color}D0`], ['#38b9ff', `${temp.color}D0`], ['#38B9FF', `${temp.color}D0`], ['#42d8ff', `${temp.color}D0`], ['#42D8FF', `${temp.color}D0`], ['#a48dff', `${temp.color}D0`], ['#A48DFF', `${temp.color}D0`], ['#6b79f2', `${temp.color}D0`], ['#6B79F2', `${temp.color}D0`], ['#9c86f2', `${temp.color}90`], ['#9C86F2', `${temp.color}90`], ['#83d3ff', `${temp.color}90`], ['#83D3FF', `${temp.color}90`], ['#C4D8F4', `${temp.color}90`], ['#fafafc', `${temp.color}20`], ['#FAFAFC', `${temp.color}20`], ['#f5fbff', `${temp.color}20`], ['#F5FBFF', `${temp.color}20`], ['#b4e5ff', `${temp.color}20`], ['#B4E5FF', `${temp.color}20`], ['#f0faff', `${temp.color}20`], ['#F0FAFF', `${temp.color}20`], ['#c4d8f4', `${temp.color}20`], ['#f1f3f8', `${temp.color}15`], ['#F1F3F8', `${temp.color}15`], ['#f2faff', `${temp.color}10`], ['#F2FAFF', `${temp.color}10`], ['#eef9fe', `${temp.color}10`], ['#EEF9FE', `${temp.color}10`], ['#f7f9fc', `${temp.color}10`], ['#F7F9FC', `${temp.color}10`], ['#f5f6fa', `${temp.color}10`], ['#F5F6FA', `${temp.color}10`], ['#b4e5ff', `${temp.color}10`], ['#B4E5FF', `${temp.color}10`], ['#e6f6ff', `${temp.color}10`], ['#E6F6FF', `${temp.color}10`], ['0,149,255', base.hexToRgba(temp.color)], ['30, 175, 255', base.hexToRgba(temp.color)], ['6, 167, 255, 0.1', base.hexToRgba(`${temp.color}1a`)], ['6,167,255,.1', base.hexToRgba(`${temp.color}1a`)], ['6,167,255,.23', base.hexToRgba(`${temp.color}3b`)], ['164,141,255,.2', base.hexToRgba(`${temp.color}30`)], ['196,182,255,.2', base.hexToRgba(`${temp.color}20`)], ['113,127,255,.2', base.hexToRgba(`${temp.color}40`)], ['3,8,26,.6', base.hexToRgba(`${temp.color}D0`)], ['255,32,102,.4', base.hexToRgba(`${temp.color}66`)], ['72,166,248,.7', base.hexToRgba(`${temp.color}66`)], ]); }; if (/(pan|yun).baidu.com/.test(location.host) && base.getValue('setting_ui_theme').custom.$baidu === true) { base.addStyle(`${mount}-baidu`, 'style', ` #layoutMain, .DxdbeCb{ border-radius:10px; border-bottom-left-radius:0; border-bottom-right-radius:0; background:#ffffffA0!important } .KPDwCE, .DxdbeCb .OFaPaO .tanwePYr, .xGLMIab .fufHyA:hover, .module-search-timeline .form-box{ background:#ffffffA0!important; } .KPDwCE .JDeHdxb, .NHcGw .AuPKyz, .xGLMIab .tvPMvPb, .xGLMIab .FcQMwt, .cazEfA .yfHIsP, .hscjZ4QL .bbxnZ0Bq .ehnyLxWZ span, .module-topToolBar, .module-timeline-view .timeline-title-curday{ background:transparent!important; border-bottom:0; } .MdLxwM{ background :#fff!important; } .aside-absolute-container{ position:absolute!important; } .aside-absolute-container .QGOvsxb .remainingSpaceUi_span{ background:#8af248!important; border-radius:10px 0 0 10px; border-right:#fff 1px solid; border-bottom:#fff 1px solid; } .xtJbHcb .CDaavKb .KQcHyA{ background:rgb(244,207,0)!important; padding:8px 15px; } .xtJbHcb .web-header-nav-new-version-inner{ background:${temp.color}!important; padding:8px 15px; line-height:15px; width:auto; height:auto; } a{ transition:all .2s!important; } #bd-main .bd-left{ margin:auto!important; } .verify-input input{ padding-left:0!important; text-align:center!important; } .verify-input input:focus{ border:2px solid ${temp.color}!important; } [data-theme=light] .vp-video-page-card .vp-video-page-card__video-detail{ color:#030b1a; } dt.level-1{ background:#fd6d65!important; } dt.level-2{ background:#f3a723!important; } dt.level-1 i.desc-arrow{ border-bottom:10px solid #dd6966!important; } dt.level-2 i.desc-arrow{ border-bottom:10px solid #d29633!important; } `, `.${mount}`); base.setColors([ ['#717fff', temp.color], ['#717FFF', temp.color], ['#06a8ff', temp.color], ['#06A8FF', temp.color], ['#06a7ff', temp.color], ['#06A7FF', temp.color], ['#dcdfe6', temp.color], ['#DCDFE6', temp.color], ['#0095ff', temp.color], ['#0095FF', temp.color], ['#09aaff', temp.color], ['#09AAFF', temp.color], ['#0ca6ff', temp.color], ['#0CA6FF', temp.color], ['#5040ff', temp.color], ['#5040FF', temp.color], ['#454d5a', temp.color], ['#454D5A', temp.color], ['#a2abbd', temp.color], ['#A2ABBD', temp.color], ['#030b1a', temp.color], ['#030B1A', temp.color], ['#afb3bf', temp.color], ['#AFB3BF', temp.color], ['#ff436a', temp.color], ['#FF436A', temp.color], ['#03081a', temp.color], ['#03081A', temp.color], ['#2974b6', temp.color], ['#2974B6', temp.color], ['#0596e6', temp.color], ['#0596E6', temp.color], ['#C3EAFF', temp.color], ['#c0d9fe', `${temp.color}50`], ['#0098EA', `${temp.color}D0`], ['#38b9ff', `${temp.color}D0`], ['#38B9FF', `${temp.color}D0`], ['#42d8ff', `${temp.color}D0`], ['#42D8FF', `${temp.color}D0`], ['#a48dff', `${temp.color}D0`], ['#A48DFF', `${temp.color}D0`], ['#6b79f2', `${temp.color}D0`], ['#6B79F2', `${temp.color}D0`], ['#9c86f2', `${temp.color}90`], ['#9C86F2', `${temp.color}90`], ['#83d3ff', `${temp.color}90`], ['#83D3FF', `${temp.color}90`], ['#C4D8F4', `${temp.color}90`], ['#fafafc', `${temp.color}20`], ['#FAFAFC', `${temp.color}20`], ['#f5fbff', `${temp.color}20`], ['#F5FBFF', `${temp.color}20`], ['#b4e5ff', `${temp.color}20`], ['#B4E5FF', `${temp.color}20`], ['#f0faff', `${temp.color}20`], ['#F0FAFF', `${temp.color}20`], ['#c4d8f4', `${temp.color}20`], ['#f1f3f8', `${temp.color}15`], ['#F1F3F8', `${temp.color}15`], ['#f2faff', `${temp.color}10`], ['#F2FAFF', `${temp.color}10`], ['#eef9fe', `${temp.color}10`], ['#EEF9FE', `${temp.color}10`], ['#f7f9fc', `${temp.color}10`], ['#F7F9FC', `${temp.color}10`], ['#f5f6fa', `${temp.color}10`], ['#F5F6FA', `${temp.color}10`], ['#b4e5ff', `${temp.color}10`], ['#B4E5FF', `${temp.color}10`], ['#e6f6ff', `${temp.color}10`], ['#E6F6FF', `${temp.color}10`], ['0,149,255', base.hexToRgba(temp.color)], ['30, 175, 255', base.hexToRgba(temp.color)], ['6, 167, 255, 0.1', base.hexToRgba(`${temp.color}1a`)], ['6,167,255,.1', base.hexToRgba(`${temp.color}1a`)], ['6,167,255,.23', base.hexToRgba(`${temp.color}3b`)], ['164,141,255,.2', base.hexToRgba(`${temp.color}30`)], ['196,182,255,.2', base.hexToRgba(`${temp.color}20`)], ['113,127,255,.2', base.hexToRgba(`${temp.color}40`)], ['3,8,26,.6', base.hexToRgba(`${temp.color}D0`)], ['255,32,102,.4', base.hexToRgba(`${temp.color}66`)], ['72,166,248,.7', base.hexToRgba(`${temp.color}66`)], ], "other"); }; if (/www.(aliyundrive|alipan).com/.test(location.host) && base.getValue('setting_ui_theme').custom.$aliyun === true) { base.setColors([ ['#3763ff', temp.color], ['#8664ff', `${temp.color}D0`], ['99, 125, 255', base.hexToRgba(temp.color)], ['132, 133, 141', base.hexToRgba(temp.color)], ['112, 136, 255', base.hexToRgba(temp.color)], ['97, 122, 250', base.hexToRgba(temp.color)], ['68, 109, 255', base.hexToRgba(temp.color)], ['82, 110, 250', base.hexToRgba(`${temp.color}20`)], ['122, 144, 255', base.hexToRgba(`${temp.color}D0`)], ['138, 157, 255', base.hexToRgba(`${temp.color}D0`)], //['49, 49, 54', base.hexToRgba(color)], ]); }; if (/(yun|caiyun).139.com/.test(location.host) && base.getValue('setting_ui_theme').custom.$mcloud === true) { base.setColors([ ['#3181f9', temp.color], ['#5a9afa', temp.color], ['#98c0fc', `${temp.color}D0`], ['#2d76e5', `${temp.color}D0`], ['49,129,249,.08', base.hexToRgba(`${temp.color}20`)], ]); }; if (/cloud.189.cn/.test(location.host) && base.getValue('setting_ui_theme').custom.$tcloud === true) { base.setColors([ ['#2b89ea', temp.color], ['#1874d3', `${temp.color}F0`], ['#1890ff', temp.color], ['#388fc9', temp.color], ['#0087ff', temp.color], ['#255697', temp.color], ['#3ea6ff', `${temp.color}80`], ['#1d52f2', temp.color], ['#3699ff', `${temp.color}D0`], ['#f4f9fe', `${temp.color}10`], ['#eaf5ff', `${temp.color}20`], ], "other"); } if (/pan.xunlei.com/.test(location.host) && base.getValue('setting_ui_theme').custom.$xunlei === true) { base.setColors([ ['#3f85ff', temp.color], ['63,133,255,.1', base.hexToRgba(`${temp.color}20`)], ['#2670ea', `${temp.color}D0`], ['#619bff', `${temp.color}D0`], ['#ecf3ff', `${temp.color}10`], ['#f6faff', `${temp.color}10`], ['#1a2845', `${temp.color}20`], ['#0f2035', `${temp.color}20`], ['#308bfd', `${temp.color}20`], ['#eee', `${temp.color}20`], ], "other"); base.addStyle(`${mount}-xunlei`, 'style', ` .web-header{ background:linear-gradient(0deg,${temp.color}D0,${temp.color}) } `); }; if (/pan.quark.cn/.test(location.host) && base.getValue('setting_ui_theme').custom.$quark === true) { base.setColors([ ['#0d53ff', temp.color], ['#e6f1ff', `${temp.color}20`], ['#f0faff', `${temp.color}20`], ['#7da3ff', `${temp.color}D0`], ['#ddd', `${temp.color}D0`], ['17,17,17,.9', base.hexToRgba(`${temp.color}D0`)], ['40,40,255,.04', base.hexToRgba(`${temp.color}20`)], ['#f7f7ff', 'transparent'], ['238,247,255,0', base.hexToRgba(`${temp.color}00`)], ]); base.addStyle(`${mount}-quark`, 'style', ` .file-list .hover-oper .hover-transparent-bg{ background:transparent!important; } .ant-checkbox-wrapper .ant-checkbox-checked .ant-checkbox-inner, .ant-checkbox-wrapper .ant-checkbox-indeterminate .ant-checkbox-inner:after{ background-color:${temp.color}!important; } `); }; if (/drive.uc.cn/.test(location.host) && base.getValue('setting_ui_theme').custom.$uc === true) { base.setColors([ ['#12161a', temp.color], ['#e6f1ff', `${temp.color}20`], ['#f0faff', `${temp.color}20`], ['#7da3ff', `${temp.color}D0`], ['#ddd', `${temp.color}D0`], ['17,17,17,.9', base.hexToRgba(`${temp.color}D0`)], ['40,40,255,.04', base.hexToRgba(`${temp.color}20`)], ['#f7f7ff', 'transparent'], ['238,247,255,0', base.hexToRgba(`${temp.color}00`)], ]); base.addStyle(`${mount}-uc`, 'style', ` .file-list .hover-oper .hover-transparent-bg{ background:transparent!important; } `); }; if (/www.(123(pan|684|865|952|912).com|123pan.cn)/.test(location.host) && base.getValue('setting_ui_theme').custom.$123pan === true) { base.setColors([ ['#597dfc', temp.color], ['#5a7cfc', temp.color], ['#2A82E4', temp.color], ['#51a1f0', temp.color], ['#597DFC', temp.color], ['#40a9ff', temp.color], ['#3c80ff', temp.color], ['#3C80FF', temp.color], ['#1890ff', temp.color], ['#f0f9ff', `${temp.color}20`], ['#F2F5FF', `${temp.color}20`], ['#325cf0', `${temp.color}D0`], ['60, 128, 255', base.hexToRgba(temp.color)], ['42, 130, 228', base.hexToRgba(temp.color)], ]); } }, /** * 初始化引导弹窗 * @author 油小猴 * @author hmjz100 * @description 显示初始化对话框,引导用户进行配置或跳过流程。 * 支持输入特定数字触发彩蛋,并自动注入默认设置点亮功能。 * @returns {Promise} 弹窗关闭后返回空值,可能触发页面刷新 */ async showInitDialog() { let dialog = await Swal.fire({ ...temp.swalDefault, title: `(◍•ᴗ•◍)/ 你好呀`, html: `

“这里好像没什么好输入的…”

但其实…你可以按下下方的 红色按钮 跳过流程
或者继续输入一些神秘的 “恶臭数字”,解锁隐藏彩蛋~

如果您喜欢这个脚本的话
请支持原作者 油小猴
或给此改版点个 Star

脚本不仅能精简网盘界面
点亮后还能修改多个网盘的主题色哦!

`, showCloseButton: true, showDenyButton: true, denyButtonText: ' 懒得输入...我要直接点亮!', allowOutsideClick: false, }); if (dialog.isDenied) { console.log("【LinkSwift】\n正在“注入”点亮按钮设置项目..."); message.warning("正在“注入”设置项目..."); await base.sleep(2500); let list = base.getValue("setting_init"); list.code = config.base.num; list.license = config.base.license; base.setValue("setting_init", list); message.success("“注入”成功啦!"); await base.sleep(1500); location.reload(); }; if (dialog.isConfirmed) { if ($('#init').val() === '114514' || $('#init').val() === '1919810' || $('#init').val() === '1145141919810') { await Swal.fire({ ...temp.swalDefault, icon: 'error', title: '1145141919810', html: 'homo特有的数字当然不行啦
哼哼哼啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
', timer: 4000, imageUrl: 'https://pic1.zhimg.com/v2-1b97a088e156c015108dec663bba8b04.avis', allowOutsideClick: false, timerProgressBar: true, showConfirmButton: false, showDenyButton: true, denyButtonText: '哼哼哼啊啊啊啊啊啊啊啊啊啊', }); message.info("成就:你触发了一个homo特有的彩蛋!"); await base.sleep(4000) Swal.fire({ ...temp.swalDefault, title: '1145141919810', text: 'homo特有的数字当然不行啦...吗?', icon: 'question', imageUrl: 'https://lh1.hetaousercontent.com/img/7d4c1c0b4adb0e95.jpg', showConfirmButton: false, allowOutsideClick: false, }); await base.sleep(3000) let list = base.getValue("setting_init"); list.code = config.base.num; list.license = config.base.license; base.setValue("setting_init", list); message.success("成就:哼哼哼啊啊啊啊啊啊啊啊地注入成功(喜)"); await base.sleep(1500) location.reload(); } else { console.log("【LinkSwift】\n暗号错误") await this.showInitDialog(); return; }; } }, /** * 显示主对话框 * @author 油小猴 * @author hmjz100 * @description 使用 SweetAlert2 显示一个自定义样式的对话框,用于展示信息或操作提示。 * @param {string} title - 对话框标题 * @param {string} html - 对话框内容的 HTML 字符串 * @param {string} footer - 对话框底部说明文字 */ showMainDialog(title, html, footer) { Swal.fire({ ...temp.swalDefault, title, html, footer: `${footer}${config.base.dom.footer}`, customClass: { popup: 'pl-popup', header: 'pl-header', title: 'pl-title', closeButton: 'pl-close', content: 'pl-content', input: 'pl-input', footer: 'pl-footer' }, confirmButtonText: ` 关闭`, showCloseButton: true, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, willClose: () => { base._resetAllData(); }, }).then(() => { base._resetAllData(); }); }, /** * 等待指定元素加载完成并执行回调 * @author hmjz100 * @description 监听 DOM 元素是否出现,若未出现则每隔一段时间重试,直到找到为止。 * 支持在 iframe 内部查找元素,适用于异步加载场景。 * @param {string} selectorElem - 要等待的目标元素选择器 * @param {Function} actionFunction - 找到元素后执行的回调函数,接收 jQuery 元素作为参数,返回 true 可以不再继续寻找 * @param {boolean} [bWaitOnce=false] - 是否只执行一次回调,默认为 false,如果不设置为 true 的话需要自行判断是否对元素进行操作 * @param {string} [iframeSelector] - 若目标元素位于 iframe 中,传入 iframe 的选择器 * @param {string} [controlKey] - 控制唯一性的键名,用于避免重复处理 */ waitForKeyElements(selectorElem, actionFunction, bWaitOnce, iframeSelector, controlKey) { // 初始化管理器 const manager = this.waitForKeyElements.manager || ( this.waitForKeyElements.manager = { observers: new WeakMap(), tasks: new Map(), instanceCounter: 0 } ); const targetDoc = iframeSelector ? $(iframeSelector).get(0)?.contentDocument : document; if (!targetDoc) return; // 无效文档直接返回 // 生成唯一控制键 controlKey = controlKey || `wkfe_${manager.instanceCounter++}`; // 清理重复任务 const existingTask = manager.tasks.get(controlKey); if (existingTask) { existingTask.observer.disconnect(); manager.tasks.delete(controlKey); } // 创建MutationObserver回调 const processElements = () => { const elements = $(selectorElem, targetDoc); let foundActive = false; elements.each((i, el) => { const jEl = $(el); const isProcessed = jEl.data(controlKey); if (isProcessed) return true; // 跳过已处理元素 const cancelAction = actionFunction(jEl); if (cancelAction) { foundActive = true; } else if (bWaitOnce) { jEl.data(controlKey, true); // 标记已处理 } }); // 一次性任务且找到有效元素时清理 if (bWaitOnce && foundActive) { observer.disconnect(); manager.tasks.delete(controlKey); } }; // 创建Observer实例 const observer = new MutationObserver(processElements); // 配置并启动观察 observer.observe(targetDoc.documentElement, { childList: true, subtree: true, attributes: true, characterData: true }); // 注册任务 manager.tasks.set(controlKey, { observer, targetDoc }); // 立即执行初始检查 processElements(); }, /** * 状态工厂 * @author 油小猴 * @author hmjz100 * @description 接受被监听的 DOM 元素的状态,根据状态确定元素是谁 * @param {Event} event - 元素状态 */ _EventFactory(event) { let target = $(event.target); let item = target.parents('.pl-item'); let link = item.find('.pl-item-link.enhance'); let directLink = item.find('.pl-item-link.normal'); let progress = item.find('.pl-item-progress'); let tip = item.find('.pl-item-tip'); let copy = item.find('.pl-item-copy'); let back = item.find('.pl-progress-back'); let stop = item.find('.pl-progress-stop'); return { item, link, directLink, progress, tip, copy, back, stop, target, }; } }; /** * 百度网盘 * @author 油小猴 * @author hmjz100 */ let $baidu = { _getExtra() { let seKey = decodeURIComponent(base.getCookie('BDCLND')); return '{' + '"sekey":"' + seKey + '"' + "}"; }, _getSurl() { let reg = /(?<=s\/|surl=)([a-zA-Z0-9_-]+)/g; if (reg.test(location.href)) { return location.href.match(reg)[0]; } return ""; }, setBDUSS(custom) { if (custom) { base.setStorage("baiduyunPlugin_BDUSS", { BDUSS: custom }); return; } try { GM_cookie('list', { name: 'BDUSS' }, (cookies, error) => { if (!error) { let BDUSS = cookies?.[0]?.value; if (BDUSS) { base.setStorage("baiduyunPlugin_BDUSS", { BDUSS }); } } else { throw new Error(error) } }); } catch (e) { console.error("【LinkSwift】\nsetBDUSS\n错误信息:", e) try { let BDUSS = document.cookie.match(/BDUSS=(.*?)(;|$)/); if (!!BDUSS || BDUSS === null) throw new Error("document.cookie dosen't had cookie") base.setStorage("baiduyunPlugin_BDUSS", { BDUSS: BDUSS }); } catch (e) { console.error("【LinkSwift】\nsetBDUSS\n错误信息:", e) } } }, getBDUSS() { temp.doc.find('.loading-popup .loading-title').html(`凭证获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取当前账号凭证~
`); let baiduyunPlugin_BDUSS = base.getStorage('baiduyunPlugin_BDUSS') ? base.getStorage('baiduyunPlugin_BDUSS') : { BDUSS: "" }; return baiduyunPlugin_BDUSS.BDUSS || ""; }, async getToken() { try { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取授权状态~
`); // 获取授权状态 let authorize = await base.getFinalUrl(config.$baidu.api.getAccessToken, undefined, true); // 判断授权情况 if (authorize.includes('authorize')) { // 没授权,先获取授权的页面 temp.doc.find('.loading-popup .loading-title').html(`授权获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取授权页面~
`); let html = await base.get(config.$baidu.api.getAccessToken, {}, 'text'); // 提取页面的发送确认授权的参数 let bdstoken = html.match(/name="bdstoken"\s+value="([^"]+)"/)?.[1]; let client_id = html.match(/name="client_id"\s+value="([^"]+)"/)?.[1]; let data = { grant_permissions_arr: 'netdisk', bdstoken: bdstoken, client_id: client_id, response_type: "token", display: "page", grant_permissions: "basic,netdisk" }; temp.doc.find('.loading-popup .loading-title').html(`授权获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在自动确认授权~
`); // 发送请求达到自动进行授权 await base.post(config.$baidu.api.getAccessToken, base.stringify(data), { 'Content-Type': 'application/x-www-form-urlencoded', }); // 再次获取授权状态 let res2 = await base.getFinalUrl(config.$baidu.api.getAccessToken, undefined, true); let accessToken = res2.match(/access_token=([^&]+)/)?.[1]; if (!!accessToken) { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
授权成功,令牌已缓存~
`); base.setValue('baidu_access_token', accessToken); return accessToken; } else { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
授权失败,等待下一步操作~
`); return ""; } } else if (authorize.includes('access_token=')) { let accessToken = authorize.match(/access_token=([^&]+)/)?.[1]; if (!!accessToken) { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
授权成功,令牌已缓存~
`); base.setValue('baidu_access_token', accessToken); return accessToken; } else { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
授权失败,等待下一步操作~
`); return ""; } } else { return ""; } } catch (error) { return ""; } }, addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:百度网盘'); if (window[key]) return; window[key] = true; temp.doc.on('mouseenter mouseleave click', '.pl-button.g-dropdown-button', function (e) { if (e.type === 'mouseleave') { $(e.currentTarget).removeClass('button-open'); } else { $(e.currentTarget).addClass('button-open'); $(e.currentTarget).find('.pl-dropdown-menu').show(); } }); temp.doc.on('mouseleave', '.pl-button.g-dropdown-button .pl-dropdown-menu', function (e) { $(e.currentTarget).hide(); }); temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; $baidu.getLink(); }); temp.doc.on('click', '.pl-button-save', async function (e) { e.preventDefault(); temp.selectList = $baidu.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要保存到网盘的文件哦~'); } message.info('提示:
因网盘限制,请保存到自己网盘后再去下载哦~'); await base.sleep(500); document.querySelector('.tools-share-save-hb').click(); }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(o.link[0].dataset.link, { "User-Agent": config.$baidu.api.ua.downloadLink }, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async () => { let prog = +temp.progress[index] || 0; let isIDM = !!temp.idm[index]; if (isIDM) { // IDM 捕获处理逻辑 o.tip.hide(); o.progress.hide(); o.copy.show(); o.directLink.show(); o.link .text('链接已被IDM捕获~请查看IDM下载窗口哦!') .animate({ opacity: '0.5' }, "slow") .show(); clearInterval(temp.ins[index]); await base.sleep(2000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); temp.idm[index] = false; return; } let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let BDUSS = $baidu.getBDUSS(); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename"), [`User-Agent:${config.$baidu.api.ua.downloadLink}`, `Cookie:BDUSS=${BDUSS}`]); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let BDUSS = $baidu.getBDUSS(); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename"), { "user_agent": config.$baidu.api.ua.downloadLink, "cookie": `BDUSS=${BDUSS}` }); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, greenerPage() { temp.pege = $baidu.detectPage(); base.waitForKeyElements(".wp-s-header-user__vip-center", function (tag) { tag.remove(); }, true); base.waitForKeyElements(".wp-s-header-user__create-team-content", function (tag) { tag.remove(); }, true); base.waitForKeyElements(".app-user-vip-center-box.vip-center-type-2", function (tag) { tag.remove(); }, true); base.waitForKeyElements(".wp-s-header__vip-btn-tip", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".app-user-vip-center-tip", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements("#web-header-text-s-45", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".wp-s-header__vip-btn", function (tag) { tag.text("会员中心") }, true); base.waitForKeyElements(".KQcHyA", function (tag) { tag.text("会员中心") }, true); base.waitForKeyElements(".gOIbzPb", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".wp-s-header-user__create-team-title", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".web-header-ad-item", function (tag) { tag.fadeOut(); }); base.waitForKeyElements(".wp-s-header__game-entry", function (tag) { tag.fadeOut(); }, true) base.waitForKeyElements(".bd-aside-ad", function (tag) { tag.fadeOut(); }, true) base.waitForKeyElements(".btn-img-tips", function (tag) { tag.fadeOut(); }, true) base.waitForKeyElements(".nd-operate-guidance", function (tag) { tag.fadeOut(); }, true) base.waitForKeyElements(".module-operation-content", function (tag) { tag.fadeOut(); document.querySelector(".operate-guide-close").click(); document.querySelector(".module-canvas").click(); }, true) base.waitForKeyElements("[class*='module-'][class*='-box']:not(.module-box), [class*='module-'][class*='-mask']", function (tag) { tag.fadeOut(); tag.find(".close-mask").click(); }, true) base.waitForKeyElements(".newIcon", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".u-badge__content.is-dot", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".wp-side-options.g-clearfix", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".wp-s-header-user__drop-channel", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".app-download", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('.g-button[title*="手机"]', function (tag) { tag.fadeOut(); }, true) base.waitForKeyElements('.yike-entrance', function (tag) { tag.remove(); }, true) base.waitForKeyElements("a.tools__item", function (tag) { if (tag.attr("linked")) return; if (tag.attr('href')) { try { let url = new URL(tag.closest('a').attr('href')); url.search = ""; url.hash = url.hash.replace(/\?(.*?)(#|$)/, '$2') tag.attr('href', url.href) } catch (e) { } } tag.attr("linked", true) }, true); base.waitForKeyElements("p.wp-s-aside-nav__main-item-text", function (tag) { if (tag.attr("linked")) return; if (tag.closest('a').attr('href')) { try { let url = new URL(tag.closest('a').attr('href')); url.search = ""; url.hash = url.hash.replace(/\?(.*?)(#|$)/, '$2') tag.closest('a').attr('href', url.href) } catch (e) { } } if (tag.is(":contains('插件'), :contains('相册'), :contains('笔记')") && tag.closest('a').attr('target') !== "_blank") { tag.closest('a').fadeOut(); } else { tag.text(tag.text().replace("百度", "")); } tag.attr("linked", true) }, true); base.waitForKeyElements('dd[node-type="header-link"]', function (tag) { tag.children().each((index, element) => { let tag = $(element); if (!tag.attr("node-type")) return; let type = tag.attr("node-type"); if ( type !== "disk-home" && type !== "mbox-homepage" && type !== "find-apps" ) { tag.fadeOut(); } }); }, true); base.waitForKeyElements(".__yunguanjia", function (tag) { tag.html(`
添加我的电脑
用电脑下载并登录最新百度网盘客户端,即自动完成添加。 下载百度网盘客户端
LinkSwift 修复该选项
`); }, true) // 美化分享页面 if (temp.pege === 'share') { base.waitForKeyElements(`iframe[src^="/buy/ad"]`, function (tag) { tag.fadeOut(); }, true) base.addStyle(`${mount}-baiduShare`, 'style', ` body, .theme-white.init-new, #layoutApp{ background-color:#DCEFFE!important; background:#DCEFFE url(https://nd-static.bdstatic.com/m-static/disk-share/widget/pageModule/init-new/image/init-bg_1708266.png) no-repeat center center; } #bd-main .bd-left{ background:#ffffffC0; border-radius:10px; } iframe[src="/buy/ad/home"]{ display:none!important; } `, `.${mount}`); base.waitForKeyElements(`.KPDwCE`, function (tag) { tag.css('background', 'transparent'); }, true); base.waitForKeyElements('.share-list .KPDwCE .AuPKyz', function (tag) { tag.css('background', 'transparent'); }, true); base.waitForKeyElements(`#layoutMain`, function (tag) { tag.css({ "border-radius": "24px" }); }, true) base.waitForKeyElements(".frame-content", function (tag) { tag.css({ "margin": "auto" }); }, true) } }, addButton() { base.waitForKeyElements(config.$baidu.mount.home, (element) => { temp.pege = $baidu.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
下载助手
`); element.prepend($button); }) base.waitForKeyElements(config.$baidu.mount.main, (element) => { temp.pege = $baidu.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'main') return; let $button = $(`
`); element.prepend($button); }) base.waitForKeyElements(config.$baidu.mount.main, (element) => { temp.pege = $baidu.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'youth') return; let $button = $(`
`); element.prepend($button); }) base.waitForKeyElements(config.$baidu.mount.share, (element) => { temp.pege = $baidu.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(` 下载助手 `) element.after($button); }) this.setBDUSS(); }, addInitButton() { base.waitForKeyElements(config.$baidu.mount.home, (element) => { temp.pege = $baidu.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
点我点亮
`); $button.click(() => { base.showInitDialog() }); element.prepend($button); }) base.waitForKeyElements(config.$baidu.mount.main, (element) => { temp.pege = $baidu.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || (temp.pege !== 'main' && temp.pege !== 'youth')) return; let $button = $(`
`); $button.click(() => { base.showInitDialog() }); element.prepend($button); }) base.waitForKeyElements(config.$baidu.mount.share, (element) => { temp.pege = $baidu.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(` 点我点亮 `) $button.click(() => { base.showInitDialog() }); element.after($button); }) }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: () => { Swal.showLoading(); }, }); // 获取选择的文件列表 temp.selectList = this.getSelectedList(); let BDUSS = this.getBDUSS(), accessToken = (base.getValue('baidu_access_token') || await $baidu.getToken()); if (!accessToken) { message.info('提示:
稍后请在新标签页中授权助手哦~'); base.delValue('baidu_access_token'); await base.sleep(3300); GM_openInTab(config.$baidu.api.getAccessToken, { active: true, insert: true, setParent: true }) let attempts = 0; let interval = setInterval(() => { if (!!base.getValue('baidu_access_token')) { clearInterval(interval); accessToken = base.getValue('baidu_access_token') } attempts++; if (attempts > 120) { clearInterval(interval); return message.error('提示:
时间太长,我先撤下啦~'); } }, 1000); return; } if (!BDUSS) { async function getBDUSS() { let dialog = await Swal.fire({ ...temp.swalDefault, icon: 'info', title: `提示`, html: '你好呀,为了获取百度网盘文件的下载直链
我们需要您安装原作者的辅助扩展
来让 “下载助手” 读取您的网盘账号凭证 (BDUSS)
获取到的凭证仅用于生成直链,请放心安装\\(≧▽≦*)o

不知道如何安装第三方扩展?点此查看详情
如果给浏览器开启了“开发者模式”后频繁提示
“关闭开发者模式”,请使用此补丁隐藏提示。界面汉化
扩展安装后请刷新本页,以应用最新更改', showConfirmButton: true, showDenyButton: true, showCancelButton: true, showCloseButton: true, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, confirmButtonText: '前往 Chrome(Crx搜搜)', denyButtonText: '前往 Firefox(Crx搜搜)', cancelButtonText: '装不了扩展,我要手动输入', position: 'center', }); if (dialog.isConfirmed) { GM_openInTab('https://www.crxsoso.com/addon/detail/mphijdmblaalbakceeadippfkbgfgaaa ', { active: true }); } if (dialog.isDenied) { GM_openInTab('https://www.crxsoso.com/firefox/detail/baidunetdiskisasb ', { active: true }); } if (dialog.isDismissed && dialog.dismiss === Swal.DismissReason.cancel) { while (true) { let idialog = await Swal.fire({ ...temp.swalDefault, title: '手动输入凭证', html: `

Via 浏览器获取方法

打开任意百度网盘页面 →

点击地址栏左侧的安全图标 →

查看 Cookies →

找到 "BDUSS=" 字段 →

复制等于号后面的内容直到分号 (不含分号) →

然后粘贴到这里


桌面端浏览器获取方法

打开任意百度网盘页面 →

F12 打开开发者工具 →

转到 应用(Application) 标签 →

Cookies →

找到 "BDUSS" 字段 →

复制其值粘贴到这里

`, showConfirmButton: true, showDenyButton: true, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, focusConfirm: false, }); if (idialog.isConfirmed) { let BDUSS = $('#init').val().trim(); if (BDUSS && BDUSS.length >= 192) { $baidu.setBDUSS(BDUSS); return message.success('提示:
凭证设置成功
请再获取一次下载链接吧~'); } else { await Swal.fire({ ...temp.swalDefault, icon: 'error', title: '格式错误', text: '请输入有效的 BDUSS(通常长度 ≥ 192 位)', }); continue; } } else if (idialog.isDenied) { return await getBDUSS(); } } } } return await getBDUSS(); } if (temp.pege === 'home' || temp.pege === 'main') { if (!temp.selectList.length) { return message.error('提示:
先勾选要下载的文件哦~'); } let cnt = 0; let processed = temp.selectList.filter(f => !f.isdir).length; async function fetchFiles(dirs) { let files = []; for (let dir of dirs) { temp.doc.find('.loading-popup .loading-title').html(`文件获取中`); let url = `${config.$baidu.api.getFiles}&dir=${encodeURIComponent(dir.path)}&access_token=${accessToken}`; let res = await base.get(url, { "User-Agent": config.$baidu.api.ua.downloadLink }); cnt++; if (res?.list?.length && (res.errno === 0 || res.errmsg === "succ")) { let subFiles = res.list.filter(f => !f.isdir); processed += subFiles.length; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} 个文件~
${dir.path}
`); files = files.concat(subFiles); if (res.list.some(f => f.isdir)) { files = files.concat(await fetchFiles(res.list.filter(f => f.isdir))); } } if (cnt >= 50) { temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} 个文件~
休息 3 秒...
`); await base.sleep(3000); cnt = 0; } } return files; } let files = temp.selectList.filter(f => !f.isdir); if (temp.selectList.some(f => f.isdir)) { files = files.concat(await fetchFiles(temp.selectList.filter(f => f.isdir))); } if (!files.length) { return message.error('提示:
文件夹是空的哦~'); } temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取文件对应的下载链接~
`); let fidList = files.map(f => f.fs_id); let batchSize = 100; let linkList = []; for (let i = 0; i < fidList.length; i += batchSize) { let url = `${config.$baidu.api.getLink}&fsids=${encodeURIComponent(JSON.stringify(fidList.slice(i, i + batchSize)))}&access_token=${accessToken}`; let res = await base.get(url, { "User-Agent": config.$baidu.api.ua.downloadLink }); if (res?.list?.length && (res.errno === 0 || res.errmsg === "succ")) { linkList = linkList.concat(res.list); temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${linkList.length} / ${fidList.length} 个链接~
`); } else { if (res?.errno) { if (res.errno === 112) { return message.error('提示:
页面过期了,刷新重试下吧~
代码:' + res.errno); } if (res.errno === 9019) { base.delValue('baidu_access_token'); return message.error('提示:
访问令牌已过期,刷新网页后再获取一次吧~
代码:' + res.errno); } base.delValue('baidu_access_token'); return message.error('提示:
获取下载链接失败,刷新网页后再试试吧~
代码:' + res.errno); } else { return message.error('提示:
获取下载链接失败,刷新网页后再试试吧~'); } } await base.sleep(1000); } if (linkList.length) { let html = base.generateDom(linkList, { isFolder: v => v.isdir === 1, getFileName: v => (v.server_filename || v.filename), getFileSize: v => v.size, getFileLink: v => v.dlink, convert: { aria2: `--header "User-Agent:${config.$baidu.api.ua.downloadLink}" --header "Cookie:BDUSS=${BDUSS}"`, curl: `-A "${config.$baidu.api.ua.downloadLink}" -b "BDUSS=${BDUSS}"`, bitcomet: `cookie=${encodeURIComponent("BDUSS=" + BDUSS)}&user_agent=${encodeURIComponent(config.$baidu.api.ua.downloadLink)}` }, tooltip: config.$baidu.dom }); base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); } else { return message.error('提示:
获取下载链接失败,刷新网页后再试试吧~'); } } else { return message.error('提示:
页面错误~'); } }, getSelectedList() { let List, selectList try { List = require("system-core:context/context.js").instanceForSystem.list; selectList = List.getSelected(); /*if (!selectList.length){ selectList = List.getCurrentList(); }*/ return selectList; } catch (e) { } try { List = unsafeWindow.document.querySelector('.wp-s-core-pan'); if (List && List.__vue__.selectedList) { selectList = List.__vue__.selectedList; return selectList; } } catch (e) { } try { List = unsafeWindow.document.querySelector('.file-list'); if (List && List.__vue__.allFileList) { selectList = List.__vue__.allFileList.filter(function (item) { return !!item.selected; }); return selectList; } } catch (e) { } }, getLogid() { let ut = require("system-core:context/context.js").instanceForSystem.tools.baseService; return ut.base64Encode(base.getCookie("BAIDUID")); }, getShareData() { let res = unsafeWindow.locals.dump(); temp.shareParams.shareType = 'secret'; temp.shareParams.sign = ""; temp.shareParams.timestamp = ""; temp.shareParams.bdstoken = res.bdstoken.value; temp.shareParams.channel = 'chunlei'; temp.shareParams.clienttype = 0; temp.shareParams.web = 1; temp.shareParams.app_id = 250528; temp.shareParams.encrypt = 0; temp.shareParams.product = 'share'; temp.shareParams.logid = this.getLogid(); temp.shareParams.shareid = res.shareid.value; temp.shareParams.uk = res.share_uk.value; temp.shareParams.shareType === 'secret' && (temp.shareParams.extra = this._getExtra()); temp.shareParams.surl = this._getSurl(); }, detectPage() { let path = location.pathname; if (/^\/disk\/home/.test(path)) return 'home'; if (/^\/disk\/main/.test(path)) return 'main'; if (/^\/youth\/pan\/main/.test(path)) return 'youth'; if (/^\/(s|share)\//.test(path)) return 'share'; return ""; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); }, async initAuthorize() { base.registerMenuCommand(); Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, html: `请稍后`, willOpen: () => { Swal.showLoading(); }, }); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { let url = new URL(location.href); let auth = new URL(config.$baidu.api.getAccessToken); let allowedClientIds = [ auth.searchParams.get("client_id"), 'L6g70tBRRIXLsY0Z3HwKqlRE', // pcstest_oauth 'fSds3K4w43rw37tOqlQmTa2kDwaczK4U', // 小度智能词典笔专业版 'TFwtw8uwHxpdkvVqVKdIlx1XqXUnr1zG', // 印象笔记 '9dgBV9yesuBVOXaxls7aVHbLBLqU8yyg', // WPS文档 'l9DdBOG4RYroMscmzK5OChdaGelgd92M', // 小猴云印PC版 'Kyr013gHQBf2immy3fQt1jZ3nZVpiGAm', // 简单打印 'iYCeC9g08h5vuP9UqvPHKKSVrKFXGa1v', // Alist 'IlLqBbU3GjQ0t46TRwFateTprHWl39zF', // 百度手机助手 ]; // https://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id=&scope=basic,netdisk,mobile&display=page&redirect_uri= if ( /openapi.baidu.com\/oauth\/2.0\/authorize/.test(location.href) && url.searchParams.get("response_type").includes("token") && url.searchParams.get("scope").includes("netdisk") && allowedClientIds.includes(url.searchParams.get("client_id")) ) { let dialog = await Swal.fire({ icon: 'info', title: `提示`, html: `

(◍•ᴗ•◍) 你好呀,为了获取百度网盘文件的下载直链
“下载助手” 需要你的授权,以获取网盘文件的访问令牌


由于在百度 OAuth 页面使用了其他应用的 Client ID
所以显示的应用名称可能会有所不同,敬请理解


获取到的令牌仅用于调用百度官方 API 生成直链
不会用于其他用途,请放心授权

`, showConfirmButton: true, showDenyButton: true, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, confirmButtonText: ' 授权', denyButtonText: ' 再想想', position: 'center' }); if (dialog.isConfirmed) { base.waitForKeyElements("button#auth-allow", function (element) { element[0].click(); }, true) return; } if (dialog.isDenied) { return await Swal.fire({ icon: 'question', title: `好吧(* ̄3 ̄)╭`, html: '那就再想一想
想好了就按下 “授权” 按钮吧~', timer: 180000, toast: true, timerProgressBar: true, showConfirmButton: false, showDenyButton: false, position: 'bottom-end', }) } } else if (/openapi.baidu.com\/oauth\/2.0\/login_success/.test(location.href)) { let int = setInterval(async () => { if (location.href.includes('access_token') && (location.href.includes('basic+netdisk') || location.href.includes('basic,netdisk'))) { clearInterval(int) let token = location.href.match(/access_token=(.*?)&/)[1]; base.setValue('baidu_access_token', token); await Swal.fire({ icon: 'success', title: `成功啦`, html: '

(◍•ᴗ•◍) 您已成功授权/授权过脚本获取网盘访问令牌~

获取到的令牌仅用于调用百度官方 API 生成直链
不会用于其他用途

等待 / 秒之后将关闭此页面

', timer: 5000, timerProgressBar: true, showConfirmButton: true, showDenyButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, confirmButtonText: ` 关闭`, position: 'center', willOpen: () => { let secondSpan = document.getElementById("second"); let interval = setInterval(() => { if (Swal.isVisible()) { let timeLeft = Swal.getTimerLeft(); if (timeLeft !== null && timeLeft > 0) { secondSpan.textContent = (timeLeft / 1000).toFixed(1); } } else { clearInterval(interval); } }, 10); }, didOpen: function (toast) { toast.addEventListener('mouseenter', () => { Swal.stopTimer(); }); toast.addEventListener('mouseleave', () => { Swal.resumeTimer(); }); }, willClose: () => { window.close(); } }); return window.close(); } else { clearInterval(int) Swal.close() } }, 1) } else { Swal.close() } } else { Swal.close() } } }; /** * 阿里云盘 * @author 油小猴 * @author hmjz100 */ let $aliyun = { addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:阿里云盘'); if (window[key]) return; window[key] = true; temp.doc.on('click', '.pl-button-save', async function (e) { e.preventDefault(); let reactDomGrid = document.querySelector(config.$aliyun.mount.grid); if (reactDomGrid) { let dialog = await Swal.fire({ ...temp.swalDefault, title: '提示', html: '
请先切换到   列表视图  后再获取下载链接哦
', icon: 'info', showCloseButton: true, showDenyButton: true, confirmButtonText: ' 切换', denyButtonText: ' 不要', }); if (dialog.isConfirmed) { document.querySelector(config.$aliyun.mount.switch).click(); return message.success('提示:
切换为列表视图成功
请再获取一次下载链接吧~'); } return false; } temp.selectList = $aliyun.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要保存到网盘的文件哦~'); } message.info('提示:
因网盘限制,请保存到自己网盘后再去下载哦~'); await base.sleep(500); document.querySelector('[class*="btn-save--"]').click(); }); temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; let reactDomGrid = document.querySelector(config.$aliyun.mount.grid); if (reactDomGrid) { let dialog = await Swal.fire({ ...temp.swalDefault, title: '提示', html: '
请先切换到   列表视图  后再获取下载链接哦
', icon: 'info', showCloseButton: true, showDenyButton: true, confirmButtonText: ' 切换', denyButtonText: ' 不要', }); if (dialog.isConfirmed) { document.querySelector(config.$aliyun.mount.switch).click(); return message.success('提示:
切换为列表视图成功
请再获取一次下载链接吧~'); } return false; } $aliyun.getLink(); }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(e.currentTarget.dataset.link, { "Referer": `https://${location.host}/` }, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async () => { let prog = +temp.progress[index] || 0; let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename"), [`Referer:https://${location.host}/`]); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename"), { "referrer": `https://${location.host}/` }); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, greenerPage() { base.waitForKeyElements('[class*="share-list-banner"]', function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('[class*="to-app"]', function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('[class*="btn-mobile-save"]', function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('div[class*="text"]', function (tag) { if (tag[0].innerHTML.match("SVIP")) tag.fadeOut(); }, true); base.waitForKeyElements('[class*="SplashScreenImg--close"]', function (tag) { tag[0].click(); }, true); base.waitForKeyElements('[class*="container"]', function (tag) { tag.find('[class^="icon-close"]').click(); }, true); base.waitForKeyElements('[class*="popup_main_close"]', function (tag) { tag[0].click(); }, true); }, svg: ``, addButton() { base.waitForKeyElements(config.$aliyun.mount.home, (element) => { temp.pege = $aliyun.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
${$aliyun.svg}下载助手
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); element.append($button); }) base.waitForKeyElements(config.$aliyun.mount.share, (element) => { temp.pege = $aliyun.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(`
${$aliyun.svg}下载助手
  • 保存后下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.css({ 'margin-right': '10px', "height": "36px", "width": "auto", "padding": "1px 30px" }); element.prepend($button); }) }, addInitButton() { let $button = $(`
${$aliyun.svg}点我点亮
`); $button.click(() => { base.showInitDialog() }); base.waitForKeyElements(config.$aliyun.mount.home, (element) => { temp.pege = $aliyun.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; $button.css({ "width": "auto" }); element.append($button); }) base.waitForKeyElements(config.$aliyun.mount.share, (element) => { temp.pege = $aliyun.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; $button.css({ 'margin-right': '10px', "height": "36px", "padding": "1px 30px", "width": "auto" }); element.prepend($button); }) }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: () => { Swal.showLoading(); }, }); temp.selectList = this.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要下载的文件哦~'); } if (this.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } if (temp.pege === 'home') { temp.selectList = temp.selectList.filter(item => item.type === 'file') let batchSize = 15; let processed = 0; temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取文件对应的下载链接~
`); for (let i = 0; i < temp.selectList.length; i += batchSize) { // 当前批次文件 let batch = temp.selectList.slice(i, i + batchSize); // 过滤掉已有 URL 的文件 let noUrlSelectList = batch.filter(v => !Boolean(v.url)); let hasUrlSelectList = batch.filter(v => Boolean(v.url)); let queue = []; // 为没有 URL 的文件生成请求队列 noUrlSelectList.forEach((item) => { queue.push(this.getFileUrlByOnce(item.driveId, item.fileId) .then(val => { processed++; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); return val; })); }); hasUrlSelectList.forEach((item) => { processed++; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); }); // 等待本批次的请求结果 let res = await Promise.all(queue); res.forEach((val, index) => { noUrlSelectList[index].url = val; }); // 每次处理完一个批次后,等待 1 秒 await base.sleep(1000); } } else { return message.error('提示:
页面错误~'); } let html = base.generateDom(temp.selectList, { isFolder: v => v.type === 'folder', getFileName: v => v.name, getFileSize: v => v.size, getFileLink: v => (v.downloadUrl || v.url), convert: { aria2: `--header "Referer:https://${location.host}/"`, curl: `-e "https://${location.host}/"`, bitcomet: `&refer=${encodeURIComponent(`https://${location.host}/`)}` }, tooltip: config.$aliyun.dom }); base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); }, async getFileUrlByOnce(d, f) { let authorization = `${base.getStorage('token').token_type} ${base.getStorage('token').access_token}`; let res = await base.post(config.$aliyun.api.getLink, { drive_id: d, file_id: f }, { authorization, "content-type": "application/json;charset=utf-8", "referer": `https://${location.host}/`, "x-canary": "client=windows,app=adrive,version=v6.0.0" }); if (res.code === 'AccessTokenInvalid') { return message.error('提示:
访问令牌过期了,请刷新网页后再试'); } if (res.url) { return res.url; } return ""; }, getSelectedList() { try { let selectedList = []; let reactDom = document.querySelector(config.$aliyun.mount.list); let reactObj = base.findReact(reactDom, 1); let props = reactObj.pendingProps; if (props) { let fileList = props.dataSource || []; let selectedKeys = props.selectedKeys.split(','); fileList.forEach(function (val) { if (selectedKeys.includes(val.fileId)) { selectedList.push(val); } }); } return selectedList; } catch (e) { return []; } }, detectPage() { let path = location.pathname; if (/^\/(drive)/.test(path)) return 'home'; if (/^\/(s|share)\//.test(path)) return 'share'; return ""; }, isOnlyFolder() { for (let i = 0; i < temp.selectList.length; i++) { if (temp.selectList[i].type === 'file') return false; } return true; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); }, }; /** * 中国移动云盘 / 和彩云 * @author 油小猴 * @author hmjz100 */ let $mcloud = { addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:移动云盘'); if (window[key]) return; window[key] = true; temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; $mcloud.getLink(); }); temp.doc.on('click', '.pl-button-save', async function (e) { e.preventDefault(); temp.selectList = $mcloud.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要直接下载的文件哦~'); } if ($mcloud.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } message.info('提示:
因网盘限制,只能够通过页面直接下载哦~'); await base.sleep(500); document.querySelector('.btn-top.btn-top_dl').click(); }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(e.currentTarget.dataset.link, undefined, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async () => { let prog = +temp.progress[index] || 0; let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename")); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename")); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, greenerPage() { base.waitForKeyElements(".adv_swiper_menu", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".client-bubble", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".avs-box", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".top-adv-swiper", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".client_download_icon", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".document_top_memberCenter", function (tag) { $(tag[0]).click(function () { Swal.fire({ ...temp.swalDefault, html: ``, allowOutsideClick: false, showCloseButton: true, showConfirmButton: false, }); }); }, true); }, addButton() { base.waitForKeyElements(config.$mcloud.mount.home, (element) => { temp.pege = $mcloud.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
下载助手
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); element.prepend($button); }) base.waitForKeyElements(config.$mcloud.mount.share, (element) => { temp.pege = $mcloud.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(`
下载助手
  • 直接下载
  • 助手设置
  • 助手美化
  • 更新日志
`); element.prepend($button); }) }, addInitButton() { let $button = $(`
点我点亮
`); $button.click(() => { base.showInitDialog() }); base.waitForKeyElements(config.$mcloud.mount.home, (element) => { temp.pege = $mcloud.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; $button.addClass('mcloud-button'); element.prepend($button); }) base.waitForKeyElements(config.$mcloud.mount.share, (element) => { temp.pege = $mcloud.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; $button.addClass('mcloud-share-button').css({ "cursor": "pointer" }); element.prepend($button); }) }, getRandomString(len) { len = len || 16; let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; let maxPos = $chars.length; let pwd = ""; for (let i = 0; i < len; i++) { pwd += $chars.charAt(Math.floor(Math.random() * maxPos)); } return pwd; }, utob(str) { let u = String.fromCharCode; return str.replace(/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, function (t) { if (t.length < 2) { let e = t.charCodeAt(0); 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); } e = 65536 + 1024 * (t.charCodeAt(0) - 55296) + (t.charCodeAt(1) - 56320); return u(240 | e >>> 18 & 7) + u(128 | e >>> 12 & 63) + u(128 | e >>> 6 & 63) + u(128 | 63 & e); }); }, getSign(e, t, a, n) { let r = "", i = ""; if (t) { let s = Object.assign({}, t); i = JSON.stringify(s), i = i.replace(/\s*/g, ""), i = encodeURIComponent(i); let c = i.split(""), u = c.sort(); i = u.join(""); } let A = md5(base.encodeBase(this.utob(i))); let l = md5(a + ":" + n); return md5(A + l).toUpperCase(); }, async getFileUrlByOnce(item, index) { try { if (item.downloadUrl) return { index, downloadUrl: item.downloadUrl }; if (this.detectPage() === 'home') { let body = { fileId: item.contentID } let time = new Date(+new Date() + 8 * 3600 * 1000).toJSON().substr(0, 19).replace('T', ' '); let key = this.getRandomString(16); let sign = this.getSign(undefined, body, time, key); let res = await base.post(config.$mcloud.api.getLink, body, { 'Authorization': base.getCookie('authorization'), 'Caller': 'web', 'CMS-DEVICE': 'default', 'Content-Type': "application/json;charset=UTF-8", 'mcloud-channel': '1000101', 'mcloud-client': '10701', 'mcloud-sign': time + "," + key + "," + sign, 'mcloud-version': '7.14.2', 'Origin': 'https://yun.139.com', 'Referer': 'https://yun.139.com/', 'X-DeviceInfo': '||9|7.14.2|chrome|119.0.0.0|||windows 10||zh-CN|||', 'X-Huawei-ChannelSrc': '10000034', 'X-Inner-Ntwk': '2', 'X-M4C-Caller': 'PC', 'X-M4C-Src': '10002', 'X-SvcType': '1', 'X-Yun-Api-Version': 'v1', 'X-Yun-App-Channel': '10000034', 'X-Yun-Channel-Source': '10000034', 'X-Yun-Client-Info': '||9|7.14.2|chrome|119.0.0.0|||windows 10||zh-CN|||||', 'X-Yun-Module-Type': '100', 'X-Yun-Svc-Type': '1' }); if (res.success) { return { index, downloadUrl: res.data.url }; } else { return { index, downloadUrl: '获取下载地址失败,刷新后再试试吧~' }; } } if (this.detectPage() === 'share') { let vueDom = document.querySelector(".main_file_list").__vue__; let res = await base.post(config.$mcloud.api.getShareLink, `linkId=${vueDom.linkID}&contentIds=${item.path}&catalogIds=`, { 'Content-Type': 'application/x-www-form-urlencoded', }); if (res.code === 0) { return { index, downloadUrl: res.data.redrUrl }; } else { return { index, downloadUrl: '获取下载地址失败,刷新后再试试吧~' }; } } } catch (e) { return { index, downloadUrl: '获取下载地址失败,刷新后再试试吧~' }; } }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: function () { Swal.showLoading(); }, }); temp.selectList = this.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要下载的文件哦~'); } if (this.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } if (temp.pege === 'home') { temp.selectList = temp.selectList.filter(item => item.contentID && item.contentName && item.contentSuffix); let batchSize = 15; let processed = 0; temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取文件对应的下载链接~
`); for (let i = 0; i < temp.selectList.length; i += batchSize) { let batch = temp.selectList.slice(i, i + batchSize); let queue = []; batch.forEach((item, localIndex) => { let globalIndex = i + localIndex; queue.push(this.getFileUrlByOnce(item, globalIndex) .then(val => { processed++; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); return val; })); }); let res = await Promise.all(queue); res.forEach(val => { temp.selectList[val.index].downloadUrl = val.downloadUrl; }); await base.sleep(1000); } } else { return message.error('提示:
页面错误~'); } let html = base.generateDom(temp.selectList, { isFolder: v => (v.dirEtag || v.caName), getFileName: v => (v.contentName || v.coName), getFileSize: v => (v.contentSize || v.coSize), getFileLink: v => v.downloadUrl, tooltip: config.$mcloud.dom }); base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); }, getSelectedList() { try { return document.querySelector(".main_file_list").__vue__.selectList.map(val => val.item); } catch (e) { let vueDom = document.querySelector(".home-page").__vue__; let fileList = vueDom._computedWatchers.fileList.value; let dirList = vueDom._computedWatchers.dirList.value; let selectedFileIndex = vueDom.selectedFile; let selectedDirIndex = vueDom.selectedDir; let selectFileList = fileList.filter((v, i) => { return selectedFileIndex.includes(i); }); let selectDirList = dirList.filter((v, i) => { return selectedDirIndex.includes(i); }); return [...selectFileList, ...selectDirList]; } }, detectPage() { let path = location.pathname; if (/^\/w/.test(path)) return 'home'; if (/^\/link|shareweb/.test(path)) return 'share'; return ""; }, isOnlyFolder() { for (let i = 0; i < temp.selectList.length; i++) { if (temp.selectList[i].contentID || temp.selectList[i].contentName) return false; } return true; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); }, }; /** * 天翼云盘 * @author 油小猴 * @author hmjz100 */ let $tcloud = { addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:天翼云盘'); if (window[key]) return; window[key] = true; temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; $tcloud.getLink(); }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(e.currentTarget.dataset.link, undefined, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async function () { let prog = +temp.progress[index] || 0; let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename")); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename")); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, greenerPage() { base.waitForKeyElements(".advertising-mask", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements("a.client-download.nav-block", function (tag) { tag.fadeOut(); }, true); }, addButton() { let $button = $(`
下载助手 
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.find(".pl-dropdown-menu").css({ 'position': 'absolute', 'left': '-1px' }) base.waitForKeyElements(config.$tcloud.mount.home, (element) => { temp.pege = $tcloud.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; $button.find(".pl-dropdown-menu").css({ 'top': '28px' }) element.prepend($button); }) base.waitForKeyElements(config.$tcloud.mount.share, (element) => { temp.pege = $tcloud.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; $button.css({ 'height': '28px', 'border-radius': '15px' }) $button.find(".pl-dropdown-menu").css({ 'top': '25px' }) element.prepend($button); }) }, addInitButton() { let $button = $(`
点我点亮
`); $button.click(() => { base.showInitDialog() }); base.waitForKeyElements(config.$tcloud.mount.home, (element) => { temp.pege = $tcloud.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; element.prepend($button); }) base.waitForKeyElements(config.$tcloud.mount.share, (element) => { temp.pege = $tcloud.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; $button.css({ 'height': '28px', 'border-radius': '15px' }) element.prepend($button); }) }, async getToken() { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取状态~
`); let res = await base.getFinalUrl(config.$tcloud.api.getAccessToken, undefined, true); let accessToken = res.match(/accessToken=(\w+)/)?.[1]; accessToken && base.setStorage('accessToken', accessToken); temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
获取成功,令牌已缓存~
`); return accessToken; }, async getFileUrlByOnce(item, index, token) { try { if (item.downloadUrl) { return { index, downloadUrl: item.downloadUrl } }; let time = Date.now(), fileId = item.fileId, o = "AccessToken=" + token + "&Timestamp=" + time + "&fileId=" + fileId, url = config.$tcloud.api.getLink + '?fileId=' + fileId; if (item.shareId) { o = "AccessToken=" + token + "&Timestamp=" + time + "&dt=1&fileId=" + fileId + "&shareId=" + item.shareId; url += '&dt=1&shareId=' + item.shareId; } let sign = md5(o).toString(); let res = await base.get(url, { "accept": "application/json;charset=UTF-8", "sign-type": 1, "accesstoken": token, "timestamp": time, "signature": sign }); if (res.res_code === 0) { return { index, downloadUrl: res.fileDownloadUrl }; } else if (res.errorCode === 'InvalidSessionKey') { return { index, downloadUrl: '提示:
请先登录网盘~' }; } else if (res.res_code === 'ShareNotFoundFlatDir') { return { index, downloadUrl: '提示:
请[转存]文件,之后再👉前往[我的网盘]中下载哦~' }; } else { return { index, downloadUrl: '获取下载地址失败,刷新后再试试吧~' + (res.res_code ? res.res_code : "") }; } } catch (e) { return { index, downloadUrl: '获取下载地址失败,刷新后再试试吧~' }; } }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: function () { Swal.showLoading(); }, }); temp.selectList = this.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要下载的文件哦~'); } if (this.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } temp.selectList = temp.selectList.filter(item => !item.isFolder) temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取状态~
`); let token = base.getStorage('accessToken') || await this.getToken(); if (!token) { return message.error('提示:
请先登录网盘~'); } temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
获取缓存成功~
`); let batchSize = 15; let processed = 0; temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取文件对应的下载链接~
`); for (let i = 0; i < temp.selectList.length; i += batchSize) { let batch = temp.selectList.slice(i, i + batchSize); let queue = []; batch.forEach((item, localIndex) => { let globalIndex = i + localIndex; queue.push(this.getFileUrlByOnce(item, globalIndex, token) .then(val => { processed++; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); return val; })); }); let res = await Promise.all(queue); res.forEach(val => { temp.selectList[val.index].downloadUrl = val.downloadUrl; }); await base.sleep(1000); } let html = base.generateDom(temp.selectList, { isFolder: v => v.isFolder, getFileName: v => v.fileName, getFileSize: v => v.size, getFileLink: v => v.downloadUrl, tooltip: config.$mcloud.dom }); base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); }, getSelectedList() { try { return document.querySelector(".c-file-list").__vue__.selectedList; } catch (e) { return [document.querySelector(".info-detail").__vue__.fileDetail]; } }, detectPage() { let path = location.pathname; if (/^\/web\/main/.test(path)) return 'home'; if (/^\/web\/share/.test(path)) return 'share'; return ""; }, isOnlyFolder() { for (let i = 0; i < temp.selectList.length; i++) { if (!temp.selectList[i].isFolder) return false; } return true; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); this.getToken(); }, }; /** * 迅雷云盘 * @author 油小猴 * @author hmjz100 */ let $xunlei = { addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:迅雷云盘'); if (window[key]) return; window[key] = true; temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; $xunlei.getLink(); }); temp.doc.on('click', '.pl-button-save', async function (e) { e.preventDefault(); temp.selectList = $xunlei.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要保存到网盘的文件哦~'); } message.info('提示:
因网盘限制,请保存到自己网盘后再去下载哦~'); await base.sleep(500); document.querySelector('.saveToCloud').click(); }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(e.currentTarget.dataset.link, undefined, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async function () { let prog = +temp.progress[index] || 0; let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename")); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename"), { "mirror_url_list": base.getMirrorList(target.data("link"), config.$xunlei.api.mirror), "checkboxCustomHeadersForMirrors": "on" }); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, addButton() { base.waitForKeyElements(config.$xunlei.mount.home, (element) => { temp.pege = $xunlei.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
下载助手
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); element.prepend($button); }) base.waitForKeyElements(config.$xunlei.mount.share, (element) => { temp.pege = $xunlei.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(`
下载助手
  • 转存后下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.css({ 'margin-right': '10px' }); element.prepend($button); }) }, addInitButton() { let $button = $(`
点我点亮
`); $button.click(() => { base.showInitDialog() }); base.waitForKeyElements(config.$xunlei.mount.home, (element) => { temp.pege = $xunlei.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; element.prepend($button); }) base.waitForKeyElements(config.$xunlei.mount.share, (element) => { temp.pege = $xunlei.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; $button.css({ 'margin-right': '10px' }); element.prepend($button); }) }, getToken() { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取状态~
`); let credentials = {}, captcha = {}; for (let i = 0; i < localStorage.length; i++) { if (/^credentials_/.test(localStorage.key(i))) { credentials = base.getStorage(localStorage.key(i)); base.setStorage(""); } if (/^captcha_[\w]{16}/.test(localStorage.key(i))) { captcha = base.getStorage(localStorage.key(i)); } } let deviceid = /(\w{32})/.exec(base.getStorage('deviceid').split(','))[0]; let token = { credentials, captcha, deviceid }; return token; }, async getFileUrlByOnce(item, index, token) { try { if (item.downloadUrl) return { index, downloadUrl: item.downloadUrl }; let res = await base.get(config.$xunlei.api.getLink + item.id, { 'Authorization': `${token.credentials.token_type} ${token.credentials.access_token}`, 'content-type': "application/json", 'x-captcha-token': token.captcha.token, 'x-device-id': token.deviceid, }); if (res.web_content_link) { return { index, downloadUrl: res.web_content_link }; } else { return { index, downloadUrl: '获取下载地址失败,刷新后再试试吧~' }; } } catch (e) { return message.error('提示:
请先登录网盘后再刷新页面呢~'); } }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: function () { Swal.showLoading(); }, }); temp.selectList = this.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要下载的文件哦~'); } if (this.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } if (temp.pege === 'home') { let token = this.getToken(); let batchSize = 15; let processed = 0; temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取文件对应的下载链接~
`); for (let i = 0; i < temp.selectList.length; i += batchSize) { let batch = temp.selectList.slice(i, i + batchSize); let queue = []; batch.forEach((item, localIndex) => { let globalIndex = i + localIndex; queue.push(this.getFileUrlByOnce(item, globalIndex, token) .then(val => { processed++; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); return val; })); }); let res = await Promise.all(queue); res.forEach(val => { temp.selectList[val.index].downloadUrl = val.downloadUrl; }); await base.sleep(1000); } } else { return message.error('提示:
页面错误~'); } let html = base.generateDom(temp.selectList, { isFolder: v => v.kind === 'drive#folder', getFileName: v => v.name, getFileSize: v => v.size, getFileLink: v => v.downloadUrl, getFileMirror: v => base.getMirrorList(v, config.$xunlei.api.mirror), tooltip: config.$xunlei.dom }); base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); }, getSelectedList() { try { let doms = document.querySelectorAll('.SourceListItem__item--XxpOC'); let selectedList = []; for (let dom of doms) { let domVue = dom.__vue__; if (domVue.selected.includes(domVue.info.id)) { selectedList.push(domVue.info); } } return selectedList; } catch (e) { return []; } }, detectPage() { let path = location.pathname; if (/^\/$/.test(path)) return 'home'; if (/^\/(s|share)\//.test(path)) return 'share'; return ""; }, isOnlyFolder() { for (let i = 0; i < temp.selectList.length; i++) { if (temp.selectList[i].kind === 'drive#file') return false; } return true; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); }, }; /** * 夸克网盘 * @author 油小猴 * @author hmjz100 */ let $quark = { addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:夸克网盘'); if (window[key]) return; window[key] = true; temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; $quark.getLink(); }); temp.doc.on('click', '.pl-button-save', async function (e) { e.preventDefault(); temp.selectList = $quark.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要保存到网盘的文件哦~'); } message.info('提示:
因网盘限制,请保存到自己网盘后再去下载哦~'); await base.sleep(500); document.querySelector('.share-path').click(); base.waitForKeyElements(".btn-file.btn-file-primary.confirm-btn", (element) => { element.one("click", async () => { await base.sleep(1000); document.querySelector('.share-save').click(); }) return true; }, true) }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(e.currentTarget.dataset.link, undefined, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async function () { let prog = +temp.progress[index] || 0; let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename"), [`Cookie:${document.cookie}`]); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename"), { "cookie": document.cookie }); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, greenerPage() { base.waitForKeyElements('[class*="Activity--video-toolbar-activity"]', function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('span[class*="SectionHeaderController--icon-download"]', function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('div[class*="SectionHeaderController--download-popover"]', function (tag) { tag.find(".ant-popover-arrow").css({ "left": "75%" }); }, true); base.waitForKeyElements('div[class*="DetailLayout--client-download"]', function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".next-box.share-right-side-content", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('[class*="DetailLayout--container"] .feature-screen', function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements('.ant-modal-content .ant-modal-body .right-wrap', function (tag) { if (tag.find(".hint").text().includes("客户端")) tag.fadeOut(); }, true); base.waitForKeyElements(".pc-member-entrance span.button-text", function (tag) { tag.text("会员中心"); let observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (tag.text() === "会员中心") return tag.text("会员中心"); }); }); let config = { subtree: true, characterData: true, childList: true }; observer.observe(tag[0], config); }, true); base.waitForKeyElements(".pc-member-entrance .tips", function (tag) { tag.fadeOut(); }, true); base.waitForKeyElements(".modal .modal-content .halo-animated-background .halo-content .pay-modal .close", function (tag) { tag[0].click(); }, true); base.waitForKeyElements(".modal .modal-content .halo-animated-background .halo-content .red-envelope .close", function (tag) { tag[0].click(); }, true); }, svg: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMiI+PHBhdGggc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJNOSAxMmwyIDIgMi0yeiIvPjxwYXRoIGQ9Ik0xNCA4aDEuNTUzYy44NSAwIDEuMTYuMDkzIDEuNDcuMjY3LjMxMS4xNzQuNTU2LjQzLjcyMi43NTYuMTY2LjMyNi4yNTUuNjUuMjU1IDEuNTR2NC44NzNjMCAuODkyLS4wODkgMS4yMTUtLjI1NSAxLjU0LS4xNjYuMzI3LS40MS41ODMtLjcyMi43NTctLjMxLjE3NC0uNjIuMjY3LTEuNDcuMjY3SDYuNDQ3Yy0uODUgMC0xLjE2LS4wOTMtMS40Ny0uMjY3YTEuNzc4IDEuNzc4IDAgMDEtLjcyMi0uNzU2Yy0uMTY2LS4zMjYtLjI1NS0uNjUtLjI1NS0xLjU0di00Ljg3M2MwLS44OTIuMDg5LTEuMjE1LjI1NS0xLjU0LjE2Ni0uMzI3LjQxLS41ODMuNzIyLS43NTcuMzEtLjE3NC42Mi0uMjY3IDEuNDctLjI2N0gxMSIvPjxwYXRoIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0iTTExIDN2MTAiLz48L2c+PC9zdmc+', addButton() { base.waitForKeyElements(config.$quark.mount.home, (element) => { temp.pege = $quark.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.css({ "margin-right": "10px", "display": "inline-block" }); element.prepend($button); }) base.waitForKeyElements(config.$quark.mount.share, (element) => { temp.pege = $quark.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(``); $button.css({ "height": "36px", "margin-left": "16px", "border-radius": "6px", "display": "inline-block" }); element.append($button); }) }, addInitButton() { base.waitForKeyElements(config.$quark.mount.home, (element) => { temp.pege = $quark.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
`); $button.css({ "margin-right": "10px", "display": "inline-block" }); $button.click(() => { base.showInitDialog() }); element.prepend($button); }) base.waitForKeyElements(config.$quark.mount.share, (element) => { temp.pege = $quark.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(``); $button.css({ "height": "36px", "margin-left": "16px", "border-radius": "6px", "display": "inline-block" }); $button.click(() => { base.showInitDialog() }); element.append($button); }) }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: function () { Swal.showLoading(); }, }); temp.selectList = this.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要下载的文件哦~'); } if (this.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } if (temp.pege === 'home') { let data = []; let batchSize = 15; let processed = 0; temp.selectList = temp.selectList.filter(item => item.file === true) for (let i = 0; i < temp.selectList.length; i += batchSize) { // 获取当前批次文件 let batch = temp.selectList.slice(i, i + batchSize); let fids = batch.map(item => item.fid); // 发起请求获取链接 let res = await base.post(config.$quark.api.getLink, { "fids": fids }, { "content-type": "application/json;charset=utf-8", "user-agent": config.$quark.api.ua.downloadLink }); if (res?.code === 31001) { return message.error('提示:
请先登录网盘~
代码:' + res.code); } if (res?.code !== 0) { return message.error('提示:
获取链接失败了~
代码:' + res.code); } // 合并响应数据 if (res?.data) { data.push(...res.data); } // 更新处理进度 processed += batch.length; // 更新UI显示 temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); // 请求间隔节流 await base.sleep(1000); } let html = base.generateDom(data, { isFolder: v => v.file === false, getFileName: v => v.file_name, getFileSize: v => v.size, getFileLink: v => v.download_url, convert: { aria2: `--header "Cookie:${document.cookie}"`, curl: `-b "${document.cookie}"`, bitcomet: `cookie=${encodeURIComponent(document.cookie)}` }, tooltip: config.$quark.dom }); base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); } else { return message.error('提示:
页面错误~'); } }, getSelectedList() { try { let selectedList = []; let reactDom = document.getElementsByClassName('file-list')[0]; let reactObj = base.findReact(reactDom); let props = reactObj.props; if (props) { let fileList = props.list || []; let selectedKeys = props.selectedRowKeys || []; fileList.forEach(function (val) { if (selectedKeys.includes(val.fid)) { selectedList.push(val); } }); } return selectedList; } catch (e) { return []; } }, detectPage() { let path = location.pathname; if (/^\/(list)/.test(path)) return 'home'; if (/^\/(s|share)\//.test(path)) return 'share'; return ""; }, isOnlyFolder() { for (let i = 0; i < temp.selectList.length; i++) { if (temp.selectList[i].file) return false; } return true; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); }, }; /** * UC网盘 * @author 油小猴 * @author hmjz100 */ let $uc = { addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:UC网盘'); if (window[key]) return; window[key] = true; temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; $uc.getLink(); }); temp.doc.on('click', '.pl-button-save', async function (e) { e.preventDefault(); temp.selectList = $uc.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要保存到网盘的文件哦~'); } message.info('提示:
因网盘限制,请保存到自己网盘后再去下载哦~'); await base.sleep(500); document.querySelector('.file-info_r').click(); }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(e.currentTarget.dataset.link, undefined, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async function () { let prog = +temp.progress[index] || 0; let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename"), [`Cookie:${document.cookie}`]); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename"), { "cookie": document.cookie }); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, greenerPage() { base.waitForKeyElements('[class*="VideoDetail--content-footer"]', function (tag) { tag.children().each(function () { let $child = $(this); if ($child.text().includes('手机客户端')) { $child.hide(); } }); }, true); base.waitForKeyElements('[class*="PCLandingBanner--ad-block"]', function (tag) { tag.hide(); }, true); }, svg: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMiI+PHBhdGggc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJNOSAxMmwyIDIgMi0yeiIvPjxwYXRoIGQ9Ik0xNCA4aDEuNTUzYy44NSAwIDEuMTYuMDkzIDEuNDcuMjY3LjMxMS4xNzQuNTU2LjQzLjcyMi43NTYuMTY2LjMyNi4yNTUuNjUuMjU1IDEuNTR2NC44NzNjMCAuODkyLS4wODkgMS4yMTUtLjI1NSAxLjU0LS4xNjYuMzI3LS40MS41ODMtLjcyMi43NTctLjMxLjE3NC0uNjIuMjY3LTEuNDcuMjY3SDYuNDQ3Yy0uODUgMC0xLjE2LS4wOTMtMS40Ny0uMjY3YTEuNzc4IDEuNzc4IDAgMDEtLjcyMi0uNzU2Yy0uMTY2LS4zMjYtLjI1NS0uNjUtLjI1NS0xLjU0di00Ljg3M2MwLS44OTIuMDg5LTEuMjE1LjI1NS0xLjU0LjE2Ni0uMzI3LjQxLS41ODMuNzIyLS43NTcuMzEtLjE3NC42Mi0uMjY3IDEuNDctLjI2N0gxMSIvPjxwYXRoIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0iTTExIDN2MTAiLz48L2c+PC9zdmc+', addButton() { base.waitForKeyElements(config.$uc.mount.home, (element) => { temp.pege = $uc.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.css({ "margin-right": "10px", "display": "inline-block" }); element.prepend($button); }) base.waitForKeyElements(config.$uc.mount.share, (element) => { temp.pege = $uc.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(`
  • 保存后下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.css({ "margin-left": "10px", "display": "inline-block" }); element.append($button); }) }, addInitButton() { let $button = $(`
`); $button.click(() => { base.showInitDialog() }); base.waitForKeyElements(config.$uc.mount.home, (element) => { temp.pege = $uc.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; $button.css({ "margin-right": "10px", "display": "inline-block" }); element.prepend($button); }) base.waitForKeyElements(config.$uc.mount.share, (element) => { temp.pege = $uc.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; $button.css({ "margin-left": "10px", "display": "inline-block" }); element.append($button); }) }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: function () { Swal.showLoading(); }, }); temp.selectList = this.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要下载的文件哦~'); } if (this.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } if (temp.pege === 'home') { let data = []; let batchSize = 15; let processed = 0; temp.selectList = temp.selectList.filter(item => item.file === true) for (let i = 0; i < temp.selectList.length; i += batchSize) { // 获取当前批次文件 let batch = temp.selectList.slice(i, i + batchSize); let fids = batch.map(item => item.fid); // 发起请求获取链接 let res = await base.post(config.$uc.api.getLink, { "fids": fids }, { "content-type": "application/json;charset=utf-8", "user-agent": config.$uc.api.ua.downloadLink }); if (res?.code === 31001) { return message.error('提示:
请先登录网盘~
代码:' + res.code); } if (res?.code !== 0) { return message.error('提示:
获取链接失败了~
代码:' + res.code); } // 合并响应数据 if (res?.data) { data.push(...res.data); } // 更新处理进度 processed += batch.length; // 更新UI显示 temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); // 请求间隔节流 await base.sleep(1000); } let html = base.generateDom(data, { isFolder: v => v.file === false, getFileName: v => v.file_name, getFileSize: v => v.size, getFileLink: v => v.download_url, convert: { aria2: `--header "Cookie:${document.cookie}"`, curl: `-b "${document.cookie}"`, bitcomet: `cookie=${encodeURIComponent(document.cookie)}` }, tooltip: config.$uc.dom }); base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); } else { return message.error('提示:
页面错误~'); } }, getSelectedList() { try { let selectedList = []; let reactDom = document.getElementsByClassName('file-list')[0]; let reactObj = base.findReact(reactDom); let props = reactObj.props; if (props) { let fileList = props.list || []; let selectedKeys = props.selectedRowKeys || []; fileList.forEach(function (val) { if (selectedKeys.includes(val.fid)) { selectedList.push(val); } }); } return selectedList; } catch (e) { return []; } }, detectPage() { let path = location.pathname; if (/^\/(list)/.test(path)) return 'home'; if (/^\/(s|share)\//.test(path)) return 'share'; return ""; }, isOnlyFolder() { for (let i = 0; i < temp.selectList.length; i++) { if (temp.selectList[i].file) return false; } return true; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); }, }; /** * 123云盘 * @author 油小猴 * @author hmjz100 */ let $123pan = { addPageListener() { /* 防止代码因其他原因被执行多次 这段代码出自 Via轻插件,作者谷花泰 */ let key = encodeURIComponent('LinkSwift:123云盘'); if (window[key]) return; window[key] = true; temp.doc.on('click', '.pl-button-mode', async function (e) { temp.mode = e.currentTarget.dataset.mode; if (!temp.mode) return; $123pan.getLink(); }); temp.doc.on('click', '.listener-api-download.enhance', async function (e) { e.preventDefault(); let o = base._EventFactory(e); let $width = o.item.find('.pl-progress-inner'); let $text = o.item.find('.pl-progress-inner-text'); let filename = o.link[0].dataset.filename; let index = o.link[0].dataset.index; let size = Number(o.link[0].dataset.size) || 0; let originalHtml = o.link.html(); base._resetData(index); base.get(e.currentTarget.dataset.link, undefined, 'blob', { filename, index }); let startTime = Date.now(); let prevLoaded = 0; let prevTime = startTime; temp.ins[index] = setInterval(async function () { let prog = +temp.progress[index] || 0; let currentTime = Date.now(); let elapsedTime = currentTime - startTime; let loaded = prog * size / 100; let timeDiff = Math.max(currentTime - prevTime, 1); // 避免除零 let speed = ((loaded - prevLoaded) / (timeDiff / 1000)) || 0; // 计算剩余时间(保护除零) let totalProgress = Math.max(prog / 100, 0.01); let totalElapsedSeconds = elapsedTime / 1000; let estTotalTime = totalElapsedSeconds / totalProgress; let remainingTime = estTotalTime - totalElapsedSeconds; // 更新界面状态 o.link.hide(); o.directLink.hide(); o.tip.hide(); o.stop.show(); o.copy.hide(); o.progress.show(); // 更新进度条 $width.css('width', `${prog}%`); $text.text(`${prog.toFixed(1)}% | 速度:${base.sizeFormat(speed)} | 剩余:${base.rtimeFormat(remainingTime)}`); // 更新历史值 prevLoaded = loaded; prevTime = currentTime; // 下载完成 if (prog >= 100) { await base.sleep(1000); clearInterval(temp.ins[index]); temp.progress[index] = 0; o.item.find('.pl-progress-stop').hide(); $text.text('下载完成~ 浏览器下载框应该弹出来了哦~'); o.back.show(); await base.sleep(3000); o.link.html(originalHtml).animate({ opacity: '1' }, "slow"); } }, 500); }); temp.doc.on('click', '.listener-aria2-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToAria2(target.data("link"), target.data("filename")); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); temp.doc.on('click', '.listener-bitcomet-download', async function (e) { let target = $(e.currentTarget); if (target.attr('data-processing') === 'true') return; target.attr('data-processing', 'true'); let originalHtml = target.html(); target.find(".pl-icon").remove(); target.find('.pl-loading').remove(); target.prepend(base.createLoading()); let res = await base.sendLinkToBitcomet(target.data("link"), target.data("filename")); if (res === 'success') { target.removeClass('pl-btn-danger').html('发送成功啦!快去看看吧~').animate({ opacity: '0.5' }, "slow"); } else { target.addClass('pl-btn-danger').text('发送失败,检查一下您的配置信息哦!').animate({ opacity: '0.5' }, "slow"); } await base.sleep(3000); target.removeClass('pl-btn-danger').removeAttr('data-processing').html(originalHtml).css('opacity', ""); }); }, greenerPage() { base.waitForKeyElements(".new-menu-item-image, .special-menu-item-container-migration--label, .sider-member-btn, .video-new-user-tips", (tag) => { if (tag.is(":hidden")) return; tag.hide(); }, true) let allowedTexts = ["其他网盘数据转入", "同步空间", "回收站", "下载客户端"]; base.waitForKeyElements(`.ant-menu.ant-menu-root.ant-menu-inline[role="menu"]`, (tag) => { tag.find(`[role="menuitem"]`).each(function () { let menuText = $(this).text().trim(); if (!allowedTexts.includes(menuText) || $(this).is(":hidden")) return; $(this).hide(); }); }, true) base.waitForKeyElements(".special-menu-item-container", (tag) => { tag.find(".special-menu-item-container-migration").each(function () { let menuText = $(this).text().trim(); if (!allowedTexts.includes(menuText) || $(this).is(":hidden")) return; $(this).hide(); }); }, true) base.waitForKeyElements(`.header-btn-list > .btn-item`, (tag) => { let menuText = tag.text().trim(); if (menuText === "消息" && tag.next().text().trim() !== "公告") { let notice = tag.clone(true); notice.find('.item-text').html("公告"); notice.on('click', (event) => { GM_openInTab('https://www.123pan.com/Notice', { active: true }); }); tag.after(notice); } if (!allowedTexts.includes(menuText) || tag.is(":hidden")) return; tag.hide(); }, true) base.waitForKeyElements(`.rightInfo .register:not(.pl-button, .pl-button-init), .homeClass > div > .ant-dropdown-trigger:not(.pl-button, .pl-button-init), .homeClass > div > .sysbut`, function (tag) { let hasTextNode = false; tag.contents().each(function () { if (this.nodeType === 3 && $.trim(this.textContent)) { hasTextNode = true; return; } }); if (!hasTextNode) return; tag.css({ "width": "38px" }); tag.contents().each(function () { if (this.nodeType === 3) { $(this).remove(); } }); tag.find('svg').css({ "margin-right": "0" }); }); base.waitForKeyElements('.rightInfo .qrcode_btn', function (tag) { tag.hide(); }, true); }, getToken() { temp.doc.find('.loading-popup .loading-title').html(`令牌获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取令牌~
`); let token = base.getStorage("authorToken"); return token; }, async getLink() { Swal.fire({ ...temp.swalDefault, showConfirmButton: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, title: "获取中", html: `...`, footer: "如果选的文件较多,请耐心等待获取完成哦!", customClass: { popup: 'loading-popup', header: 'loading-header', title: 'loading-title', content: 'loading-content', input: 'loading-input', footer: 'loading-footer' }, willOpen: function () { Swal.showLoading(); }, }); temp.selectList = this.getSelectedList(); if (temp.selectList.length === 0) { return message.error('提示:
请勾选要下载的文件哦~'); } if (this.isOnlyFolder()) { return message.error('提示:
请打开文件夹后再勾选文件~'); } if (temp.pege === 'home') { let token = this.getToken(); let batchSize = 15; let processed = 0; temp.selectList = temp.selectList.filter(item => item.Type === 0); for (let i = 0; i < temp.selectList.length; i += batchSize) { let batch = temp.selectList.slice(i, i + batchSize); let queue = []; temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取文件对应的下载链接~
`); batch.forEach((item, localIndex) => { let globalIndex = i + localIndex; queue.push(this.getFileUrlByOnce(item, globalIndex, token) .then(val => { processed++; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); return val; })); }); let res = await Promise.all(queue); res.forEach(val => { temp.selectList[val.index].DownloadUrl = val.downloadUrl; }); await base.sleep(1000); } let html = base.generateDom(temp.selectList, { isFolder: v => v.Type !== 0, getFileName: v => v.FileName, getFileSize: v => v.Size, getFileLink: v => v.DownloadUrl || v.DownloadURL, tooltip: config.$123pan.dom }) base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); } else if (temp.pege === 'share') { let token = this.getToken(); let batchSize = 15; let processed = 0; temp.selectList = temp.selectList.filter(item => item.Type === 0); let pathSplit = location.pathname.split('/').filter(Boolean); let ShareKey = pathSplit[1]; for (let i = 0; i < temp.selectList.length; i += batchSize) { let batch = temp.selectList.slice(i, i + batchSize); let queue = []; temp.doc.find('.loading-popup .loading-title').html(`链接获取中`); temp.doc.find('.loading-popup .swal2-html-container').html(`
正在获取文件对应的下载链接~
`); batch.forEach((item, localIndex) => { let globalIndex = i + localIndex; queue.push(this.getFileUrlByOnce(item, globalIndex, token, ShareKey) .then(val => { processed++; temp.doc.find('.loading-popup .swal2-html-container').html(`
已获取 ${processed} / ${temp.selectList.length} 个链接~
`); return val; })); }); let res = await Promise.all(queue); res.forEach(val => { temp.selectList[val.index].DownloadUrl = val.downloadUrl; }); await base.sleep(1000); } let html = base.generateDom(temp.selectList, { isFolder: v => v.Type !== 0, getFileName: v => v.FileName, getFileSize: v => v.Size, getFileLink: v => v.DownloadUrl || v.DownloadURL, tooltip: config.$123pan.dom }) base.showMainDialog(config.base.dom.button[temp.mode].title, html, config.base.dom.button[temp.mode].footer); } else { return message.error('提示:
页面错误~'); } }, async getFileUrlByOnce(item, index, token, ShareKey) { if (item.DownloadUrl) return { index, downloadUrl: item.DownloadUrl }; let res = null; if (ShareKey) { res = await base.post(config.$123pan.api.getShareLink, { "ShareKey": ShareKey, "FileID": item.FileId, "S3keyFlag": item.S3KeyFlag, "Size": item.Size, "Etag": item.Etag }, { "content-type": "application/json;charset=utf-8", "authorization": `Bearer ${token}`, "platform": "ios" }); } else { res = await base.post(config.$123pan.api.getLink, { "driveId": 0, "etag": item.Etag, "fileId": item.FileId, "s3keyFlag": item.S3KeyFlag, "type": item.Type, "fileName": item.FileName, "size": item.Size }, { "content-type": "application/json;charset=utf-8", "authorization": `Bearer ${token}`, "platform": "ios" }); } if (res.data?.DownloadUrl) { let url = res.data.DownloadUrl; let surl = new URL(url).searchParams.get("params"); if (surl) url = base.decodeBase(surl); url = await base.getFinalUrl(url); return { index, downloadUrl: url }; } else if (res.data?.DownloadURL) { let url = res.data.DownloadURL; let surl = new URL(url).searchParams.get("params"); if (surl) url = base.decodeBase(surl); url = await base.getFinalUrl(url); return { index, downloadUrl: url }; } else if (res?.code === 5112) { return message.error('提示:
请先登录网盘后再获取链接呢~'); } else { return { index, downloadUrl: '获取下载地址失败,刷新后再试试吧~' }; } }, getSelectedList() { try { let selectedList = []; let reactDom = $(".ant-table-body, .tiled-list-content, .file-list")[0]; let reactObj = base.findReact(reactDom); let props = reactObj.memoizedProps; if (props) { let fileList = props?.props?.data || props?.loadedFileList || props?.files || []; fileList.forEach(function (val) { if (val?.checked === true) { selectedList.push(val); } }); } return selectedList; } catch (e) { return []; } }, isOnlyFolder() { for (let i = 0; i < temp.selectList.length; i++) { if (temp.selectList[i].Type === 0) return false; } return true; }, addButton() { base.waitForKeyElements(config.$123pan.mount.home, (element) => { element = element.parent(); temp.pege = $123pan.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
下载助手
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.css({ "margin-right": "22px", "width": "110px" }) element.prepend($button); }) base.waitForKeyElements(config.$123pan.mount.share, (element) => { element = element.parent(); temp.pege = $123pan.detectPage(); if ($(".pl-button").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(`
下载助手
  • API 下载
  • cURL 下载
  • Aria2 下载
  • 彗星下载
  • 助手设置
  • 助手美化
  • 更新日志
`); $button.css({ "width": "100px" }) element.append($button); }) }, addInitButton() { base.waitForKeyElements(config.$123pan.mount.home, (element) => { element = element.parent(); temp.pege = $123pan.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'home') return; let $button = $(`
点我点亮
`); $button.click(() => { base.showInitDialog() }); $button.css({ "margin-right": "22px", "width": "110px" }) element.prepend($button); }) base.waitForKeyElements(config.$123pan.mount.share, (element) => { element = element.parent(); temp.pege = $123pan.detectPage(); if ($(".pl-button-init").length > 0 || !temp.pege || temp.pege !== 'share') return; let $button = $(`
点我点亮
`); $button.click(() => { base.showInitDialog() }); $button.css({ "width": "100px" }) element.append($button); }) }, detectPage() { let path = location.pathname; if (/^\/$/.test(path)) return 'home'; if (/^\/s\//.test(path)) return 'share'; return ""; }, async initPanLinker() { base.createTip(); base.registerMenuCommand(); if (config.base.num === base.getValue('setting_init').code || config.base.license === base.getValue('setting_init').license) { this.addButton(); } else { this.addInitButton(); } this.addPageListener(); }, }; // 主代码 let main = { async init() { base.waitForKeyElements(`html:not(:has(> .${mount})) head`, (element) => { if ($(`.${mount}`).length > 0) return; element.after(`<${mount} class="${mount}" />`) }) base.waitForKeyElements(`.${mount}`, (element) => { element.append(``); return true; }, true) // 先加载默认设置 base.initDefaultConfig(); // 再加载网页样式 base.addPanLinkerStyle(); base.addPageListener(); base.createDownloadIframe(); /** * 控制台输出 * @author 油小猴 * @author hmjz100 * @description 来自【网盘智能识别助手】,有改动 */ console.log( `%c\s%c LinkSwift\n一个基于 JavaScript 的网盘文件下载地址获取工具\n仓库:https://github.com/hmjz100/LinkSwift\n版本:${info.version}\n领域:${(window.self !== window.top ? "[iframe] " : "") + (document.title ? (document.title + " (" + location.origin + location.pathname + ")") : location.href)}`, `background:url(${info.icon}) center center no-repeat;background-size:12px;padding:3px`, `padding:2px` ); let storedVersion = base.getValue("setting_init").version; if (!storedVersion || base.isNewerVersion(info.version, storedVersion)) { base.waitForKeyElements("body", () => { base.showUpdate(); let list = base.getValue("setting_init"); list.version = info.version; base.setValue("setting_init", list); return true; }, true) } // 最后判断页面地址并加载对应的initPanLinker if (/(pan|yun).baidu.com/.test(location.host)) { $baidu.initPanLinker(); $baidu.greenerPage(); } if (/openapi.baidu.com\/oauth/.test(location.href)) { $baidu.initAuthorize() } if (/www.(aliyundrive|alipan).com/.test(location.host)) { $aliyun.initPanLinker(); $aliyun.greenerPage(); } if (/(yun|caiyun).139.com/.test(location.host)) { $mcloud.initPanLinker(); $mcloud.greenerPage(); } if (/cloud.189.cn/.test(location.host)) { $tcloud.initPanLinker(); $tcloud.greenerPage(); } if (/pan.xunlei.com/.test(location.host)) { $xunlei.initPanLinker(); } if (/pan.quark.cn/.test(location.host)) { $quark.initPanLinker(); $quark.greenerPage(); } if (/drive.uc.cn/.test(location.host)) { $uc.initPanLinker(); $uc.greenerPage(); } if (/(www|login).(123(pan|684|865|952|912).com|123pan.cn)/.test(location.host)) { $123pan.initPanLinker(); $123pan.greenerPage(); } } }; main.init(); // 这是啥?我不到啊 function idontknow(input) { let charArray = input.split(""); // Fisher-Yates 洗牌算法 for (let i = charArray.length - 1; i > 0; i--) { let j = Math.floor(Math.random() * (i + 1)); [charArray[i], charArray[j]] = [charArray[j], charArray[i]]; } return charArray.join(""); } })();