// ==UserScript== // @name 网盘智能识别助手-修改优化版 // @namespace https://github.com/Magiclyan/panAI // @version 261012 // @author MagicLyan(FuM),YouXiaoHou,52fisher,Modified // @description 智能识别选中文字中的🔗网盘链接和🔑提取码,识别成功打开网盘链接并自动填写提取码。支持60+网盘,含深浅模式、背景材质、13套主题等。 // @license AGPL-3.0-or-later // @homepage https://github.com/Magiclyan/panAI // @supportURL https://github.com/Magiclyan/panAI // @match *://*/* // @require https://unpkg.com/sweetalert2@10.16.6/dist/sweetalert2.min.js // @require https://unpkg.com/hotkeys-js@3.13.3/dist/hotkeys.min.js // @resource swalStyle https://unpkg.com/sweetalert2@10.16.6/dist/sweetalert2.min.css // @run-at document-idle // @grant GM_openInTab // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_getResourceText // @grant GM_info // @icon data:image/svg+xml;utf8, // ==/UserScript== (function () { 'use strict'; /* ===== 网盘真实品牌图标库(内联 SVG,无外部依赖、无跨域问题)===== */ const PAN_ICON_DATA = {"baidu":"","alibabacloud":"","quark":"","dropbox":"","uc":"","qq":"","weiyun":"","sinaweibo":"","lanzou":"","123pan":"123","4275":"","caiyun":"","chinaunicom":"","chinatelecom":"","mediafire":"","xunlei":"","360":"","115":"","box":"","cowtransfer":"","ctfile":"","wenshushu":"","mega":"","wetransfer":"","nitroflare":"","crown":"","target":"","home":"","yifile":"","dufile":"","plane":"","silver":"","lansod":"","61":"","520":"","567":"","ayunpan":"","iycdn":"","cat":"","download":"","ox":"","snow":"","cloud":"","116":"","terabox":"","pikpak":"","google-drive":"","microsoft-onedrive":"","microsoft-edge":"","github":"","flowus":"","chrome-web-store":"","firefox-mono":"","microsoft-store":"","nutstore":"","4shared":"","kdocs":"","gofile":""}; /** * 获取网盘对应的品牌图标(SVG 字符串)。 * @param {string} key 图标标识,匹配 PAN_ICON_DATA 中的键 * @param {number} size 显示尺寸(px),默认 16 * @param {boolean} circle 是否裁成圆形头像,默认 true */ function getPanIcon(key, size, circle) { if (size === undefined) size = 16; if (circle === undefined) circle = true; var svg = PAN_ICON_DATA[key]; if (!svg) { return '☁️'; } return '' + svg + ''; } /* ===== 版本号(年月日)与版本日志 ===== */ const VERSION = '261013'; const CHANGELOG = [ { version: '261013', date: '2026-10-13', items: [ '更换 ScriptCat 扩展列表图标为自定义紫色渐变云存储图标', '夸克云盘图标更换为蓝紫渐变云朵图标', '123云盘图标更换为蓝紫圆角方形 123 图标', 'Google Drive 图标更换为经典黄绿蓝三色三角拼合图标', 'OneDrive 图标更换为蓝紫渐变云朵图标', 'QQ 闪传图标更换为经典企鹅卡通形象图标', '设置页面取消折叠收纳,所有功能默认全部展开', '设置窗口尺寸增大至 760×820,功能完整显示无需滚动' ] }, { version: '261012', date: '2026-10-12', items: [ '插件重命名为「网盘智能识别助手-修改优化版」', 'ScriptCat 扩展列表图标更换为自定义紫色渐变云存储图标', '删除「切换深浅并预览」按钮,简化设置页面操作', '设置页面重新设计:按「外观设置 / 布局与位置 / 行为设置」三大区块分组,新增分区标题', '新增背景材质效果:无 / 透明 / 模糊 / 亚克力模糊 / 云母 五种可选', '透明材质在深浅模式下自动适配背景色,亚克力/云母材质含动态光泽层', '更新日志抽屉 UI 适配深浅模式,使用 CSS 变量统一配色', '首次安装或插件更新后自动弹出更新日志页面', '修复恢复默认按钮未重置背景材质设置的问题' ] }, { version: '261011', date: '2026-10-11', items: [ '新增外观模式切换:支持「跟随系统 / 始终浅色 / 始终深色」三种模式,可随时切换深浅', '扩展主题为 13 套(含明亮浅色、深夜暗黑两套基础主题),每套主题均提供独立的暗色变体', '主题卡片预览改为双色色块(左浅右深),一眼区分明暗与配色风格', '设置页新增「🌗 切换深浅并预览」按钮,点击实时切换并预览效果', '恢复默认按钮同步重置外观模式设置', '全部 58 个网盘图标替换为对应网盘官方品牌 SVG 图标,含百度蓝、阿里橙、腾讯蓝、Google 四色、OneDrive 蓝、Edge 等标准色' ] }, { version: '261008', date: '2026-10-09', items: [ '新增弹窗主题:提供 11 套拟真 Windows 外观(Win11 / 10 / 8.1 / 8 / 7 / Vista / XP / ME / 98 / 3.x / 1.0&2.0),含标题栏配色、圆角、按钮与边框风格', '新增弹窗位置设置:上 / 中 / 下,作用于全部 SweetAlert 弹窗', '新增弹窗尺寸设置:宽度 / 高度自由调节,另含紧凑/标准/宽屏三档预设', '新增「恢复默认」按钮,一键还原主题、位置、大小及所有设置项', '设置页重构为分组折叠卡片式,保存无需刷新页面', '网盘图标全部替换为真实品牌 SVG:百度蓝、阿里橙、腾讯微云、Google 四色、OneDrive 蓝、Edge、GitHub、Firefox、Dropbox、Box、Mega、MediaFire 等 58 个品牌标准色图标', '识别结果弹窗与支持网盘清单的图标改为矢量图形,放大不失真,随主题自动适配背景' ] }, { version: '261007', date: '2026-10-07', items: [ '新增适配主流网盘:QQ闪传(qfile.qq.com)、NitroFlare,恢复 360 云盘', '新增适配小众网盘:飞机盘、银盘(yukaidi)、小蓝云盘、六一云盘、520云盘、567盘、AYunPan、爱优网盘、飞猫盘、优云下载、迅牛网盘、雪球云盘、飞云网盘、116盘,恢复 OwnFile', '为每个网盘添加专属图标,识别弹窗与支持列表均展示图标', '新增「更新日志」抽屉面板:最新版默认展开,历史版本收纳折叠、点击展开,版本号为年月日', '新增「支持网盘」清单面板,按主流 / 海外 / 小众 / 商店分类展示全部已适配网盘及图标', '修复 UC 网盘按钮选择器缺少右括号导致自动填码报错', '修复识别型网盘(无需提取码)在打开链接时误附加密码的问题', '提升健壮性:快捷键库加载失败不再中断脚本,缺失匹配项的网盘不再报错' ] }, { version: '260107', date: '2026-01-07', items: [ '新增海外/国际化网盘:TeraBox、PikPak、Google Drive、OneDrive、Dropbox、MediaFire、Box、Gofile、WeTransfer、4shared', '新增金山文档(WPS)、GitHub Releases、FlowUs息流、4275极速文件中转站适配', '优化蓝奏云旧域名自动修正(lanzous→lanzouw)' ] }, { version: '250706', date: '2025-07-06', items: [ '重构三大运营商网盘适配:中国移动(和彩云)、中国联通(沃盘)、中国电信(天翼云盘)', '新增识别剪切板文字、自定义快捷键、前台打开等配置项', '新增识别成功次数统计与重置功能' ] } ]; const customClass = { container: 'panai-container', popup: 'panai-popup', }; let toast = Swal.mixin({ toast: true, position: 'top', showConfirmButton: false, timer: 3500, timerProgressBar: false, didOpen: (toast) => { toast.addEventListener('mouseenter', Swal.stopTimer); toast.addEventListener('mouseleave', Swal.resumeTimer); } }); let util = { clog(c) { console.group("%c %c [网盘智能识别助手(M)]", `background:url(${GM_info.script.icon}) center center no-repeat;background-size:12px;padding:3px`, ""); console.log(c); console.groupEnd(); }, parseQuery(name) { let reg = new RegExp(`(?<=(?:${name})\\=)(?:wss:[a-zA-Z0-9]+|[\\w-]+)`, "i") let pd = location.href.replace(/%3A/g, ":").match(reg); if (pd) { return pd[0]; } return null; }, getValue(name) { return GM_getValue(name); }, setValue(name, value) { GM_setValue(name, value); }, sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); }, addStyle(id, tag, css) { tag = tag || 'style'; let doc = document, styleDom = doc.getElementById(id); if (styleDom) return; let style = doc.createElement(tag); style.rel = 'stylesheet'; style.id = id; tag === 'style' ? style.innerHTML = css : style.href = css; document.head.appendChild(style); }, isHidden(el) { try { return el.offsetParent === null; } catch (e) { return false; } }, isMobile: (() => !!navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone|HarmonyOS|MicroMessenger)/i))(), query(selector) { if (Array.isArray(selector)) { let obj = null; for (let i = 0; i < selector.length; i++) { let o = document.querySelector(selector[i]); if (o) { obj = o; break; } } return obj; } return document.querySelector(selector); } }; /* 网盘域名标识识别区 格式: '<任意填写>': { reg: /<链接匹配正则表达式>/, host: /<链接匹配主机名>/, input: ['form .ant-input', 'form input[type="text"]', 'input[name="pwd"]'], button: ['form .button--fep7l', 'form button[type="submit"]'], name: '<提示显示文本>', icon: '<展示图标>', storage: 'hash' */ let opt = { 'baidu': { reg: /((?:https?:\/\/)?(?:e?yun|pan)\.baidu\.com\/(doc\/|enterprise\/)?(?:s\/[\w~]*(((-)?\w*)*)?|share\/\S{4,}))(?:\s*(?:提取码|密码)\s*[::]\s*(\w{4}))?/, host: /(pan|e?yun)\.baidu\.com/, input: ['#accessCode', '.share-access-code', '#wpdoc-share-page > .u-dialog__wrapper .u-input__inner', '#pwd'], button: ['#submitBtn', '.share-access .g-button', '#wpdoc-share-page > .u-dialog__wrapper .u-btn--primary', '.passwddiv-btn', '#sub'], name: '百度网盘', icon: 'baidu', storage: 'hash' }, 'aliyun': { reg: /((?:https?:\/\/)?(?:(?:www\.)?(?:aliyundrive|alipan)\.com\/s|alywp\.net)\/[a-zA-Z\d]+)/, host: /www\.(aliyundrive|alipan)\.com|alywp\.net/, input: ['form .ant-input', 'form input[type="text"]', 'input[name="pwd"]'], button: ['form .button--fep7l', 'form button[type="submit"]'], name: '阿里云盘', icon: 'alibabacloud', storage: 'hash' }, 'quark': { reg: /((?:https?:\/\/)?pan\.quark\.cn\/s\/[a-zA-Z\d-]+)/, host: /pan\.quark\.cn/, input: ['.ant-input'], button: ['.ant-btn-primary'], name: '夸克网盘', icon: 'quark', storage: 'local', storagePwdName: 'tmp_quark_pwd' }, 'UC': { reg: /(?:https?:\/\/)?drive\.uc\.cn\/s\/[a-zA-Z\d]+/, host: /drive\.uc\.cn/, input: ["input[class*='ShareReceivePC--input']", '.input-wrap input'], button: ["button[class*='ShareReceivePC--submit-btn']", '.input-wrap button'], name: 'UC云盘', icon: 'uc', storage: 'hash' }, 'RUC': { reg: /(?:https?:\/\/)?fast\.uc\.cn\/s\/[a-zA-Z\d]+/, host: /fast\.uc\.cn/, input: ["input[class*='ShareReceivePC--input']", '.input-wrap input'], button: ["button[class*='ShareReceivePC--submit-btn']", '.input-wrap button'], name: 'UC云盘(转码)', icon: 'uc', storage: 'hash' }, 'weiyun': { reg: /((?:https?:\/\/)?share\.weiyun\.com\/[a-zA-Z\d]+)/, host: /share\.weiyun\.com/, input: ['.mod-card-s input[type=password]', 'input.pw-input'], button: ['.mod-card-s .btn-main', ".pw-btn-wrap button.btn"], name: '腾讯微云', icon: 'weiyun', storage: 'hash' }, 'lanzou': { reg: /((?:https?:\/\/)?(?:[a-zA-Z0-9\-.]+\.)?(?:lanzou[a-z]|lanzn)\.com\/[\w-]+(?:\/[\w-]+)*)/, host: /(?:[a-zA-Z\d-.]+)?(?:lanzou[a-z]|lanzn)\.com/, input: ['#pwd'], button: ['.passwddiv-btn', '#sub'], name: '蓝奏云(免登)', icon: 'lanzou', storage: 'hash' }, 'lanzou-Pre': { reg: /((?:https?:\/\/)?(?:[a-zA-Z0-9\-.]+)?(?:ilanzou)\.com\/[a-zA-Z\d_\-]+(?:\/[\w-]+)?)/, host: /(?:[a-zA-Z\d-.]+)?(?:ilanzou)\.com/, input: ['#pwd'], button: ['.passwddiv-btn', '#sub'], name: '蓝奏云·优享版', icon: 'lanzou', storage: 'hash' }, '123pan': { reg: /((?:https?:\/\/)?(?:www\.)?(?:\d{6}\.com|123pan\.com|123pan\.cn)\/s\/[\w-]+(?:\?.*)?)/, host: /(?:www\.)?(?:\d{6}\.com|123pan\.com|123pan\.cn)/, input: ['.ca-fot input', ".appinput .appinput"], button: ['.ca-fot button', ".appinput button"], name: '123云盘(免登)', icon: '123pan', storage: 'hash' }, '4275': { reg: /((?:https?:\/\/)?(?:www\.)?4275\.com\/[\w-]+(?:\?.*)?)/, host: /4275\.com/, input: ['.ca-fot input', ".appinput .appinput"], button: ['.ca-fot button', ".appinput button"], name: '4275极速云文件中转站', icon: '4275', storage: 'hash' }, /* 三大通信运营商网盘 */ 'CMCCdrive': { reg: /((?:https?:\/\/)?caiyun\.139\.com\/(?:m\/i|w\/i\/|web\/|front\/#\/detail)\??(?:linkID=)?[a-zA-Z\d]+)/, host: /(?:cai)?yun\.139\.com/, input: ['.token-form input[type=text]'], button: ['.token-form .btn-token'], name: '中国移动云盘(和彩云)', icon: 'caiyun', storage: 'local', storagePwdName: 'tmp_caiyun_pwd' }, 'CUCCdrive': { reg: /(?:https?:\/\/)?pan\.wo\.cn\/s\/[\w_]+/, host: /(pan\.wo\.cn|panservice\.mail\.wo\.cn)/, input: ['input.el-input__inner', ".van-field__control"], button: ['.s-button', ".share-code button"], name: '中国联通云盘(沃盘)', icon: 'chinaunicom', storage: (() => util.isMobile === true ? 'local' : 'hash')(), storagePwdName: 'tmp_wo_pwd' }, 'CTCCdrive': { reg: /((?:https?:\/\/)?cloud\.189\.cn\/(?:t\/|web\/share\?code=)?[a-zA-Z\d]+)/, host: /cloud\.189\.cn/, input: ['.access-code-item #code_txt', "input.access-code-input"], button: ['.access-code-item .visit', ".button"], name: '中国电信(天翼云)', icon: 'chinatelecom', storage: (() => util.isMobile === true ? 'local' : 'hash')(), storagePwdName: 'tmp_tianyi_pwd' }, /*——End——*/ 'xunlei': { reg: /((?:https?:\/\/)?pan\.xunlei\.com\/s\/[\w-]{10,})/, host: /pan\.xunlei\.com/, input: ['.pass-input-wrap .td-input__inner'], button: ['.pass-input-wrap .td-button'], name: '迅雷云盘', icon: 'xunlei', storage: 'hash' }, '360': { reg: /((?:https?:\/\/)?(?:[a-zA-Z\d\-.]+)?(?:yunpan\.360\.cn|yunpan\.com)(\/lk)?\/surl_\w{6,})/, host: /[\w.]+?(?:yunpan\.360\.cn|yunpan\.com)/, input: ['.pwd-input'], button: ['.submit-btn'], name: '360云盘', icon: '360', storage: 'local', storagePwdName: 'tmp_360_pwd' }, '115': { reg: /((?:https?:\/\/)?115cdn\.com\/s\/[a-zA-Z\d]+)/, host: /115cdn\.com/, input: ['.form-decode input'], button: ['.form-decode .submit a'], name: '115网盘', icon: '115', storage: 'hash' }, 'cowtransfer': { reg: /((?:https?:\/\/)?(?:[a-zA-Z\d-.]+)?cowtransfer\.com\/s\/[a-zA-Z\d]+)/, host: /(?:[a-zA-Z\d-.]+)?cowtransfer\.com/, input: ['.receive-code-input input'], button: ['.open-button'], name: '奶牛快传', icon: 'cowtransfer', storage: 'hash' }, 'ctfile': { reg: /((?:https?:\/\/)?(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|ghpym)\.com\/\w+\/[a-zA-Z\d-]+)/, host: /(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|ghpym)\.com/, input: ['#passcode'], button: ['.card-body button'], name: '城通网盘', icon: 'ctfile', storage: 'hash' }, 'wenshushu': { reg: /((?:https?:\/\/)?(?:www\.wenshushu|ws28)\.cn\/(?:k|box|f)\/\w+)/, host: /(?:www\.wenshushu|ws28)\.cn/, input: ['.pwd-inp .ivu-input'], button: ['.pwd-inp .ivu-btn'], name: '文叔叔网盘', icon: 'wenshushu', storage: 'hash' }, 'vdisk': { reg: /(?:https?:\/\/)?vdisk.weibo.com\/lc\/\w+/, host: /vdisk\.weibo\.com/, input: ['#keypass', "#access_code"], button: ['.search_btn_wrap a', "#linkcommon_btn"], name: '微盘', icon: 'weibo', storage: 'hash', }, 'jianguoyun': { reg: /((?:https?:\/\/)?www\.jianguoyun\.com\/p\/[\w-]+)/, host: /www\.jianguoyun\.com/, input: ['input[type=password]'], button: ['.ok-button', '.confirm-button'], name: '坚果云', icon: 'nutstore', storage: 'hash' }, 'mega': { reg: /((?:https?:\/\/)?(?:mega\.nz|mega\.co\.nz)\/#F?![\w!-]+)/, host: /(?:mega\.nz|mega\.co\.nz)/, input: ['.dlkey-dialog input'], button: ['.dlkey-dialog .fm-dialog-new-folder-button'], name: 'Mega', icon: 'mega', storage: 'local' }, 'qqfile': { reg: /((?:https?:\/\/)?qfile\.qq\.com\/q\/[\w]+)/, host: /qfile\.qq\.com/, name: 'QQ闪传', icon: 'qq' }, 'nitroflare': { reg: /((?:https?:\/\/)?(?:www\.)?(?:nitroflare\.com|nitro\.download)\/view\/[a-zA-Z0-9]+)/, host: /(?:www\.)?(?:nitroflare\.com|nitro\.download)/, name: 'NitroFlare', icon: '🔥' }, 'dudujb': { reg: /(?:https?:\/\/)?www\.dudujb\.com\/file-\d+\.html/, host: /www\.dudujb\.com/, name: '网赚:贵族网盘', icon: 'crown', }, '77file': { reg: /(?:https?:\/\/)?www\.77file\.com\/s\/[a-zA-Z\d]+/, host: /www\.77file\.com/, name: '网赚:77file', icon: 'target', }, 'ownfile': { reg: /(?:https?:\/\/)?ownfile\.net\/files\/[a-zA-Z\d]+\.html/, host: /ownfile\.net/, name: 'OwnFile', icon: 'home', }, 'yifile': { reg: /(?:https?:\/\/)?www\.yifile\.com\/f\/\w+/, host: /www\.yifile\.com/, name: '网赚:YiFile', icon: 'yifile', }, 'dufile': { reg: /(?:https?:\/\/)?dufile\.com\/file\/\w+\.html/, host: /dufile\.com/, name: 'duFile', icon: 'dufile', }, /* 小众网赚网盘(网赚盘,多为 /file-.html 格式) */ 'feijipan': { reg: /((?:https?:\/\/)?(?:www\.)?(?:share\.feijipan\.com|www\.feijix\.com)\/s\/[\w]+)/, host: /(?:share\.feijipan\.com|www\.feijix\.com)/, name: '飞机盘(小飞机网盘)', icon: 'plane', }, 'yukaidi': { reg: /((?:https?:\/\/)?(?:pan\d+\.)?yukaidi\.com\/s\/[\w]+)/, host: /(?:pan\d+\.)?yukaidi\.com/, name: '银盘(yukaidi)', icon: 'silver', }, 'lansod': { reg: /((?:https?:\/\/)?pan\.lansod\.cn\/s\/[\w]+)/, host: /pan\.lansod\.cn/, name: '小蓝云盘(BlueDisk)', icon: 'lansod', }, 'now61': { reg: /((?:https?:\/\/)?www\.now61\.(?:com|cn)\/s\/[\w]+)/, host: /www\.now61\.(?:com|cn)/, name: '六一云盘', icon: '61', }, // 爱丽丝的记事本(爱丽丝网盘):天使动漫自建网盘,2025.10 起暂下线,分享域名暂未核实, // 待用户提供真实链接样例后可在此补全 reg/host 即可启用自动识别。 'alice': { reg: null, host: null, name: '爱丽丝的记事本', icon: '📓', _pending: true }, '520vip': { reg: /((?:https?:\/\/)?www\.(?:520-vip|eos-53)\.com\/file-\d+\.html)/, host: /www\.(?:520-vip|eos-53)\.com/, name: '520云盘', icon: '520', }, '567pan': { reg: /((?:\/\/)?www\.567(?:pan|yun|file|inc)\.(?:com|cn)\/file-\d+\.html)/, host: /www\.567(?:pan|yun|file|inc)\.(?:com|cn)/, name: '567盘', icon: '567', replaceHost: "www.567inc.com", }, 'ayunpan': { reg: /((?:https?:\/\/)?www\.ayunpan\.com\/file-\d+\.html)/, host: /www\.ayunpan\.com/, name: 'AYunPan', icon: 'ayunpan', }, 'iycdn': { reg: /((?:https?:\/\/)?www\.iycdn\.com\/file-\d+\.html)/, host: /www\.iycdn\.com/, name: '爱优网盘', icon: 'iycdn', }, 'feimaoyun': { reg: /((?:https?:\/\/)?www\.(?:feimaoyun\.com|feimao\.cloud)\/s\/[0-9a-zA-Z]+)/, host: /www\.(?:feimaoyun\.com|feimao\.cloud)/, name: '飞猫盘', icon: 'cat', }, 'uyunp': { reg: /((?:https?:\/\/)?download\.uyunp\.com\/share\/s\/short\/\?surl=[0-9a-zA-Z]+)/, host: /download\.uyunp\.com/, name: '优云下载', icon: 'download', }, 'xunniu': { reg: /(?:https?:\/\/)?www\.xunniu(?:fxp|wp|fx)\.com\/file-\d+\.html/, host: /www\.xunniu(?:fxp|wp|fx)\.com/, name: '迅牛网盘', icon: 'ox', }, 'xueqiupan': { reg: /(?:https?:\/\/)?www\.xueqiupan\.com\/file-\d+\.html/, host: /www\.xueqiupan\.com/, name: '雪球云盘', icon: 'snow', }, 'feiyunfile': { reg: /(?:https?:\/\/)?www\.feiyunfile\.com\/file\/[\w=]+\.html/, host: /www\.feiyunfile\.com/, name: '飞云网盘', icon: 'cloud', }, '116pan': { reg: /((?:https?:\/\/)?(?:www\.)?116pan\.(?:com|xyz)\/(?:s\/|file-)?[\w.\/-]+)/, host: /(?:www\.)?116pan\.(?:com|xyz)/, name: '116盘', icon: '116', }, /* 海外/国际化网盘 */ 'terabox': { reg: /((?:https?:\/\/)?(?:www\.)?(?:terabox|1024terabox|dubox|nephobox|teraboxapp)\.com\/(?:s\/[\w-]+|sharing\/link\?surl=[\w-]+))/, host: /(?:www\.)?(?:terabox|1024terabox|dubox|nephobox|teraboxapp)\.com/, name: 'TeraBox(海外盘)', icon: 'terabox', storage: 'hash' }, 'pikpak': { reg: /((?:https?:\/\/)?(?:www\.)?(?:mypikpak\.com|pikpak\.me|pikpak\.org)\/s\/[\w-]+)/, host: /(?:www\.)?(?:mypikpak\.com|pikpak\.me|pikpak\.org)/, name: 'PikPak', icon: 'pikpak', storage: 'hash' }, 'googledrive': { reg: /((?:https?:\/\/)?drive\.google\.com\/(?:file\/d\/[\w-]+|open\?id=[\w-]+|uc\?id=[\w-]+))/, host: /drive\.google\.com/, name: 'Google Drive', icon: 'google-drive', storage: 'hash' }, 'onedrive': { reg: /((?:https?:\/\/)?(?:1drv\.ms\/[\w]+|onedrive\.live\.com\/[\w?=&%.=\/-]+))/, host: /(?:1drv\.ms|onedrive\.live\.com)/, name: 'OneDrive', icon: 'microsoft-onedrive', storage: 'hash' }, 'dropbox': { reg: /((?:https?:\/\/)?(?:www\.)?dropbox\.com\/(?:s|sh|scl)\/[\w-]+(?:\/[\w-]+)*)/, host: /(?:www\.)?dropbox\.com/, name: 'Dropbox', icon: 'dropbox', storage: 'hash' }, 'mediafire': { reg: /((?:https?:\/\/)?(?:www\.)?mediafire\.com\/(?:file|folder)\/[\w]+)/, host: /(?:www\.)?mediafire\.com/, name: 'MediaFire', icon: 'mediafire', storage: 'hash' }, 'box': { reg: /((?:https?:\/\/)?(?:app|account)\.box\.com\/s\/[\w]+)/, host: /(?:app|account)\.box\.com/, name: 'Box', icon: 'box', storage: 'hash' }, 'gofile': { reg: /((?:https?:\/\/)?gofile\.io\/d\/[\w]+)/, host: /gofile\.io/, name: 'Gofile', icon: 'gofile', storage: 'hash' }, 'wetransfer': { reg: /((?:https?:\/\/)?(?:we\.tl\/[\w-]+|wetransfer\.com\/downloads\/[\w-]+))/, host: /(?:we\.tl|wetransfer\.com)/, name: 'WeTransfer', icon: 'wetransfer', storage: 'hash' }, '4shared': { reg: /((?:https?:\/\/)?(?:www\.)?4shared\.com\/(?:file|folder|web)\/[\w-]+)/, host: /(?:www\.)?4shared\.com/, name: '4shared', icon: '🔗', storage: 'hash' }, 'kdocs': { reg: /((?:https?:\/\/)?(?:www\.)?kdocs\.cn\/l\/[\w-]+)/, host: /kdocs\.cn/, name: '金山文档(WPS)', icon: 'kdocs', storage: 'hash' }, 'github': { reg: /((?:https?:\/\/)?github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+\/releases(?:\/[a-zA-Z0-9_.-]+)?)/, host: /github\.com/, name: 'GitHub Releases', icon: 'github', storage: 'hash' }, 'flowus': { reg: /((?:https?:\/\/)?flowus\.cn\/[\S ^\/]*\/?share\/[a-z\d]{8}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{12})/, host: /flowus\.cn/, name: 'FlowUs息流', icon: 'flowus', storage: 'hash' }, 'chrome': { reg: /^https?:\/\/chrome.google.com\/webstore\/.+?\/([a-z\d]{32})(?=[\/#?]|$)/, host: /chrome\.google\.com/, replaceHost: "chrome.crxsoso.com", name: 'Chrome商店', icon: '🌐', }, 'edge': { reg: /^https?:\/\/microsoftedge.microsoft.com\/addons\/.+?\/([a-z\d]{32})(?=[\/#?]|$)/, host: /microsoftedge\.microsoft\.com/, replaceHost: "microsoftedge.crxsoso.com", name: 'Edge商店', icon: 'microsoft-edge', }, 'firefox': { reg: /^https?:\/\/(reviewers\.)?(addons\.mozilla\.org|addons(?:-dev)?\.allizom\.org)\/.*?(?:addon|review)\/([^/<>"'?#]+)/, host: /addons\.mozilla\.org/, replaceHost: "addons.crxsoso.com", name: 'Firefox商店', icon: 'firefox-mono', }, 'microsoft': { reg: /^https?:\/\/(?:apps|www).microsoft.com\/(?:store|p)\/.+?\/([a-zA-Z\d]{10,})(?=[\/#?]|$)/, host: /(apps|www)\.microsoft\.com/, replaceHost: "apps.crxsoso.com", name: 'Windows商店', icon: 'microsoft-store', }, }; /* 支持网盘分类(用于「支持网盘」抽屉面板展示) */ const PAN_GROUPS = [ ['主流网盘', ['baidu', 'aliyun', 'quark', 'UC', 'RUC', 'weiyun', 'lanzou', 'lanzou-Pre', '123pan', 'CMCCdrive', 'CUCCdrive', 'CTCCdrive', 'xunlei', '360', '115', 'cowtransfer', 'ctfile', 'wenshushu', 'vdisk', 'jianguoyun', 'pikpak', 'qqfile', 'googledrive', 'mega']], ['海外/国际网盘', ['terabox', 'onedrive', 'dropbox', 'mediafire', 'box', 'gofile', 'wetransfer', '4shared', 'nitroflare', 'kdocs', 'github', 'flowus', '4275']], ['小众网盘', ['feijipan', 'yukaidi', 'lansod', 'now61', 'alice', '520vip', '567pan', 'ayunpan', 'iycdn', 'feimaoyun', 'uyunp', 'dudujb', 'xunniu', 'xueqiupan', '77file', 'ownfile', 'feiyunfile', 'yifile', 'dufile', '116pan']], ['商店', ['chrome', 'edge', 'firefox', 'microsoft']], ]; let main = { lastText: "lorem&", // 弹窗外观默认值 DEFAULTS: { theme: 'win11', appearance: 'system', effect: 'none', position: 'top', width: 500, height: 280, sizePreset: 'standard' }, //初始化配置数据 initValue() { let value = [{ name: 'setting_success_times', value: 0 }, { name: 'setting_auto_click_btn', value: true }, { name: 'setting_active_in_front', value: true }, { name: 'setting_timer_open', value: false }, { name: 'setting_timer', value: 5000 }, { name: 'setting_hotkeys', value: 'F1' }, { name: 'setting_theme', value: 'win11' }, { name: 'setting_appearance', value: 'system' }, { name: 'setting_effect', value: 'none' }, { name: 'setting_position', value: 'top' }, { name: 'setting_width', value: 500 }, { name: 'setting_height', value: 280 }, { name: 'setting_size_preset', value: 'standard' }]; value.forEach((v) => { if (util.getValue(v.name) === undefined) { util.setValue(v.name, v.value); } }); }, // 监听选择事件 addPageListener() { document.addEventListener("mouseup", this.smartIdentify.bind(this), true); document.addEventListener("keydown", this.pressKey.bind(this), true); }, // 获取选择内容的HTML和文本(增加兼容性) 或 DOM(节点遍历) getSelectionHTML(selection, isDOM = false) { const testDiv = document.createElement("div"); if (!selection.isCollapsed) { const docFragment = selection.getRangeAt(0).cloneContents(); testDiv.appendChild(docFragment); } return isDOM ? testDiv : selection.toString(); }, smartIdentify(event, str = '') { let selection = window.getSelection(); let text = str || this.getSelectionHTML(selection); if (text !== this.lastText && text !== '') { let start = performance.now(); this.lastText = text; let linkObj = this.parseLink(text); let link = linkObj.link; let name = linkObj.name; let pwd = this.parsePwd(text); if (!link) { linkObj = this.parseParentLink(selection); link = linkObj.link; name = linkObj.name; } if (link) { if (!/https?:\/\//.test(link)) { link = 'https://' + link; } let end = performance.now(); let time = (end - start).toFixed(3); util.clog(`文本识别结果:${name} 链接:${link} 密码:${pwd} 耗时:${time}毫秒`); let option = { toast: false, showCancelButton: true, position: this.getSwalPosition(), title: `${getPanIcon(linkObj.icon, 22, false)}发现${name}链接`, html: `${!!pwd ? '密码:' + pwd : '是否打开?'}`, confirmButtonText: '打开', cancelButtonText: '关闭', customClass, width: util.getValue('setting_width'), ...(util.getValue('setting_height') ? {padding: '1.25em'} : {}) }; if (util.getValue('setting_timer_open')) { option.timer = util.getValue('setting_timer'); option.timerProgressBar = true; } util.setValue('setting_success_times', util.getValue('setting_success_times') + 1); // 应用主题 + 用户自定义尺寸 this.applyTheme(); this.applySize(); Swal.fire(option).then((res) => { this.clearSize(); this.lastText = 'lorem&'; selection.empty(); if (res.isConfirmed || res.dismiss === 'timer') { if (linkObj.storage == "local") { util.setValue(linkObj.storagePwdName, pwd); } let active = util.getValue('setting_active_in_front'); // 仅对需要提取码的网盘附加密码;识别型网盘(无storage)直接打开干净链接,避免误附加无关字符 if (pwd && linkObj.storage) { let extra = `${link}?pwd=${pwd}#${pwd}`; if (~link.indexOf('?')) { extra = `${link}&pwd=${pwd}#${pwd}`; } GM_openInTab(extra, {active}); } else { GM_openInTab(`${link}`, {active}); } } }); } } }, pressKey(event) { if (event.key === 'Enter') { let confirmBtn = document.querySelector('.panai-container .swal2-confirm'); confirmBtn && confirmBtn.click(); } if (event.key === 'Escape') { let cancelBtn = document.querySelector('.panai-container .swal2-cancel'); cancelBtn && cancelBtn.click(); } }, addHotKey() { let hotkey = util.getValue('setting_hotkeys'); // 若 hotkeys 库未加载成功则不注册,避免中断脚本 if (typeof hotkeys === 'function') { hotkeys(hotkey, (event, handler) => { event.preventDefault(); this.showIdentifyBox(); }); } }, //正则解析网盘链接 parseLink(text = '') { let obj = {name: '', link: '', storage: '', storagePwdName: '', icon: ''}; if (text) { try { text = decodeURIComponent(text); } catch { } text = text.replace(/[点點]/g, '.'); text = text.replace(/[\u4e00-\u9fa5()(),\u200B,\uD83C-\uDBFF\uDC00-\uDFFF]/g, ''); text = text.replace(/lanzous/g, 'lanzouw'); //修正lanzous打不开的问题 for (let name in opt) { let val = opt[name]; // 防御:缺失匹配项的网盘(如域名待补全的条目)直接跳过,避免 reg 为 null 时报错 if (!val.reg) continue; if (val.reg.test(text)) { let matches = text.match(val.reg); obj.name = val.name; obj.link = matches[0]; obj.storage = val.storage; obj.storagePwdName = val.storagePwdName || null; obj.icon = val.icon; if (val.replaceHost) { obj.link = obj.link.replace(val.host, val.replaceHost); } return obj; } } } return obj; }, //正则解析超链接类型网盘链接 parseParentLink(selection) { const dom = this.getSelectionHTML(selection, true).querySelector('*[href]'); return this.parseLink(dom ? dom.href : ""); }, //正则解析提取码 parsePwd(text) { text = text.replace(/\u200B/g, '').replace('%3A', ":"); text = text.replace(/(?:本帖)?隐藏的?内容[::]?/, ""); let reg = /wss:[a-zA-Z0-9]+|(?<=\s*(?:密|提取|访问|解压|訪問|key|password|pwd|#|\?p=)\s*[码碼]?\s*[::=]?\s*)[a-zA-Z0-9]{3,8}/i; if (reg.test(text)) { let match = text.match(reg); return match[0]; } return ''; }, //根据域名检测网盘类型 panDetect() { let hostname = location.hostname; for (let name in opt) { let val = opt[name]; // 防御:host 缺失的条目跳过,避免 test 报错 if (!val.host) continue; if (val.host.test(hostname)) { return name; } } return ''; }, //自动填写密码 autoFillPassword() { let query = util.parseQuery('pwd|p'); let hash = location.hash.slice(1).replace(/\W/g, "") //hash中可能存在密码,需要过滤掉非密码字符 let pwd = query || hash; let panType = this.panDetect(); for (let name in opt) { let val = opt[name]; if (panType === name) { if (val.storage === 'local') { //当前local存储的密码不一定是当前链接的密码,用户可能通过url直接访问或者恢复页面,这样取出来的密码可能是其他链接的 //如果能从url中获取到密码,则应该优先使用url中获取的密码 //util.getValue查询不到key时,默认返回undefined,已经形成逻辑短路,此处赋空值无效也无需赋空值.详见https://github.com/syhyz1990/panAI/commit/efb6ff0c77972920b26617bb836a2e19dd14a749 pwd = pwd || util.getValue(val.storagePwdName); pwd && this.doFillAction(val.input, val.button, pwd); } if (val.storage === 'hash') { if (!/^(?:wss:[a-zA-Z\d]+|[a-zA-Z0-9]{3,8})$/.test(pwd)) { //过滤掉不正常的Hash return; } //部分仅识别打开、未配置提取码输入框的网盘,跳过自动填码,避免 querySelector(undefined) 报错 pwd && val.input && this.doFillAction(val.input, val.button, pwd); } } } }, doFillAction(inputSelector, buttonSelector, pwd) { let maxTime = 10; let ins = setInterval(async () => { maxTime--; let input = util.query(inputSelector); let button = util.query(buttonSelector); if (input && !util.isHidden(input)) { clearInterval(ins); Swal.fire({ toast: true, position: 'top', showCancelButton: false, showConfirmButton: false, title: 'AI已识别到密码!正自动帮您填写', icon: 'success', timer: 2000, customClass }); let lastValue = input.value; input.value = pwd; //Vue & React 触发 input 事件 let event = new Event('input', {bubbles: true}); let tracker = input._valueTracker; if (tracker) { tracker.setValue(lastValue); } input.dispatchEvent(event); if (util.getValue('setting_auto_click_btn')) { await util.sleep(1000); //1秒后点击按钮 button.click(); } } else { maxTime === 0 && clearInterval(ins); } }, 800); }, //重置识别次数 clearIdentifyTimes() { this.applyTheme(); let res = Swal.fire({ showCancelButton: true, title: '确定要重置识别次数吗?', icon: 'warning', confirmButtonText: '确定', cancelButtonText: '取消', customClass }).then(res => { this.lastText = 'lorem&'; if (res.isConfirmed) { util.setValue('setting_success_times', 0); history.go(0); } }); }, //识别输入框中的内容 showIdentifyBox() { this.applyTheme(); Swal.fire({ title: '识别剪切板中文字', input: 'textarea', inputPlaceholder: '若选方式一,请按 Ctrl+V 粘贴要识别的文字', html: `提示:在任意网页按下 ${util.getValue("setting_hotkeys")} 键可快速打开本窗口。支持以下两种方式:方式一:直接粘贴文字到输入框,点击“识别方框内容”按钮。方式二:点击“读取剪切板”按钮。会弹出“授予网站读取剪切板”权限,同意后会自动识别剪切板中的文字。`, showCloseButton: false, showDenyButton: true, confirmButtonText: '识别方框内容', denyButtonText: '读取剪切板', customClass }).then(res => { if (res.isConfirmed) { this.smartIdentify(null, res.value); } if (res.isDenied) { navigator.clipboard.readText().then(text => { this.smartIdentify(null, text); }).catch(() => { toast.fire({title: '读取剪切板失败,请先授权或手动粘贴后识别!', icon: 'error'}); }); } }); }, //显示设置 showSettingBox() { const themes = [ ['light', '☀️', '明亮浅色'], ['dark', '🌙', '深夜暗黑'], ['win11', '🪟', 'Windows 11'], ['win10', '🪟', 'Windows 10'], ['win81', '🧊', 'Windows 8.1'], ['win8', '🟦', 'Windows 8'], ['win7', '🔷', 'Windows 7'], ['vista', '🟦', 'Windows Vista'], ['xp', '🟢', 'Windows XP'], ['me', '💠', 'Windows ME'], ['98', '🩶', 'Windows 98'], ['3x', '🕹️', 'Windows 3.x'], ['12', '📺', 'Windows 1.0 / 2.0'] ]; const appearances = [['system', '🌗 跟随系统'], ['light', '☀️ 始终浅色'], ['dark', '🌙 始终深色']]; const effects = [['none', '🚫 无'], ['transparent', '👁️ 透明'], ['blur', '🌫️ 模糊'], ['acrylic', '💠 亚克力模糊'], ['mica', '✨ 云母']]; const positions = [['top', '上'], ['center', '中'], ['bottom', '下']]; const presets = [['compact', '紧凑'], ['standard', '标准'], ['wide', '宽屏']]; const cur = { theme: util.getValue('setting_theme'), appearance: util.getValue('setting_appearance'), effect: util.getValue('setting_effect'), position: util.getValue('setting_position'), width: util.getValue('setting_width'), height: util.getValue('setting_height'), preset: util.getValue('setting_size_preset') }; const appearanceRadios = appearances.map(([k, n]) => `${n}`).join(''); const effectRadios = effects.map(([k, n]) => `${n}`).join(''); const themeCards = themes.map(([k, ic, name]) => ` ${ic}${name} `).join(''); let html = ` 🎨 外观设置 🌗 深浅模式 ${appearanceRadios} 🖼️ 背景材质 ${effectRadios} 🎭 主题风格 ${themeCards} 📐 弹窗布局 弹窗位置 ${positions.map(([k, n]) => `${n}`).join('')} 尺寸预设 ${presets.map(([k, n]) => `${n}`).join('')} 自定义大小 宽 × 高 px ⚙️ 行为设置 填写密码后自动提交 前台打开网盘标签页 倒计时结束自动打开 倒计时时长 (${util.getValue('setting_timer') / 1000}秒) 快捷键设置 `; const SET_W = 1233; const SET_H = Math.round(Math.min(window.innerHeight - 16, 1287)); const swalOpts = { title: '识别助手配置', html, showCloseButton: true, showCancelButton: true, confirmButtonText: '保存', cancelButtonText: '恢复默认', footer: '点击查看 使用说明,助手免费开源,Powered by 油小猴', customClass, width: SET_W, heightAuto: true, // 设置页使用独立大高度,不继承用户自定义的弹窗尺寸 didOpen: () => { const popup = document.querySelector('.panai-container .swal2-popup'); if (popup) { popup.style.width = SET_W + 'px'; popup.style.maxWidth = '96vw'; popup.style.maxHeight = SET_H + 'px'; popup.style.height = SET_H + 'px'; const body = popup.querySelector('.swal2-html-container'); if (body) { body.style.maxHeight = (SET_H - 180) + 'px'; body.style.overflowY = 'auto'; body.style.overflowX = 'hidden'; body.style.padding = '0 4px'; } } } }; this.applyTheme(); Swal.fire(swalOpts).then((res) => { if (res.dismiss === 'cancel') { // 恢复默认 const def = this.DEFAULTS; util.setValue('setting_theme', def.theme); util.setValue('setting_appearance', def.appearance); util.setValue('setting_effect', def.effect); util.setValue('setting_position', def.position); util.setValue('setting_width', def.width); util.setValue('setting_height', def.height); util.setValue('setting_size_preset', def.sizePreset); util.setValue('setting_auto_click_btn', true); util.setValue('setting_active_in_front', true); util.setValue('setting_timer_open', false); util.setValue('setting_timer', 5000); util.setValue('setting_hotkeys', 'F1'); toast.fire({title: '已恢复全部默认设置', icon: 'success'}); } }); // 主题卡片点击 const box = document.querySelector('.panai-container .panai-set-layout') || document.querySelector('.panai-container .panai-set-wrap'); if (!box) return; // 外观模式单选 box.querySelectorAll('.panai-radio[data-app]').forEach(r => { r.addEventListener('click', () => { box.querySelectorAll('.panai-radio[data-app]').forEach(x => x.classList.remove('on')); r.classList.add('on'); const inp = r.querySelector('input'); inp.checked = true; util.setValue('setting_appearance', inp.value); this.applyTheme(); }); }); // 背景材质单选 box.querySelectorAll('.panai-radio[data-eff]').forEach(r => { r.addEventListener('click', () => { box.querySelectorAll('.panai-radio[data-eff]').forEach(x => x.classList.remove('on')); r.classList.add('on'); const inp = r.querySelector('input'); inp.checked = true; util.setValue('setting_effect', inp.value); this.applyTheme(); }); }); // 主题卡片点击 box.querySelectorAll('.panai-theme-card').forEach(card => { card.addEventListener('click', () => { box.querySelectorAll('.panai-theme-card').forEach(c => c.classList.remove('active')); card.classList.add('active'); util.setValue('setting_theme', card.dataset.theme); this.applyTheme(); }); }); // 位置单选 box.querySelectorAll('.panai-radio[data-pos]').forEach(r => { r.addEventListener('click', () => { box.querySelectorAll('.panai-radio[data-pos]').forEach(x => x.classList.remove('on')); r.classList.add('on'); const inp = r.querySelector('input'); inp.checked = true; util.setValue('setting_position', inp.value); }); }); // 尺寸预设 const PRESET_MAP = {compact: [420, 240], standard: [500, 280], wide: [620, 360]}; box.querySelectorAll('.panai-radio[data-pre]').forEach(r => { r.addEventListener('click', () => { box.querySelectorAll('.panai-radio[data-pre]').forEach(x => x.classList.remove('on')); r.classList.add('on'); const inp = r.querySelector('input'); inp.checked = true; const [w, h] = PRESET_MAP[inp.value] || PRESET_MAP.standard; util.setValue('setting_size_preset', inp.value); util.setValue('setting_width', w); util.setValue('setting_height', h); box.querySelector('#S-width').value = w; box.querySelector('#S-height').value = h; }); }); box.querySelector('#S-width').addEventListener('input', e => { util.setValue('setting_width', e.target.value); util.setValue('setting_size_preset', 'custom'); box.querySelectorAll('.panai-radio[data-pre]').forEach(x => x.classList.remove('on')); }); box.querySelector('#S-height').addEventListener('input', e => { util.setValue('setting_height', e.target.value); util.setValue('setting_size_preset', 'custom'); box.querySelectorAll('.panai-radio[data-pre]').forEach(x => x.classList.remove('on')); }); box.querySelector('#S-Auto').addEventListener('change', (e) => { util.setValue('setting_auto_click_btn', e.target.checked); }); box.querySelector('#S-Active').addEventListener('change', (e) => { util.setValue('setting_active_in_front', e.target.checked); }); box.querySelector('#S-Timer-Open').addEventListener('change', (e) => { let rangeWrapper = box.querySelector('#Panai-Range-Wrapper'); e.target.checked ? rangeWrapper.style.display = 'flex' : rangeWrapper.style.display = 'none'; util.setValue('setting_timer_open', e.target.checked); }); box.querySelector('#S-Timer').addEventListener('input', (e) => { util.setValue('setting_timer', e.target.value); box.querySelector('#Timer-Value').innerText = `(${e.target.value / 1000}秒)`; }); box.querySelector('#S-hotkeys').addEventListener('change', (e) => { util.setValue('setting_hotkeys', e.target.value); }); // 所有分区默认全部展开,无需折叠 }, // 根据 setting_position 映射到 SweetAlert 支持的 position getSwalPosition() { const map = { 'top': 'top', 'center': 'center', 'bottom': 'bottom' }; return map[util.getValue('setting_position')] || 'top'; }, // 应用主题:注入对应主题样式表 applyTheme() { const theme = util.getValue('setting_theme') || 'win11'; const appearance = util.getValue('setting_appearance') || 'system'; let dark = false; if (appearance === 'dark') dark = true; else if (appearance === 'system') { dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; } // 给容器和抽屉添加/移除 dark-mode class const container = document.querySelector('.panai-container'); const overlay = document.getElementById('panai-overlay'); if (container) container.classList.toggle('dark-mode', dark); if (overlay) overlay.classList.toggle('dark-mode', dark); let style = document.getElementById('panai-theme-style'); if (!style) { style = document.createElement('style'); style.id = 'panai-theme-style'; document.head.appendChild(style); } style.innerHTML = this.buildThemeCSS(theme); }, // 构建指定主题的拟真 CSS(支持亮/暗两种模式 + 背景材质) buildThemeCSS(theme) { const appearance = util.getValue('setting_appearance') || 'system'; const effect = util.getValue('setting_effect') || 'none'; // 判定实际暗色状态 let dark = false; if (appearance === 'dark') dark = true; else if (appearance === 'system') { dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; } const THEMES = { // ===== 明亮浅色 ===== light: ` .swal2-popup { border-radius: 10px !important; box-shadow: 0 12px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.05) !important; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif !important; background: #ffffff !important; } .swal2-title { font-weight: 600 !important; color: #1a1a2e !important; } .swal2-html-container { color: #4a4a5a !important; } .swal2-confirm { background: #4f46e5 !important; border-radius: 8px !important; font-weight: 600 !important; padding: 9px 24px !important; } .swal2-confirm:hover { background: #4338ca !important; } .swal2-cancel { background: #f1f1f4 !important; color: #333 !important; border-radius: 8px !important; padding: 9px 24px !important; } .swal2-cancel:hover { background: #e4e4e9 !important; } `, // ===== 深夜暗黑 ===== dark: ` .swal2-popup { border-radius: 10px !important; box-shadow: 0 12px 48px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08) !important; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif !important; background: #1e1e2e !important; } .swal2-title { font-weight: 600 !important; color: #cdd6f4 !important; } .swal2-html-container { color: #a6adc8 !important; } .swal2-confirm { background: #cba6f7 !important; color: #1e1e2e !important; border-radius: 8px !important; font-weight: 600 !important; padding: 9px 24px !important; } .swal2-confirm:hover { background: #b4befe !important; } .swal2-cancel { background: #313244 !important; color: #cdd6f4 !important; border-radius: 8px !important; padding: 9px 24px !important; } .swal2-cancel:hover { background: #45475a !important; } .swal2-icon { filter: invert(.9) hue-rotate(180deg); } `, // Windows 11:圆角、Mica 蓝 win11: ` .swal2-popup { border-radius: 12px !important; box-shadow: 0 24px 60px rgba(0,0,0,.28), 0 0 0 1px rgba(0,0,0,.06) !important; font-family: "Segoe UI Variable","Segoe UI",system-ui,sans-serif !important; } .swal2-title { font-weight: 600 !important; } .swal2-confirm { background: #0067c0 !important; border-radius: 6px !important; font-weight: 600 !important; padding: 9px 22px !important; } .swal2-confirm:hover { background: #1a78c8 !important; } .swal2-cancel { border-radius: 6px !important; padding: 9px 22px !important; } .swal2-cancel:hover { filter: brightness(.95); } .swal2-icon { border-radius: 50% !important; } `, // Windows 10:平面 + 强调蓝 win10: ` .swal2-popup { border-radius: 2px !important; box-shadow: 0 6px 24px rgba(0,0,0,.32) !important; font-family: "Segoe UI",system-ui,sans-serif !important; } .swal2-title { font-weight: 400 !important; } .swal2-confirm { background: #0078d4 !important; border-radius: 0 !important; font-weight: 600 !important; padding: 8px 24px !important; } .swal2-confirm:hover { background: #106ebe !important; } .swal2-cancel { border-radius: 0 !important; padding: 8px 24px !important; } .swal2-cancel:hover { filter: brightness(.95); } `, // Windows 8.1:全屏方块磁贴感 win81: ` .swal2-popup { border-radius: 0 !important; box-shadow: 0 0 0 2px #0067b8, 0 8px 30px rgba(0,0,0,.3) !important; font-family: "Segoe UI",system-ui,sans-serif !important; } .swal2-title { font-weight: 300 !important; letter-spacing: .5px; } .swal2-confirm { background: #0067b8 !important; border-radius: 0 !important; padding: 9px 28px !important; font-weight: 600 !important; } .swal2-confirm:hover { background: #005a9e !important; } .swal2-cancel { border-radius: 0 !important; padding: 9px 28px !important; } .swal2-cancel:hover { filter: brightness(.95); } `, // Windows 8:深蓝主题 win8: ` .swal2-popup { border-radius: 0 !important; box-shadow: 0 4px 20px rgba(0,0,0,.35) !important; font-family: "Segoe UI",system-ui,sans-serif !important; } .swal2-title { font-weight: 300 !important; } .swal2-confirm { background: #2d89ef !important; border-radius: 0 !important; padding: 9px 28px !important; } .swal2-confirm:hover { background: #2272c4 !important; } .swal2-cancel { border-radius: 0 !important; padding: 9px 28px !important; } .swal2-cancel:hover { filter: brightness(.95); } `, // Windows 7:玻璃蓝渐变 + 圆角 win7: ` .swal2-popup { border-radius: 6px !important; box-shadow: 0 0 0 1px #7ba2e0, 0 8px 28px rgba(0,0,0,.35) !important; font-family: "Segoe UI",system-ui,sans-serif !important; } .swal2-title { font-weight: 700 !important; text-shadow: 0 1px 0 rgba(255,255,255,.5); } .swal2-confirm { background: linear-gradient(#fdfefe,#c3daf7) !important; border: 1px solid #3c7fb1 !important; border-radius: 4px !important; padding: 6px 20px !important; text-shadow: 0 1px 0 #fff; } .swal2-confirm:hover { background: linear-gradient(#eaf4fd,#a8cef5) !important; } .swal2-cancel { background: linear-gradient(#fdfefe,#e7e7e7) !important; border: 1px solid #8a8a8a !important; border-radius: 4px !important; padding: 6px 20px !important; } .swal2-cancel:hover { background: linear-gradient(#f5f5f5,#d8d8d8) !important; } `, // Windows Vista:Aero 玻璃 + 发光 vista: ` .swal2-popup { border-radius: 10px !important; box-shadow: 0 0 0 1px #7ba2e0, 0 12px 40px rgba(0,60,130,.4) !important; font-family: "Segoe UI",system-ui,sans-serif !important; background: rgba(240,245,255,.97) !important; } .swal2-title { font-weight: 700 !important; } .swal2-confirm { background: linear-gradient(#5c9de6,#1b5fa8) !important; border: 1px solid #12406f !important; border-radius: 5px !important; color: #fff !important; padding: 7px 22px !important; } .swal2-confirm:hover { background: linear-gradient(#6ca7ea,#2268b2) !important; } .swal2-cancel { background: linear-gradient(#f0f5fb,#d3dde8) !important; border: 1px solid #8ba0b4 !important; border-radius: 5px !important; padding: 7px 22px !important; } .swal2-cancel:hover { background: linear-gradient(#e2ebf5,#c1cddb) !important; } `, // Windows XP:经典蓝绿「青柠」风 xp: ` .swal2-popup { border-radius: 8px !important; box-shadow: 0 0 0 1px #003c74, 0 8px 26px rgba(0,0,0,.35) !important; font-family: "Tahoma","Microsoft YaHei",sans-serif !important; } .swal2-title { font-weight: 700 !important; } .swal2-confirm { background: linear-gradient(#4b9cf5,#1c5aa6) !important; border: 1px solid #003c74 !important; border-radius: 5px !important; color: #fff !important; padding: 6px 20px !important; } .swal2-confirm:hover { background: linear-gradient(#5ca6f7,#2362b0) !important; } .swal2-cancel { background: linear-gradient(#f6f4ea,#cfcbb4) !important; border: 1px solid #7f7c64 !important; border-radius: 5px !important; padding: 6px 20px !important; } .swal2-cancel:hover { background: linear-gradient(#fffdf5,#ddd9c2) !important; } `, // Windows ME:纯平面,灰蓝经典 me: ` .swal2-popup { border-radius: 0 !important; box-shadow: 0 6px 20px rgba(0,0,0,.3) !important; font-family: "Tahoma","Microsoft Sans Serif",sans-serif !important; border: 1px solid #404040 !important; } .swal2-title { font-weight: 700 !important; } .swal2-confirm { border: 1px solid #404040 !important; border-radius: 0 !important; padding: 4px 18px !important; } .swal2-confirm:hover { filter: brightness(.95); } .swal2-cancel { border: 1px solid #404040 !important; border-radius: 0 !important; padding: 4px 18px !important; } .swal2-cancel:hover { filter: brightness(.95); } `, // Windows 98:经典立体浮雕边框 '98': ` .swal2-popup { border-radius: 0 !important; box-shadow: none !important; font-family: "Pixelated MS Sans Serif","MS Sans Serif","Tahoma",sans-serif !important; border-top: 2px solid #fff !important; border-left: 2px solid #fff !important; border-right: 2px solid #404040 !important; border-bottom: 2px solid #404040 !important; } .swal2-title { font-weight: 700 !important; } .swal2-confirm { border-top: 2px solid #fff !important; border-left: 2px solid #fff !important; border-right: 2px solid #404040 !important; border-bottom: 2px solid #404040 !important; border-radius: 0 !important; padding: 4px 18px !important; } .swal2-confirm:hover { filter: brightness(1.05); } .swal2-cancel { border-top: 2px solid #fff !important; border-left: 2px solid #fff !important; border-right: 2px solid #404040 !important; border-bottom: 2px solid #404040 !important; border-radius: 0 !important; padding: 4px 18px !important; } .swal2-cancel:hover { filter: brightness(1.05); } `, // Windows 3.x:程序管理器灰 + 标题栏渐变 '3x': ` .swal2-popup { border-radius: 0 !important; box-shadow: none !important; font-family: "MS Sans Serif","Tahoma",sans-serif !important; border-top: 2px solid #dfdfdf !important; border-left: 2px solid #dfdfdf !important; border-right: 2px solid #404040 !important; border-bottom: 2px solid #404040 !important; } .swal2-title { font-weight: 700 !important; background: linear-gradient(90deg,#000080,#1084d0) !important; padding: 3px 10px !important; margin: -1.25em -1.6em 1em !important; font-size: 13px !important; } .swal2-confirm { border-top: 2px solid #dfdfdf !important; border-left: 2px solid #dfdfdf !important; border-right: 2px solid #404040 !important; border-bottom: 2px solid #404040 !important; border-radius: 0 !important; padding: 3px 16px !important; font-size: 12px !important; } .swal2-cancel { border-top: 2px solid #dfdfdf !important; border-left: 2px solid #dfdfdf !important; border-right: 2px solid #404040 !important; border-bottom: 2px solid #404040 !important; border-radius: 0 !important; padding: 3px 16px !important; font-size: 12px !important; } `, // Windows 1.0 / 2.0:黑底白字单色复古终端风 '12': ` .swal2-popup { border-radius: 0 !important; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000 !important; font-family: "Perfect DOS VGA 437","Consolas","Courier New",monospace !important; background: #000 !important; } .swal2-title { font-weight: 700 !important; text-transform: uppercase; letter-spacing: 1px; } .swal2-html-container { color: #c0c0c0 !important; } .swal2-confirm { background: #000 !important; border: 2px solid #fff !important; border-radius: 0 !important; font-family: inherit !important; } .swal2-confirm:hover { background: #fff !important; } .swal2-cancel { background: #000 !important; border: 2px solid #fff !important; border-radius: 0 !important; font-family: inherit !important; } .swal2-cancel:hover { background: #fff !important; } .swal2-input, .swal2-textarea { background: #000 !important; border: 1px solid #fff !important; font-family: inherit !important; } ` }; // 获取基础主题 CSS let base = (THEMES[theme] || THEMES.win11); // 暗色模式覆盖层 const DARK_OVERRIDE = ` .swal2-popup { background: #1e1e2e !important; color: #cdd6f4 !important; box-shadow: 0 24px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08) !important; } .swal2-title { color: #cdd6f4 !important; } .swal2-html-container { color: #a6adc8 !important; } .swal2-confirm { background: #cba6f7 !important; color: #1e1e2e !important; } .swal2-confirm:hover { background: #b4befe !important; } .swal2-cancel { background: #313244 !important; color: #cdd6f4 !important; } .swal2-cancel:hover { background: #45475a !important; } .swal2-input, .swal2-textarea { background: #313244 !important; color: #cdd6f4 !important; border-color: #585b70 !important; } .swal2-icon { filter: invert(.85) hue-rotate(180deg); } `; // Win7/XP 等带渐变按钮的主题,暗色下需额外处理按钮 const DARK_BTN_OVERRIDE = ` .swal2-confirm { background: #cba6f7 !important; color: #1e1e2e !important; border-color: #cba6f7 !important; text-shadow: none !important; } .swal2-cancel { background: #313244 !important; color: #cdd6f4 !important; border-color: #585b70 !important; text-shadow: none !important; } `; // ===== 背景材质效果 ===== const EFFECTS = { none: ``, transparent: ` .swal2-popup { background: transparent !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; } .swal2-popup .swal2-title { text-shadow: 0 1px 3px rgba(0,0,0,.3); } `, blur: ` .swal2-popup { backdrop-filter: blur(12px) !important; -webkit-backdrop-filter: blur(12px) !important; } `, acrylic: ` .swal2-popup { backdrop-filter: blur(20px) saturate(180%) !important; -webkit-backdrop-filter: blur(20px) saturate(180%) !important; } .swal2-popup::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,.1), rgba(255,255,255,.03)); border-radius: inherit; pointer-events: none; z-index: -1; } `, mica: ` .swal2-popup { backdrop-filter: blur(30px) saturate(150%) brightness(1.05) !important; -webkit-backdrop-filter: blur(30px) saturate(150%) brightness(1.05) !important; } .swal2-popup::before { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.02) 50%, rgba(0,0,0,.02) 100%); border-radius: inherit; pointer-events: none; z-index: -1; } ` }; let result = base; // 应用背景材质(放在最外层,不随主题变) const effectCSS = EFFECTS[effect] || ''; // 暗色/亮色处理 if (dark) { result += DARK_OVERRIDE; if (['win7','vista','xp','me','98','3x'].includes(theme)) { result += DARK_BTN_OVERRIDE; } if (theme === 'win11' || theme === 'win10') { result += `.swal2-confirm { background: #4f46e5 !important; } .swal2-confirm:hover { background: #6366f1 !important; }`; } } else { result += this._getLightColors(theme); } // 透明效果在亮色下需要特殊处理背景色 let transparentOverride = ''; if (effect === 'transparent') { transparentOverride = dark ? `.swal2-popup { background: rgba(30,30,46,.85) !important; }` : `.swal2-popup { background: rgba(255,255,255,.85) !important; }`; } return result + effectCSS + transparentOverride + ` .swal2-popup { transition: width .2s, border-radius .2s !important; position: relative; } .swal2-actions { gap: 10px !important; } `; }, // 获取亮色模式的文字/背景色补充 _getLightColors(theme) { const LIGHT = { win11: `.swal2-title { color: #1b1b1b !important; } .swal2-html-container { color: #424242 !important; } .swal2-cancel { background: #e8e8e8 !important; color: #1b1b1b !important; } .swal2-cancel:hover { background: #dcdcdc !important; }`, win10: `.swal2-title { color: #323130 !important; } .swal2-cancel { background: #e6e6e6 !important; color: #323130 !important; } .swal2-cancel:hover { background: #d6d6d6 !important; }`, win81: `.swal2-title { color: #0067b8 !important; } .swal2-cancel { background: #f2f2f2 !important; color: #505050 !important; } .swal2-cancel:hover { background: #e0e0e0 !important; }`, win8: `.swal2-popup { background: #f0f0f0 !important; } .swal2-title { color: #2d89ef !important; } .swal2-cancel { background: #cccccc !important; color: #222 !important; } .swal2-cancel:hover { background: #bbbbbb !important; }`, win7: `.swal2-popup { background: #f5f6f7 !important; } .swal2-title { color: #104a8e !important; } .swal2-confirm { color: #0c3d6e !important; } .swal2-cancel { color: #333 !important; }`, vista: `.swal2-title { color: #12406f !important; } .swal2-confirm { color: #fff !important; } .swal2-cancel { color: #22405c !important; }`, xp: `.swal2-popup { background: #ece9d8 !important; } .swal2-title { color: #003c74 !important; } .swal2-confirm { color: #fff !important; } .swal2-cancel { color: #333 !important; }`, me: `.swal2-popup { background: #d4d0c8 !important; } .swal2-title { color: #000080 !important; } .swal2-confirm { background: #d4d0c8 !important; color: #000 !important; } .swal2-cancel { background: #d4d0c8 !important; color: #000 !important; } .swal2-html-container { color: #000 !important; }`, '98': `.swal2-popup { background: #c0c0c0 !important; } .swal2-title { color: #000 !important; } .swal2-html-container { color: #000 !important; } .swal2-confirm { background: #c0c0c0 !important; color: #000 !important; } .swal2-cancel { background: #c0c0c0 !important; color: #000 !important; }`, '3x': `.swal2-popup { background: #c0c0c0 !important; } .swal2-title { color: #fff !important; } .swal2-confirm { background: #c0c0c0 !important; color: #000 !important; } .swal2-cancel { background: #c0c0c0 !important; color: #000 !important; }`, '12': `.swal2-title { color: #fff !important; } .swal2-html-container { color: #c0c0c0 !important; } .swal2-confirm { color: #fff !important; } .swal2-cancel { color: #fff !important; } .swal2-input, .swal2-textarea { color: #fff !important; }` }; return LIGHT[theme] || LIGHT['win11']; }, // 应用自定义尺寸:动态写入尺寸变量 applySize(force) { const w = parseInt(util.getValue('setting_width')) || 500; const h = parseInt(util.getValue('setting_height')) || 280; let style = document.getElementById('panai-size-style'); if (!style) { style = document.createElement('style'); style.id = 'panai-size-style'; document.head.appendChild(style); } // 只限制内容区(html-container)高度,弹窗整体高度由 padding/内容自然撑开, // 避免整体 height 被锁死后截断底部按钮与确认栏。 style.innerHTML = ` .swal2-popup { width: ${w}px !important; max-width: 96vw !important; height: auto !important; } .swal2-popup .swal2-html-container { max-height: ${Math.max(h - 160, 60)}px; overflow-y: auto; } `; }, // 清除尺寸样式,避免影响后续弹窗 clearSize() { const style = document.getElementById('panai-size-style'); if (style) style.remove(); }, // 抽屉式:更新日志 + 支持网盘列表(最新版默认展开,历史版本折叠收纳,点击展开) showUpdateDrawer() { let overlay = document.getElementById('panai-overlay'); if (overlay) { overlay.style.display = 'flex'; return; } const logHtml = CHANGELOG.map((v, i) => { const open = i === 0; return ` v${v.version} ${v.date} ▶ ${v.items.map(it => `${it}`).join('')} `; }).join(''); const panHtml = PAN_GROUPS.map(([g, keys]) => { const chips = keys.map(k => { const o = opt[k]; if (!o) return ''; const pending = o._pending ? '(域名待补全)' : ''; return `${getPanIcon(o.icon, 18)}${o.name}${pending}`; }).join(''); return `${g}${chips}`; }).join(''); overlay = document.createElement('div'); overlay.id = 'panai-overlay'; overlay.className = 'panai-overlay'; overlay.innerHTML = ` 🔗 网盘智能识别助手 ✕ 📋 更新日志 🗂 支持网盘 ${logHtml} ${panHtml} 当前版本 v${VERSION} · 修改优化版 `; document.body.appendChild(overlay); const close = () => { overlay.style.display = 'none'; }; overlay.addEventListener('click', (e) => { if (e.target === overlay) close(); }); overlay.querySelector('#panai-drawer-close').addEventListener('click', close); // 标签切换 overlay.querySelectorAll('.panai-tab').forEach(t => { t.addEventListener('click', () => { overlay.querySelectorAll('.panai-tab').forEach(x => x.classList.remove('active')); t.classList.add('active'); overlay.querySelectorAll('.panai-panel').forEach(p => p.style.display = 'none'); const panel = overlay.querySelector(`.panai-panel[data-panel="${t.dataset.tab}"]`); if (panel) panel.style.display = 'block'; }); }); // 版本日志折叠/展开 overlay.querySelectorAll('.panai-log-head').forEach(h => { h.addEventListener('click', () => { const item = h.parentElement; const body = overlay.querySelector(`.panai-log-body[data-log-body="${h.dataset.log}"]`); const open = item.classList.toggle('open'); if (body) body.style.display = open ? '' : 'none'; }); }); overlay.style.display = 'flex'; this.applyTheme(); }, registerMenuCommand() { GM_registerMenuCommand('👀 已识别:' + util.getValue('setting_success_times') + '次', () => { this.clearIdentifyTimes(); }); GM_registerMenuCommand(`📋️ 识别剪切板中文字(快捷键 ${util.getValue('setting_hotkeys')})`, () => { this.showIdentifyBox(); }); GM_registerMenuCommand('📋 更新日志', () => { this.showUpdateDrawer(); }); GM_registerMenuCommand('⚙️ 设置', () => { this.showSettingBox(); }); }, addPluginStyle() { let style = ` /* ===== 深浅模式 CSS 变量 ===== */ .panai-overlay, .panai-container { --panai-bg: #ffffff; --panai-bg2: #f7f8fa; --panai-bg3: #f0f2f5; --panai-border: #e2e2e8; --panai-border2: #eef0f4; --panai-text: #1a1b26; --panai-text2: #4a4b57; --panai-text3: #6b6c78; --panai-accent: #6366f1; --panai-accent-hover: #818cf8; --panai-accent-text: #ffffff; --panai-shadow: rgba(0,0,0,.08); --panai-shadow-lg: rgba(0,0,0,.14); --panai-overlay: rgba(0,0,0,.4); --panai-tag-bg: rgba(99,102,241,.1); --panai-tag-text: #6366f1; } .panai-container.dark-mode, .panai-overlay.dark-mode { --panai-bg: #1e1e2e; --panai-bg2: #242436; --panai-bg3: #2d2d44; --panai-border: #3a3a52; --panai-border2: #313144; --panai-text: #cdd6f4; --panai-text2: #a6adc8; --panai-text3: #7c819c; --panai-accent: #cba6f7; --panai-accent-hover: #d8b9ff; --panai-accent-text: #1e1e2e; --panai-shadow: rgba(0,0,0,.3); --panai-shadow-lg: rgba(0,0,0,.5); --panai-overlay: rgba(0,0,0,.6); --panai-tag-bg: rgba(203,166,247,.15); --panai-tag-text: #cba6f7; } .panai-container { z-index: 99999!important } .panai-popup { font-size: 14px !important } .panai-setting-label { display: flex;align-items: center;justify-content: space-between;padding-top: 14px; cursor: pointer; } .panai-setting-checkbox { width: 16px;height: 16px; accent-color: var(--panai-accent); } /* ===== 设置面板:左右两栏网格布局 ===== */ .panai-set-wrap { text-align: left; padding: 4px 2px; } /* 左右两栏 */ .panai-set-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; } .panai-set-col { display: flex; flex-direction: column; gap: 16px; } /* 分区容器 */ .panai-set-section { border: 1px solid var(--panai-border); border-radius: 14px; overflow: hidden; background: var(--panai-bg); box-shadow: 0 1px 4px var(--panai-shadow); } .panai-set-section-bar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; background: linear-gradient(135deg, var(--panai-bg2), var(--panai-bg3)); border-bottom: 1px solid var(--panai-border2); } .panai-set-bar-ic { font-size: 16px; line-height: 1; } .panai-set-bar-tx { font-size: 14px; font-weight: 700; color: var(--panai-text); letter-spacing: .3px; } .panai-set-section-body { padding: 16px 18px 14px; } /* 字段行 */ .panai-set-field { padding: 5px 0; } .panai-set-field-label { font-size: 13px; font-weight: 600; color: var(--panai-text2); margin-bottom: 8px; } /* 单选按钮 */ .panai-set-radios { display: flex; gap: 8px; flex-wrap: wrap; } .panai-radios-full { width: 100%; } .panai-radio { display: inline-flex; align-items: center; gap: 5px; padding: 8px 18px; border: 1.5px solid var(--panai-border); border-radius: 22px; font-size: 13px; cursor: pointer; background: var(--panai-bg2); color: var(--panai-text2); transition: all .18s ease; user-select: none; white-space: nowrap; } .panai-radio input { display: none; } .panai-radio:hover { border-color: var(--panai-accent-hover); background: var(--panai-bg3); color: var(--panai-text); transform: translateY(-1px); } .panai-radio.on { background: var(--panai-accent); border-color: var(--panai-accent); color: var(--panai-accent-text); font-weight: 600; box-shadow: 0 3px 10px var(--panai-shadow); } /* 尺寸输入 */ .panai-set-size-vals { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--panai-text3); } .panai-size-box { position: relative; display: inline-flex; align-items: center; } .panai-size-box input { width: 78px; padding: 7px 26px 7px 10px; border: 1.5px solid var(--panai-border); border-radius: 8px; font-size: 13px; text-align: center; background: var(--panai-bg2); color: var(--panai-text); transition: border-color .15s; } .panai-size-box input:focus { outline: none; border-color: var(--panai-accent); box-shadow: 0 0 0 3px var(--panai-tag-bg); } .panai-size-box i { position: absolute; right: 8px; font-style: normal; font-size: 11px; color: var(--panai-text3); pointer-events: none; } .panai-size-unit { font-size: 12px; color: var(--panai-text3); margin-left: 2px; } /* 复选框行 */ .panai-setting-label { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; margin-bottom: 4px; cursor: pointer; border-radius: 10px; transition: background .15s; } .panai-setting-label:hover { background: var(--panai-bg2); } .panai-set-cb-label { font-size: 13px; color: var(--panai-text2); } .panai-setting-checkbox { width: 18px; height: 18px; accent-color: var(--panai-accent); cursor: pointer; } .panai-setting-range { gap: 12px; } .panai-setting-range input[type="range"] { flex: 1; max-width: 240px; accent-color: var(--panai-accent); height: 4px; } .panai-set-hotkey-input { width: 110px; padding: 7px 12px; border: 1.5px solid var(--panai-border); border-radius: 8px; font-size: 13px; text-align: center; background: var(--panai-bg2); color: var(--panai-text); font-family: 'SF Mono', 'Cascadia Code', monospace; } .panai-set-hotkey-input:focus { outline: none; border-color: var(--panai-accent); box-shadow: 0 0 0 3px var(--panai-tag-bg); } /* 主题选择卡片 - 网格 */ .panai-theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 520px; overflow-y: auto; padding-right: 4px; } .panai-theme-grid::-webkit-scrollbar { width: 6px; } .panai-theme-grid::-webkit-scrollbar-track { background: var(--panai-bg3); border-radius: 3px; } .panai-theme-grid::-webkit-scrollbar-thumb { background: var(--panai-border); border-radius: 3px; } .panai-theme-grid::-webkit-scrollbar-thumb:hover { background: var(--panai-text3); } .panai-theme-card { border: 2px solid var(--panai-border); border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--panai-bg2); transition: all .18s ease; } .panai-theme-card:hover { border-color: var(--panai-accent-hover); transform: translateY(-2px); box-shadow: 0 6px 16px var(--panai-shadow); } .panai-theme-card.active { border-color: var(--panai-accent); box-shadow: 0 3px 14px var(--panai-shadow); } .panai-theme-thumb { height: 36px; } .panai-theme-meta { display: flex; align-items: center; gap: 5px; padding: 6px 8px; font-size: 11px; color: var(--panai-text2); white-space: nowrap; overflow: hidden; } .panai-theme-ic { font-size: 12px; } .panai-theme-name { overflow: hidden; text-overflow: ellipsis; } /* 各主题缩略图 */ .panai-theme-thumb.t-light { background: linear-gradient(90deg,#ffffff 0%,#ffffff 50%,#e8e8f0 50%,#e8e8f0 100%); } .panai-theme-thumb.t-dark { background: linear-gradient(90deg,#1e1e2e 0%,#1e1e2e 50%,#313244 50%,#313244 100%); } .panai-theme-thumb.t-win11 { background: linear-gradient(135deg,#eaf3fc,#f7fbff); } .panai-theme-thumb.t-win10 { background: #0078d4; } .panai-theme-thumb.t-win81 { background: #0067b8; } .panai-theme-thumb.t-win8 { background: #2d89ef; } .panai-theme-thumb.t-win7 { background: linear-gradient(180deg,#5b9de0,#2b6fb0); } .panai-theme-thumb.t-vista { background: linear-gradient(135deg,#7ec0ff,#2a6fc4); } .panai-theme-thumb.t-xp { background: linear-gradient(180deg,#3b8ef5,#1c5aa6); } .panai-theme-thumb.t-me { background: #d4d0c8; } .panai-theme-thumb.t-98 { background: #c0c0c0; } .panai-theme-thumb.t-3x { background: linear-gradient(90deg,#000080,#1084d0); } .panai-theme-thumb.t-12 { background: #000; } /* 更新日志抽屉 */ .panai-overlay { position: fixed; inset: 0; z-index: 999999; background: var(--panai-overlay); display: flex; justify-content: flex-end; backdrop-filter: blur(2px); } .panai-drawer { width: 380px; max-width: 92vw; height: 100%; background: var(--panai-bg); color: var(--panai-text); box-shadow: -4px 0 24px var(--panai-shadow-lg); display: flex; flex-direction: column; animation: panai-slide .25s ease; } @keyframes panai-slide { from { transform: translateX(100%); } to { transform: translateX(0); } } .panai-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--panai-border2); } .panai-drawer-title { font-size: 16px; font-weight: 700; } .panai-drawer-close { border: none; background: var(--panai-bg3); width: 30px; height: 30px; border-radius: 50%; font-size: 14px; line-height: 1; cursor: pointer; color: var(--panai-text3); transition: all .15s; } .panai-drawer-close:hover { background: var(--panai-accent); color: var(--panai-accent-text); } .panai-drawer-tabs { display: flex; border-bottom: 1px solid var(--panai-border2); } .panai-tab { flex: 1; padding: 11px; border: none; background: var(--panai-bg2); cursor: pointer; font-size: 13px; color: var(--panai-text3); transition: all .15s; } .panai-tab:hover { background: var(--panai-bg3); } .panai-tab.active { background: var(--panai-bg); color: var(--panai-accent); font-weight: 600; border-bottom: 2px solid var(--panai-accent); } .panai-drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; } .panai-drawer-foot { padding: 12px 16px; border-top: 1px solid var(--panai-border2); font-size: 12px; color: var(--panai-text3); text-align: center; } .panai-log-item { border: 1px solid var(--panai-border2); border-radius: 10px; margin-bottom: 10px; overflow: hidden; } .panai-log-head { padding: 11px 13px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; background: var(--panai-bg2); font-size: 13px; font-weight: 600; color: var(--panai-text); transition: background .15s; } .panai-log-head:hover { background: var(--panai-bg3); } .panai-log-ver { color: var(--panai-accent); } .panai-log-tag { background: var(--panai-tag-bg); color: var(--panai-tag-text); font-size: 11px; font-weight: 400; padding: 2px 8px; border-radius: 10px; } .panai-log-arrow { font-size: 10px; color: var(--panai-text3); transition: transform .2s; } .panai-log-item.open .panai-log-arrow { transform: rotate(90deg); } .panai-log-body { padding: 10px 13px; font-size: 12px; color: var(--panai-text2); line-height: 1.9; } .panai-log-line { padding-left: 14px; position: relative; } .panai-log-line::before { content: '•'; position: absolute; left: 0; color: var(--panai-accent); } .panai-group-title { font-size: 13px; font-weight: 700; color: var(--panai-text); margin: 14px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--panai-border2); } .panai-group-title:first-child { margin-top: 0; } .panai-pan-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; } .panai-pan-chip { display: flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--panai-border2); border-radius: 8px; font-size: 12px; color: var(--panai-text2); background: var(--panai-bg2); overflow: hidden; white-space: nowrap; } .panai-pan-chip > span.panai-pan-icon { width: 18px; height: 18px; flex-shrink: 0; } .panai-pan-icon { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; } .panai-pan-icon svg { width: 100%; height: 100%; display: block; } .panai-pan-icon--circle { border-radius: 50%; overflow: hidden; background: var(--panai-bg3); padding: 2px; box-sizing: border-box; } .panai-result-title { display: flex; align-items: center; gap: 8px; } .panai-result-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 24px; height: 24px; } .panai-result-icon svg { width: 100%; height: 100%; display: block; } .panai-result-name { color: var(--panai-accent); margin: 0 4px; } .panai-pan-name { overflow: hidden; text-overflow: ellipsis; } .panai-pan-pending { color: #d14529; font-size: 11px; margin-left: 2px; } `; if (document.head) { util.addStyle('swal-pub-style', 'style', GM_getResourceText('swalStyle')); util.addStyle('panai-style', 'style', style); } const headObserver = new MutationObserver(() => { util.addStyle('swal-pub-style', 'style', GM_getResourceText('swalStyle')); util.addStyle('panai-style', 'style', style); }); headObserver.observe(document.head, {childList: true, subtree: true}); }, isTopWindow() { return window.self === window.top; }, init() { this.initValue(); this.addPluginStyle(); this.addHotKey(); this.autoFillPassword(); this.addPageListener(); this.isTopWindow() && this.registerMenuCommand(); this.checkVersionAndShowChangelog(); }, // 检测首次使用或版本更新,自动弹出更新日志 checkVersionAndShowChangelog() { const lastVersion = util.getValue('setting_last_version'); if (lastVersion !== VERSION) { util.setValue('setting_last_version', VERSION); // 延迟弹出,确保样式已加载 setTimeout(() => { this.showUpdateDrawer(); }, 800); } }, }; main.init(); })();