// ==UserScript== // @name 夜间护眼助手 // @namespace Local // @version 5.7.2 // @description 全网通用夜间护眼助手,深度优化123云盘夜间模式,恢复影视反色模式,优化代码页面显示,新增豆沙绿背景护眼模式(可全局/专用切换) // @match *://*/* // @run-at document-start // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @icon data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8Y2lyY2xlIGN4PSI2NCIgY3k9IjY0IiByPSI2NCIgZmlsbD0iIzQyNGE2ZSIvPgogICAgPHBhdGggZD0iTTY0IDMwQzgyIDMwIDk2IDQ2IDk2IDY0Qzk2IDgyIDgyIDk4IDY0IDk4QzQ2IDk4IDMyIDgyIDMyIDY0QzMyIDQ2IDQ2IDMwIDY0IDMwWiIgZmlsbD0id2hpdGUiLz4KICAgIDxjaXJjbGUgY3g9IjY4IiBjeT0iNjQiIHI9IjIwIiBmaWxsPSIjYThjNmZmIiBvcGFjaXR5PSIwLjMiLz4KICAgIDxjaXJjbGUgY3g9IjcyIiBjeT0iNjAiIHI9IjEyIiBmaWxsPSIjYThjNmZmIiBvcGFjaXR5PSIwLjIiLz4KICAgIDxjaXJjbGUgY3g9Ijc2IiBjeT0iNTYiIHI9IjgiIGZpbGw9IiNhOGM2ZmYiIG9wYWNpdHk9IjAuMSIvPgogICAgPHBhdGggZD0iTTEwMCAyNUwxMDMgMzFMMTEwIDMzTDEwNCAzNUwxMDAgNDFMOTYgMzVMOTAgMzNMODggMzFMMTAwIDI1WiIgZmlsbD0id2hpdGUiLz4KICAgIDxjaXJjbGUgY3g9IjMwIiBjeT0iNDAiIHI9IjQiIGZpbGw9IndoaXRlIi8+CiAgICA8Y2lyY2xlIGN4PSI0MCIgY3k9IjkwIiByPSIzIiBmaWxsPSJ3aGl0ZSIvPgogICAgPGNpcmNsZSBjeD0iOTAiIGN5PSIyNSIgcj0iMi41IiBmaWxsPSJ3aGl0ZSIvPgogICAgPGNpcmNsZSBjeD0iMTEwIiBjeT0iNzAiIHI9IjIiIGZpbGw9IndoaXRlIi8+CiAgICA8Y2lyY2xlIGN4PSIyMCIgY3k9IjcwIiByPSIyIiBmaWxsPSJ3aGl0ZSIvPgogICAgPGNpcmNsZSBjeD0iMTAwIiBjeT0iMTAwIiByPSIyIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K // ==/UserScript== ;(function () { 'use strict'; // 存储所有菜单命令ID let menuCommands = []; let EyeProtect = { // 当前模式存储 currentMode: null, // 默认配置 defaults: { globalEnable: false, // 全局开关 enableList: [], // 启用列表(白名单) blacklist: [], // 禁用列表(黑名单) autoExclude: true, // 智能排除 forcedEnableList: [], // 强制启用列表 originThemeColor: '#ffffff', // 原始主题色 runDuringDay: true, // 白天保持开启 darkAuto: false, // 跟随浏览器暗色模式 customDayNight: '6:00|18:00', // 自定义昼夜时间 autoSwitch: '', // 自动切换模式 customDark1: '60|50', // 亮度模式设置 customDark2: '60|40|50|50', // 暖色模式设置 customDark3: '90', // 反色强度设置 dark3Exclude: 'img, .img, video, [style*="background"][style*="url"], svg, .video-player, .player, [class*="player"], [class*="Player"], [id*="player"], [id*="Player"], .plyr, .jw-player, .video-js', // 排除元素 inkModeConfig: '#343c3e|#ffffff|#4a5457|#5d696c|#009688|#26a69a', filterExcludeList: ['youku.com', 'v.youku.com', 'www.douyu.com', 'www.iqiyi.com', 'vip.iqiyi.com', 'mail.qq.com', 'live.kuaishou.com'], // 滤镜模式排除列表 siteSpecificModes: '{}' // 网站专用模式 }, // 初始化 init() { this.initConfig(); // 获取当前模式,修复可能的模式错误(允许light/dark/green) this.fixModeIssue(); // 立即应用基础样式(不等待DOM加载) this.applyImmediateMode(); // 延迟保存原始主题色 setTimeout(() => this.saveOriginThemeColor(), 1000); this.initMenu(); // 监听系统主题变化 if (window.matchMedia) { window.matchMedia('(prefers-color-scheme: dark)').addListener(() => { this.applyMode(); this.refreshMenu(); }); } // 监听全屏变化(用于滤镜模式) document.addEventListener("fullscreenchange", () => this.handleFullscreenChange()); document.addEventListener("webkitfullscreenchange", () => this.handleFullscreenChange()); document.addEventListener("mozfullscreenchange", () => this.handleFullscreenChange()); // 等待DOM加载完成后应用完整模式 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { setTimeout(() => { this.applyMode(); // 监听页面动态加载 this.observeDOMChanges(); }, 100); }); } else { setTimeout(() => { this.applyMode(); this.observeDOMChanges(); }, 100); } }, // 处理全屏变化 handleFullscreenChange() { if (this.isFullscreen()) { // 进入全屏时禁用滤镜模式 if (this.currentMode === 'filter') { this.disableFilterMode(); } } else { // 退出全屏时恢复滤镜模式 if (this.currentMode === 'filter' && this.shouldApplyMode()) { setTimeout(() => this.applyFilterMode(), 100); } } }, // 判断是否全屏 isFullscreen() { return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement; }, // 立即应用基础模式(在DOM加载前执行) applyImmediateMode() { // 检查是否应该应用模式 if (this.shouldApplyMode()) { // 创建通用的立即样式 let style = document.createElement('style'); style.id = 'eye-protect-immediate'; style.innerHTML = ` /* 立即模式 - 防止页面闪烁 */ html, body { transition: none !important; } `; // 立即插入到head中 if (document.head) { document.head.appendChild(style); } else { // 如果head不存在,直接插入到document document.documentElement.appendChild(style); } } }, // 修复模式问题:确保模式正确(现在允许light/dark/green) fixModeIssue() { let storedMode = this.getConfig('currentMode'); // 全局模式有效值:light, dark, green const validGlobalModes = ['light', 'dark', 'green']; // 如果存储的模式不是有效模式,重置为light if (!validGlobalModes.includes(storedMode)) { this.setConfig('currentMode', 'light'); this.currentMode = 'light'; } else { this.currentMode = storedMode; } }, // 初始化配置 initConfig() { for (let key in this.defaults) { let value = GM_getValue(key); if (value === undefined) { GM_setValue(key, this.defaults[key]); } } // 初始化当前模式 if (GM_getValue('currentMode') === undefined) { GM_setValue('currentMode', 'light'); this.currentMode = 'light'; } }, // 获取配置值 getConfig(key) { return GM_getValue(key); }, // 设置配置值 setConfig(key, value) { GM_setValue(key, value); }, // 保存原始主题色 saveOriginThemeColor() { let meta = document.querySelector('meta[name="theme-color"]'); if (meta && meta.content) { this.setConfig('originThemeColor', meta.content); } }, // 监听DOM变化(用于动态加载的页面) observeDOMChanges() { const observer = new MutationObserver((mutations) => { // 检查是否需要重新应用模式 let style = document.querySelector('style[id^="eye-protect-"]'); if (!style && this.shouldApplyMode()) { setTimeout(() => this.applyMode(), 100); } // 豆沙绿模式特殊处理:新插入的元素需要修正白色背景 if (this.shouldApplyMode() && this.getCurrentMode() === 'green') { this.fixWhiteBackgroundOnNewElements(mutations); } }); // 监听整个文档树的变化 observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'id'] }); }, // 豆沙绿模式:为新插入的元素修正白色背景 fixWhiteBackgroundOnNewElements(mutations) { const beanGreen = '#CCE8CF'; mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType === 1) { // 元素节点 this.applyGreenBackgroundToElement(node, beanGreen); // 处理子元素 if (node.querySelectorAll) { node.querySelectorAll('*').forEach(el => { this.applyGreenBackgroundToElement(el, beanGreen); }); } } }); }); }, // 判断是否为白天 isDaytime() { let time = this.getConfig('customDayNight').split('|'); let now = new Date(); let currentTime = now.getHours() * 60 + now.getMinutes(); let dayStart = this.timeToMinutes(time[0]); let dayEnd = this.timeToMinutes(time[1]); if (dayStart < dayEnd) { return currentTime >= dayStart && currentTime < dayEnd; } else { return currentTime >= dayStart || currentTime < dayEnd; } }, timeToMinutes(timeStr) { let parts = timeStr.split(':'); return parseInt(parts[0]) * 60 + parseInt(parts[1] || 0); }, // 获取当前应该应用的模式 getCurrentMode() { // 首先检查网站专用模式(最高优先级) let siteSpecificMode = this.getSiteSpecificMode(); if (siteSpecificMode && siteSpecificMode !== 'default') { return siteSpecificMode; } // 确保只有有效模式 let mode = this.currentMode || this.getConfig('currentMode'); const validGlobalModes = ['light', 'dark', 'green']; if (!validGlobalModes.includes(mode)) { mode = 'light'; this.setConfig('currentMode', 'light'); } // 如果启用了自动切换 if (this.getConfig('autoSwitch')) { let modes = this.getConfig('autoSwitch').split('|'); if (modes.length === 2) { // 自动切换中,值0=light,1=dark,2=green(扩展) if (this.isDaytime()) { mode = modes[0] === '1' ? 'dark' : (modes[0] === '2' ? 'green' : 'light'); } else { mode = modes[1] === '1' ? 'dark' : (modes[1] === '2' ? 'green' : 'light'); } } } // 如果跟随浏览器暗色模式 if (this.getConfig('darkAuto') && window.matchMedia) { let prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; if (prefersDark && mode === 'light') { mode = 'dark'; } } return mode; }, // 彻底清理所有样式和修改 cleanupAllStyles() { // 1. 移除所有样式标签 let styles = document.querySelectorAll('style[id^="eye-protect-"]'); styles.forEach(style => { style.remove(); }); // 2. 移除滤镜模式的SVG let svg = document.getElementById('eye-protect-filter-svg'); if (svg) svg.remove(); // 3. 恢复原始主题色 let meta = document.querySelector('meta[name="theme-color"]'); if (meta) { meta.content = this.getConfig('originThemeColor'); } // 4. 移除豆沙绿模式添加的内联背景(通过data属性标记) let elements = document.querySelectorAll('[data-eye-protect-bg]'); elements.forEach(element => { element.removeAttribute('data-eye-protect-bg'); element.style.backgroundColor = ''; }); // 5. 移除动态添加的内联样式(原有) let oldElements = document.querySelectorAll('[data-eye-protect]'); oldElements.forEach(element => { element.removeAttribute('data-eye-protect'); element.removeAttribute('style'); }); // 6. 移除滤镜模式特定样式 let filterStyle = document.getElementById('eye-protect-filter-style'); if (filterStyle) filterStyle.remove(); }, // 应用样式(带模式标识) applyStyle(css, modeId) { // 移除所有之前可能存在的样式 this.cleanupAllStyles(); let style = document.createElement('style'); style.id = 'eye-protect-' + modeId; style.setAttribute('data-eye-protect-mode', modeId); style.innerHTML = css; // 确保文档已准备好 if (document.head) { document.head.appendChild(style); } else { // 如果head不存在,等待它加载 const waitForHead = () => { if (document.head) { document.head.appendChild(style); } else { requestAnimationFrame(waitForHead); } }; waitForHead(); } // 标记body,方便调试 if (document.body) { document.body.setAttribute('data-eye-protect', 'enabled'); document.body.setAttribute('data-eye-mode', modeId); } }, // 获取网站专用模式 getSiteSpecificMode() { try { let host = location.host; let siteModesStr = this.getConfig('siteSpecificModes') || '{}'; let siteModes = {}; siteModes = JSON.parse(siteModesStr); return siteModes[host] || null; } catch (e) { return null; } }, // 设置网站专用模式 setSiteSpecificMode(mode) { try { let host = location.host; let siteModesStr = this.getConfig('siteSpecificModes') || '{}'; let siteModes = {}; siteModes = JSON.parse(siteModesStr); if (mode === 'default' || mode === null) { delete siteModes[host]; } else { siteModes[host] = mode; } this.setConfig('siteSpecificModes', JSON.stringify(siteModes)); } catch (e) { console.error('设置网站专用模式出错:', e); } }, // 应用通用夜间模式 applyOriginalDarkMode() { let style_30 = this.getConfig('customDark3') || '90'; let dark3Exclude = this.getConfig('dark3Exclude'); let style_31 = ` html { filter: invert(${style_30}%) !important; text-shadow: 0 0 0 !important; } ${dark3Exclude} { filter: invert(1) !important; } img[alt="[公式]"] { filter: none !important; } /* 滚动条样式 */ ::-webkit-scrollbar { height: 12px !important; width: 12px !important; } ::-webkit-scrollbar-thumb { border-radius: 0; border-color: transparent; border-style: dashed; background-color: #3f4752 !important; background-clip: padding-box; transition: background-color .32s ease-in-out; } ::-webkit-scrollbar-corner { background: #202020 !important; } ::-webkit-scrollbar-track { background-color: #22272e !important; } ::-webkit-scrollbar-thumb:hover { background: #3f4752 !important; } `; if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { style_31 = ` html { filter: invert(${style_30}%) !important; background-image: url(); text-shadow: 0 0 0 !important; } ${dark3Exclude} { filter: invert(1) !important; } img[alt="[公式]"] { filter: none !important; } `; } this.applyStyle(style_31, 'dark-mode-original'); }, // 判断是否为Firefox浏览器 isFirefox() { return /Firefox/i.test(navigator.userAgent); }, // 应用滤镜模式 applyFilterMode() { // 首先检查是否应该排除当前网站 let filterExcludeList = this.getConfig('filterExcludeList'); let host = location.host; if (filterExcludeList.includes(host)) { this.cleanupAllStyles(); return; } // 彻底清理所有样式 this.cleanupAllStyles(); // 创建SVG滤镜(非Firefox浏览器) if (!this.isFirefox() && !document.getElementById('eye-protect-filter-svg')) { this.createFilterSvg(); } // 创建滤镜样式 this.createFilterStyle(); // 设置深色主题色 this.applyThemeColor('#131313'); }, // 创建SVG滤镜 createFilterSvg() { let svgDom = ''; let div = document.createElementNS('http://www.w3.org/2000/svg', 'div'); div.innerHTML = svgDom; let frag = document.createDocumentFragment(); while (div.firstChild) frag.appendChild(div.firstChild); document.head.appendChild(frag); }, // 创建滤镜样式 createFilterStyle() { let filter = this.isFirefox() ? `filter: url('data:image/svg+xml;utf8,#eye-protect-filter') !important;` : '-webkit-filter: url(#eye-protect-filter) !important; filter: url(#eye-protect-filter) !important;'; let reverseFilter = this.isFirefox() ? `filter: url('data:image/svg+xml;utf8,#eye-protect-filter-reverse') !important;` : '-webkit-filter: url(#eye-protect-filter-reverse) !important; filter: url(#eye-protect-filter-reverse) !important;'; let css = ` @media screen { html { ${filter} scrollbar-color: #454a4d #202324; } /* Default Reverse rule */ img, video, iframe, canvas, :not(object):not(body) > embed, object, svg image, [style*="background:url"], [style*="background-image:url"], [style*="background: url"], [style*="background-image: url"], [background], twitterwidget, .sr-reader, .no-dark-mode, .sr-backdrop { ${reverseFilter} } [style*="background:url"] *, [style*="background-image:url"] *, [style*="background: url"] *, [style*="background-image: url"] *, input, [background] *, img[src^="https://s0.wp.com/latex.php"], twitterwidget .NaturalImage-image { -webkit-filter: none !important; filter: none !important; } /* Text contrast */ html { text-shadow: 0 0 0 !important; } /* Full screen */ .no-filter, :-webkit-full-screen, :-webkit-full-screen *, :-moz-full-screen, :-moz-full-screen *, :fullscreen, :fullscreen * { -webkit-filter: none !important; filter: none !important; } ::-webkit-scrollbar { background-color: #202324; color: #aba499; } ::-webkit-scrollbar-thumb { background-color: #454a4d; } ::-webkit-scrollbar-thumb:hover { background-color: #575e62; } ::-webkit-scrollbar-thumb:active { background-color: #484e51; } ::-webkit-scrollbar-corner { background-color: #181a1b; } /* Page background */ html { background: #fff !important; } } `; let style = document.createElement('style'); style.id = 'eye-protect-filter-style'; style.innerHTML = css; document.head.appendChild(style); }, // 禁用滤镜模式 disableFilterMode() { let style = document.getElementById('eye-protect-filter-style'); if (style) style.remove(); let svg = document.getElementById('eye-protect-filter-svg'); if (svg) svg.remove(); // 恢复原始主题色 this.applyThemeColor(this.getConfig('originThemeColor') || '#ffffff'); }, // 应用夜间模式 applyDarkMode() { // 彻底清理所有样式 this.cleanupAllStyles(); // 根据域名使用不同的处理逻辑 let hostname = window.location.hostname; let pathname = window.location.pathname; // 检查网站专用模式 let siteSpecificMode = this.getSiteSpecificMode(); if (siteSpecificMode === 'light') { // 如果网站专用模式是白天模式,清理样式 this.cleanupAllStyles(); return; } // 检查是否为JSON文件页面或特定的代码网页 if (this.isJsonOrCodePage(window.location.href)) { this.applyCodePageDarkMode(); } else if (hostname.includes('123pan.com') || hostname.includes('123865.com') || hostname.includes('123pan.cn') || hostname.includes('123-pan.com') || hostname.includes('123684.com')) { // 新增域名:123684.com this.apply123PanDarkMode(); } else if (hostname.includes('bilivod.com') || hostname.includes('bilivod2.cc') || hostname.includes('bilitv.top')) { this.applyBilivodDarkMode(); } else if (hostname.includes('lanzou')) { this.applyLanzouDarkMode(); } else { // 对于所有其他网站,都使用移植的通用夜间模式 this.applyOriginalDarkMode(); } // 设置主题色为深色 this.applyThemeColor('#131313'); }, // 判断是否为JSON文件页面或特定的代码网页 isJsonOrCodePage(url) { // 检查URL是否以.json结尾或包含.json if (url.endsWith('.json') || url.includes('.json?') || url.includes('.json#') || url.includes('.json&') || url.includes('.json/') || url.indexOf('.json') > -1) { return true; } // 检查页面内容类型是否为JSON const contentType = document.contentType || ''; if (contentType.includes('application/json') || contentType.includes('text/json')) { return true; } // 检查是否为特定的GitHub Raw文件代理 if (url.includes('edgeone.gh-proxy.org') && url.includes('raw.githubusercontent.com')) { return true; } // 检查是否为gh-proxy.org代理的GitHub Raw文件 if (url.includes('gh-proxy.org') && url.includes('raw.githubusercontent.com')) { return true; } // 检查是否为JSON配置文件 if (url.includes('shuyuan.xingmian.icu') && url.includes('/data/shuyuan/') && url.endsWith('.json')) { return true; } // 检查是否为dns.jingluo.love的JSON文件 if (url.includes('dns.jingluo.love') && url.endsWith('.json')) { return true; } // 检查scriptcat.org代码页面 if (url.includes('scriptcat.org') && url.includes('/code/')) { return true; } // 检查updategf.qytechs.cn代码页面 if (url.includes('updategf.qytechs.cn') && url.includes('/scripts/')) { return true; } // 检查页面内容是否为有效的JSON格式 try { if (document.body) { const bodyText = document.body.textContent.trim(); if ((bodyText.startsWith('{') && bodyText.endsWith('}')) || (bodyText.startsWith('[') && bodyText.endsWith(']'))) { JSON.parse(bodyText); return true; } } // 检查pre元素中的内容 const preElements = document.querySelectorAll('pre'); for (let pre of preElements) { const text = pre.textContent.trim(); if ((text.startsWith('{') && text.endsWith('}')) || (text.startsWith('[') && text.endsWith(']'))) { try { JSON.parse(text); return true; } catch (e) { // 不是有效的JSON } } } } catch (e) { // 不是有效的JSON,继续检查其他条件 } return false; }, // 应用主题色 applyThemeColor(color) { setTimeout(() => { let meta = document.querySelector('meta[name="theme-color"]'); if (meta) { meta.content = color; } else { let metaEle = document.createElement('meta'); metaEle.name = 'theme-color'; metaEle.content = color; if (document.head) { document.head.appendChild(metaEle); } } }, 100); }, // 通用代码页面夜间模式(用于JSON文件和特定代码页面) applyCodePageDarkMode() { let style_30 = this.getConfig('customDark3') || '90'; let css = ` /* 通用代码页面专用夜间模式(适用于JSON文件和代码页面) */ html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-color: #0d1117 !important; text-shadow: 0 0 0 !important; } /* 排除需要保持原始颜色的元素 */ img, svg, canvas, iframe, .icon, .logo, .avatar, [class*="icon"], [class*="Icon"], [src*=".svg"], [src*=".png"], [src*=".jpg"], [src*=".jpeg"], [src*=".gif"], [src*=".webp"], .code-preview img, .avatar img, pre img, code img, .hljs img { filter: invert(1) hue-rotate(180deg) !important; } body, html { background-color: #0d1117 !important; color: #c9d1d9 !important; } /* 代码查看器主区域 */ .container, .main-container, .wrapper, .content, .code-container, .script-container, .page-content, .main-content, body > div:not([class]):not([id]), div[class=""], div[id=""] { background-color: #0d1117 !important; color: #c9d1d9 !important; } /* 代码查看器头部 */ .header, .script-header, .page-header, .navbar, .nav, .top-bar, [class*="header"], [class*="Header"], .breadcrumb, .nav-bar, .header-bar, .title-bar { background-color: #161b22 !important; border-color: #30363d !important; color: #c9d1d9 !important; } /* 代码高亮区域 */ .code-viewer, .code-area, .editor-container, pre, code, .hljs, .prismjs, [class*="language-"], [class*="syntax-"], .CodeMirror, .cm-s-default, .code-mirror, .code-editor, .editor, .viewer, .source-code, .code-block, .code-snippet, div[style*="font-family:monospace"], div[style*="font-family: monospace"], div[style*="font-family:'Courier New'"], div[style*="font-family: 'Courier New'"], div[style*="font-family:Consolas"], div[style*="font-family: Consolas"], div[style*="font-family:Monaco"], div[style*="font-family: Monaco"] { background-color: #0d1117 !important; color: #c9d1d9 !important; } /* 代码行号和语法高亮 */ .line-numbers, .line-number, .linenumber, .ln, .lnum, td[class*="line"], td[class*="number"], td[style*="text-align:right"], td[style*="text-align: right"] { background-color: #161b22 !important; color: #8b949e !important; border-right-color: #30363d !important; } /* 代码关键字高亮 */ .keyword, .function, .class-name, .operator, .punctuation, .string, .comment, .variable, .constant, .built_in, .attr-name, .selector, .property, .number, .boolean { color: #d2a8ff !important; } /* JSON语法高亮增强 */ /* JSON键(字符串) */ span[style*="color: #000080"], span[style*="color:#000080"], span[style*="color: #001080"], span[style*="color:#001080"], .string, [class*="key"], [style*="color: rgb(0, 0, 128)"], [style*="color:rgb(0,0,128)"] { color: #79c0ff !important; font-weight: normal !important; } /* JSON字符串值 */ span[style*="color: #0451a5"], span[style*="color:#0451a5"], span[style*="color: #a31515"], span[style*="color:#a31515"], .value.string, [style*="color: rgb(4, 81, 165)"], [style*="color:rgb(4,81,165)"], [style*="color: rgb(163, 21, 21)"], [style*="color:rgb(163,21,21)"] { color: #a5d6ff !important; } /* JSON数字值 */ span[style*="color: #098658"], span[style*="color:#098658"], .number, [style*="color: rgb(9, 134, 88)"], [style*="color:rgb(9,134,88)"] { color: #56d364 !important; } /* JSON布尔值和null */ span[style*="color: #0000ff"], span[style*="color:#0000ff"], .boolean, .null, [style*="color: rgb(0, 0, 255)"], [style*="color:rgb(0,0,255)"] { color: #ff7b72 !important; } /* JSON标点符号(冒号、括号、逗号) */ span[style*="color: #000000"], span[style*="color:#000000"], .punctuation, [style*="color: rgb(0, 0, 0)"], [style*="color:rgb(0,0,0)"] { color: #c9d1d9 !important; } /* 用户脚本元数据区域 */ pre[style*="color: rgb(136, 136, 136)"], pre[style*="color:rgb(136,136,136)"], pre[style*="color:#888"], .user.js-header, .metadata-block, .meta, .userscript-meta { background-color: #161b22 !important; color: #8b949e !important; border: 1px solid #30363d !important; } /* 脚本说明区域 */ .description, .desc, .summary, .comment-block, .doc-block, [style*="color: rgb(102, 102, 102)"], [style*="color:rgb(102,102,102)"], [style*="color:#666"] { color: #8b949e !important; } /* 滚动条优化 */ ::-webkit-scrollbar { width: 12px !important; height: 12px !important; background-color: #0d1117 !important; } ::-webkit-scrollbar-thumb { background-color: #30363d !important; border: 2px solid #0d1117 !important; border-radius: 6px !important; } ::-webkit-scrollbar-thumb:hover { background-color: #444c56 !important; } ::-webkit-scrollbar-track { background-color: #161b22 !important; } ::-webkit-scrollbar-corner { background-color: #0d1117 !important; } /* 链接和按钮 */ a, a:link, a:visited { color: #58a6ff !important; } a:hover, a:active { color: #79b8ff !important; } button, .btn, .button, input[type="button"], input[type="submit"] { background-color: #238636 !important; color: #ffffff !important; border-color: #2ea043 !important; } button:hover, .btn:hover { background-color: #2ea043 !important; } /* 文本选择 */ ::selection { background-color: #1c6b48 !important; color: #ffffff !important; } /* Firefox兼容性 */ @-moz-document url-prefix() { html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-image: url() !important; background-color: #0d1117 !important; } /* Firefox滚动条 */ * { scrollbar-color: #30363d #0d1117 !important; scrollbar-width: thin !important; } } /* 通用文本颜色覆盖 */ p, span, div, h1, h2, h3, h4, h5, h6, li, label, strong, em, i, b, u, .text, .title, .name, .info, .desc, .content, .label, .tip, .hint, .help, [class*="text"], [class*="Text"], [class*="title"], [class*="Title"], [class*="name"], [class*="Name"], [class*="label"], [class*="Label"], [class*="desc"], [class*="Desc"], [class*="info"], [class*="Info"], [class*="content"], [class*="Content"], [class*="tip"], [class*="Tip"], [class*="hint"], [class*="Hint"], [class*="help"], [class*="Help"] { color: #c9d1d9 !important; } /* 输入框和表单 */ input, textarea, select, [class*="input"], [class*="Input"] { background-color: #0d1117 !important; color: #c9d1d9 !important; border-color: #30363d !important; } input::placeholder, textarea::placeholder { color: #8b949e !important; } /* JSON特定元素高亮增强 */ /* 确保所有pre元素都有正确的样式 */ pre { padding: 16px !important; border-radius: 6px !important; background-color: #161b22 !important; border: 1px solid #30363d !important; overflow-x: auto !important; margin: 1em 0 !important; } /* JSON行内高亮 */ span { transition: color 0.2s ease !important; } /* JSON折叠指示器 */ .json-formatter-row .json-formatter-toggle { color: #58a6ff !important; } `; this.applyStyle(css, 'dark-mode-code-page'); }, // 123云盘专用夜间模式 - 影视反色技术优化版(增强图片显示效果,对标蓝奏云) apply123PanDarkMode() { let style_30 = this.getConfig('customDark3') || '90'; let css = ` /* ====== 123云盘专用夜间模式(影视反色技术优化版) ====== */ /* 核心:采用影视反色模式的 filter:invert + hue-rotate 方案优化色彩 */ /* 增强:所有图片、视频、媒体元素均双重反色恢复原始色彩,完全对标蓝奏云效果 */ /* 全局基础 - 应用影视反色技术 */ html, body { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-color: #0f1115 !important; color: #e1e4e8 !important; } /* ====== 重点修复:顶部白色区域 ====== */ /* 顶部导航栏区域 - 强制深色背景,不受反色影响 */ header, .header, .top-header, .navbar, .ant-layout-header, .layout-header, .main-header, .page-header, [class*="header"], [class*="Header"], .nav-bar, .top-bar, .app-bar, .sticky-header, .fixed-header { filter: invert(1) hue-rotate(180deg) !important; background-color: #12141a !important; border-bottom-color: #2d333b !important; color: #ffffff !important; } /* 顶部导航栏内部元素 */ .header *, .navbar *, .top-header *, .ant-layout-header * { color: #ffffff !important; background-color: transparent !important; } /* 搜索框区域优化 */ .search-box, .search-container, .ant-input-search, .el-input, input[type="search"], input[type="text"], [class*="search"], [class*="Search"] { background-color: #272c36 !important; border-color: #444c56 !important; color: #e1e4e8 !important; } .ant-input::placeholder, input::placeholder, [placeholder] { color: #768390 !important; } /* ====== 核心优化:恢复蓝色元素(采用影视反色方案) ====== */ /* 蓝色按钮 - 通过反色恢复原始蓝色 */ .ant-btn-primary, .el-button--primary, .btn-primary, .primary-btn, button[type="primary"], [class*="primary"], [class*="Primary"], .ant-btn[type="primary"], .download-btn, .save-btn, button:contains("下载"), button:contains("分享"), button:contains("上传"), button:contains("新建") { filter: invert(1) hue-rotate(180deg) !important; background-color: #1890ff !important; border-color: #1890ff !important; color: #ffffff !important; } /* 蓝色链接和文字 */ a, a:link, a:visited, .ant-typography a, .link, .external-link, [href], [class*="link"], [class*="Link"] { filter: invert(1) hue-rotate(180deg) !important; color: #1890ff !important; } /* 蓝色图标和强调色 */ .blue-icon, .blue-text, [class*="blue"], [class*="Blue"], [style*="color: #1890ff"], [style*="color:#1890ff"], [style*="color: #1a7dff"] { filter: invert(1) hue-rotate(180deg) !important; color: #1890ff !important; } /* 蓝色背景区域 */ .blue-bg, .blue-area, [style*="background-color: #1890ff"], [style*="background-color:#1890ff"], [style*="background: #1890ff"], [style*="background:#1890ff"] { filter: invert(1) hue-rotate(180deg) !important; background-color: #1890ff !important; color: #ffffff !important; } /* ====== 文件列表区域 ====== */ /* 文件列表容器 */ .file-list, .list-container, .ant-list, .ant-table-wrapper, .list-wrapper, .file-container, .file-content, .file-area { background-color: #1a1d23 !important; } /* 文件项目 */ .file-item, .list-item, .ant-list-item, .ant-table-row, .file-row, .list-row { background-color: #20242c !important; border-color: #2d333b !important; color: #e1e4e8 !important; } /* 文件项目悬停效果 */ .file-item:hover, .ant-list-item:hover, .ant-table-row:hover { background-color: #272c36 !important; } /* 文件名称 */ .file-name, .item-name, .ant-list-item-meta-title, .ant-table-cell { color: #e1e4e8 !important; } /* 文件大小和日期 */ .file-size, .file-date, .file-meta, .ant-list-item-meta-description, .size, .date, .time, [class*="size"], [class*="date"], [class*="time"] { color: #adbac7 !important; } /* ====== 按钮和操作区域 ====== */ /* 普通按钮 */ .ant-btn, .el-button, button, .btn, .button, [class*="btn"], [class*="Button"] { background-color: #373e47 !important; border-color: #444c56 !important; color: #adbac7 !important; } .ant-btn:hover, .el-button:hover, button:hover, .btn:hover { background-color: #444c56 !important; border-color: #768390 !important; color: #cdd9e5 !important; } /* 次要按钮(灰色) */ .ant-btn-default, .el-button--default, .btn-default, .default-btn { background-color: #2d333b !important; border-color: #444c56 !important; color: #adbac7 !important; } /* 危险按钮(红色) */ .ant-btn-danger, .el-button--danger, .btn-danger, .danger-btn, button:contains("删除"), button:contains("移除") { filter: invert(1) hue-rotate(180deg) !important; background-color: #ff4d4f !important; border-color: #ff4d4f !important; color: #ffffff !important; } /* ====== 输入框和表单 ====== */ .ant-input, .ant-input-search, input, textarea, select, [class*="input"], [class*="Input"] { background-color: #272c36 !important; border-color: #444c56 !important; color: #e1e4e8 !important; } /* ====== 排除不需要反色的元素 ====== */ /* 所有图片、视频、媒体元素双重反色恢复原始色彩,完全对标蓝奏云效果 */ img, svg, video, canvas, iframe, .icon, .logo, .anticon, .qrcode, .code-img, .verify-img, .file-icon, .ant-avatar, .file-thumbnail, .preview-image, .ant-image-img, .ant-image-preview-img, .ad-container, .banner, [class*="icon"], [class*="Icon"], [src*=".svg"], [src*=".png"], [src*=".jpg"], [src*=".jpeg"], [src*=".gif"], [src*=".webp"], [src*=".bmp"], [src*=".ico"], [src*=".avif"], [style*="background-image"], [style*="background:url"], .cover, .poster, .thumbnail, .avatar, .file-preview, .img-container, [class*="thumb"], [class*="preview"], [class*="cover"], [class*="poster"], [class*="avatar"] { filter: invert(1) hue-rotate(180deg) !important; } /* ====== 滚动条优化 ====== */ ::-webkit-scrollbar { width: 12px !important; height: 12px !important; background-color: #0f1115 !important; } ::-webkit-scrollbar-thumb { background-color: #373e47 !important; border: 2px solid #0f1115 !important; border-radius: 6px !important; } ::-webkit-scrollbar-thumb:hover { background-color: #444c56 !important; } ::-webkit-scrollbar-track { background-color: #1a1d23 !important; } ::-webkit-scrollbar-corner { background-color: #0f1115 !important; } /* ====== Firefox兼容性 ====== */ @-moz-document url-prefix() { html, body { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-image: url() !important; background-color: #0f1115 !important; } /* Firefox滚动条 */ * { scrollbar-color: #373e47 #0f1115 !important; scrollbar-width: thin !important; } } /* ====== 通用背景色设置 ====== */ /* 主要背景色 */ html, body { background-color: #0f1115 !important; } div, section, main, article, nav, footer, aside, .app-container, .main-container, .container, .wrapper, .content, .main-content, .page-container, .root-container, body > div, [class*="container"], [class*="Container"] { background-color: #1a1d23 !important; } /* 侧边栏和菜单 */ .sidebar, .side-nav, .menu-container, .ant-layout-sider, .sider, .left-nav, [class*="sidebar"], [class*="Sidebar"], [class*="menu"], [class*="Menu"] { background-color: #16181f !important; border-right-color: #2d333b !important; } /* 卡片和面板 */ .card, .panel, .box, .block, [class*="card"], [class*="Card"], [class*="panel"], [class*="Panel"] { background-color: #20242c !important; border-color: #2d333b !important; color: #e1e4e8 !important; } /* 表格 */ table, .ant-table, [class*="table"], [class*="Table"] { background-color: #1a1d23 !important; color: #e1e4e8 !important; border-color: #2d333b !important; } th, .ant-table-thead > tr > th { background-color: #16181f !important; color: #e1e4e8 !important; border-color: #2d333b !important; } td, .ant-table-tbody > tr > td { background-color: #20242c !important; color: #e1e4e8 !important; border-color: #2d333b !important; } tr:hover td { background-color: #272c36 !important; } /* 文字颜色优化 */ p, span, div, h1, h2, h3, h4, h5, h6, li, label, strong, em, i, b, u, .text, .title, .name, .info, .desc, .content, .label, .tip, .hint, .help, .ant-typography, .ant-text, [class*="text"], [class*="Text"], [class*="title"], [class*="Title"], [class*="name"], [class*="Name"], [class*="label"], [class*="Label"], [class*="desc"], [class*="Desc"], [class*="info"], [class*="Info"], [class*="content"], [class*="Content"], [class*="tip"], [class*="Tip"], [class*="hint"], [class*="Hint"], [class*="help"], [class*="Help"] { color: #e1e4e8 !important; } `; this.applyStyle(css, 'dark-mode-123pan'); }, // bilivod.com及同类域名专用夜间模式 applyBilivodDarkMode() { let style_30 = this.getConfig('customDark3') || '90'; let css = ` /* bilivod.com及同类域名专用夜间模式 */ html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-color: #1a1a1a !important; text-shadow: 0 0 0 !important; } /* 排除不需要反色的元素 */ img, svg, video, canvas, iframe, .icon, .logo, .thumbnail, .avatar, [class*="icon"], [class*="Icon"], [src*=".svg"], [src*=".png"], [src*=".jpg"], [src*=".jpeg"], [src*=".gif"], [src*=".webp"], .video-player, .player, [class*="player"], [class*="Player"] { filter: invert(1) hue-rotate(180deg) !important; } body { background-color: #1a1a1a !important; } /* bilivod.com特定优化 */ body, div, section, main, article, nav, header, footer, aside, .container, .wrapper, .content, .main-content, .panel, .card, .box, .block, .list, .item, .entry, .video-list, .video-item, .vod-item { background-color: #1a1a1a !important; color: #d0d0d0 !important; border-color: #333 !important; } /* 强力覆盖所有内联白色背景 */ [style*="background-color: white"], [style*="background: white"], [style*="background:#fff"], [style*="background-color:#fff"], [style*="background-color: #fff"], [style*="background-color: #ffffff"] { background-color: #1a1a1a !important; } /* 导航栏和头部 */ .header, .navbar, .nav, .top-bar, .menu, .toolbar, .bar { background-color: #222 !important; } /* 按钮和表单 */ button, .btn, .button, input, textarea, select { background-color: #2a2a2a !important; color: #e0e0e0 !important; border-color: #444 !important; } /* 链接和蓝色区域 */ a, a:link, a:visited { color: #ff7700 !important; } a:hover { color: #ff9933 !important; } .btn-primary, .primary, .blue { background-color: #ff7700 !important; } /* 滚动条 */ ::-webkit-scrollbar { background-color: #1a1a1a !important; } ::-webkit-scrollbar-thumb { background-color: #444 !important; } ::-webkit-scrollbar-thumb:hover { background-color: #555 !important; } ::-webkit-scrollbar-track { background-color: #222 !important; } /* Firefox兼容性 */ @-moz-document url-prefix() { html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-image: url() !important; background-color: #1a1a1a !important; } } `; this.applyStyle(css, 'dark-mode-bilivod'); }, // 蓝奏云优化的反色模式(增强:所有文字、按钮、状态标签均使用专业配色,无额外滤镜干扰) applyLanzouDarkMode() { let style_30 = this.getConfig('customDark3') || '90'; let css = ` /* ====== 蓝奏云夜间模式优化版(图片完美还原,文字高对比) ====== */ /* 核心:全局反色 + hue旋转,图片双重反色恢复原始色彩 */ /* 优化:文件列表文字、按钮、状态标签使用专门配色,完全对标图1效果 */ html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-color: #1a1a1a !important; text-shadow: 0 0 0 !important; } /* ---------- 媒体元素:双重反色恢复原始色彩 ---------- */ img, svg, video, canvas, iframe, .icon, .logo, .qrcode, .code-img, .avatar, .thumbnail, .preview, [class*="icon"], [class*="Icon"], [src*=".svg"], [src*=".png"], [src*=".jpg"], [src*=".jpeg"], [src*=".gif"], [src*=".webp"], [src*=".bmp"], [src*=".ico"], [style*="background-image"], [style*="background:url"], [class*="thumb"], [class*="preview"], [class*="cover"] { filter: invert(1) hue-rotate(180deg) !important; } /* ---------- 基础背景色 ---------- */ body, html { background-color: #1a1a1a !important; color: #e0e0e0 !important; } /* ---------- 全局容器 ---------- */ div, section, main, article, nav, header, footer, aside, .container, .wrapper, .content, .main, .panel, .box { background-color: #1a1a1a !important; color: #e0e0e0 !important; } /* ---------- 文件列表区域 ---------- */ .file-list, .folder-list, .data-list, .table, .list-container, .list-box { background-color: #222 !important; border: 1px solid #333 !important; } /* ---------- 文件/文件夹项目 ---------- */ .file-item, .folder-item, .list-item, tr, .data-item, .list-row { background-color: #2a2a2a !important; color: #e0e0e0 !important; border-color: #333 !important; } /* ---------- 文件名、大小、日期等文本 ---------- */ .file-item .name, .folder-item .name, .file-item a, .folder-item a, .file-list .name, .file-list .size, .file-list .time, td:nth-child(2), td:nth-child(3), td:nth-child(4), [class*="file-name"], [class*="file-size"], [class*="file-date"], [class*="item-name"], [class*="item-size"], [class*="item-date"] { color: #e0e0e0 !important; } /* ---------- 下载按钮 ---------- */ .download-btn, .btn-download, .down, button[onclick*="download"], a[href*="down"], .file-item .download, .list-download { filter: invert(1) hue-rotate(180deg) !important; background-color: #0066cc !important; color: white !important; border: 1px solid #0066cc !important; border-radius: 4px !important; padding: 4px 12px !important; font-weight: normal !important; } .download-btn:hover, .btn-download:hover { filter: invert(1) hue-rotate(180deg) !important; background-color: #0080ff !important; border-color: #0080ff !important; } /* ---------- 普通按钮和表单 ---------- */ button, .btn, input[type="button"], input[type="submit"] { filter: invert(1) hue-rotate(180deg) !important; background-color: #0066cc !important; color: white !important; border: 1px solid #0066cc !important; } button:hover, .btn:hover { filter: invert(1) hue-rotate(180deg) !important; background-color: #0080ff !important; border-color: #0080ff !important; } /* ---------- 输入框 ---------- */ input, textarea, select, .form-control { background-color: #2a2a2a !important; color: #e0e0e0 !important; border: 1px solid #444 !important; } /* ---------- 链接颜色 ---------- */ a, a:link, a:visited { filter: invert(1) hue-rotate(180deg) !important; color: #66aaff !important; } a:hover, a:active { filter: invert(1) hue-rotate(180deg) !important; color: #88ccff !important; } /* ---------- 滚动条 ---------- */ ::-webkit-scrollbar { width: 12px !important; height: 12px !important; background-color: #222 !important; } ::-webkit-scrollbar-thumb { background-color: #444 !important; border-radius: 6px !important; } ::-webkit-scrollbar-thumb:hover { background-color: #555 !important; } ::-webkit-scrollbar-track { background-color: #1a1a1a !important; } /* ---------- Firefox兼容性 ---------- */ @-moz-document url-prefix() { html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-image: url() !important; background-color: #1a1a1a !important; } /* Firefox滚动条 */ * { scrollbar-color: #444 #1a1a1a !important; scrollbar-width: thin !important; } } `; this.applyStyle(css, 'dark-mode-lanzou'); }, // 应用墨黑模式 applyInkMode() { this.cleanupAllStyles(); let config = this.getConfig('inkModeConfig').split('|'); let backgroundColor = config[0] || '#343c3e'; let textColor = config[1] || '#ffffff'; let secondaryBg = config[2] || '#4a5457'; let borderColor = config[3] || '#5d696c'; let primaryColor = config[4] || '#009688'; let hoverColor = config[5] || '#26a69a'; let css = this.generateInkModeCSS(backgroundColor, textColor, secondaryBg, borderColor, primaryColor, hoverColor); this.applyStyle(css, 'ink-mode'); this.applyThemeColor(backgroundColor); }, // 应用影视反色模式(保留,仅用于已有配置) applyVideoInvertMode() { let style_30 = this.getConfig('customDark3') || '90'; let css = ` /* ====== 影视反色模式(基于bilivod.com技术) ====== */ /* 特色:通过反色+hue旋转创造柔和影视色调,适合视频类网站 */ /* 核心滤镜:反色+色调旋转 */ html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-color: #0a0a0a !important; text-shadow: 0 0 0 !important; } /* 恢复媒体元素原始色彩 */ img, svg, video, canvas, iframe, .icon, .logo, .thumbnail, .avatar, [class*="icon"], [class*="Icon"], [src*=".svg"], [src*=".png"], [src*=".jpg"], [src*=".jpeg"], [src*=".gif"], [src*=".webp"], .video-player, .player, [class*="player"], [class*="Player"], [id*="player"], [id*="Player"], .plyr, .jw-player, .video-js, .ad-container, .banner, .qrcode, .code-img, .preview-image, .cover-image { filter: invert(1) hue-rotate(180deg) !important; } /* 基础背景色 */ body, html { background-color: #0a0a0a !important; color: #cccccc !important; } /* 通用容器深色背景 */ body, div, section, main, article, nav, header, footer, aside, .container, .wrapper, .content, .main-content, .panel, .card, .box, .block, .list, .item, .entry, .video-list, .video-item, .vod-item, .movie-list, .film-list, .tv-list, [class*="container"], [class*="Container"], [class*="wrapper"], [class*="Wrapper"], [class*="content"], [class*="Content"] { background-color: #0a0a0a !important; color: #cccccc !important; border-color: #333333 !important; } /* 强力覆盖白色内联背景 */ [style*="background-color: white"], [style*="background: white"], [style*="background:#fff"], [style*="background-color:#fff"], [style*="background-color: #fff"], [style*="background-color: #ffffff"], [style*="background: #fff"], [style*="background: #ffffff"] { background-color: #0a0a0a !important !important; } /* 导航栏和头部区域 */ .header, .navbar, .nav, .top-bar, .menu, .toolbar, .bar, [class*="header"], [class*="Header"], [class*="navbar"], [class*="Navbar"], [class*="nav"], [class*="Nav"] { background-color: #121212 !important; border-color: #333333 !important; } /* 按钮和表单元素 */ button, .btn, .button, input, textarea, select, [class*="btn"], [class*="Button"], [class*="input"], [class*="Input"] { background-color: #1a1a1a !important; color: #e0e0e0 !important; border-color: #444444 !important; } /* 链接颜色优化 */ a, a:link, a:visited { color: #ff6600 !important; } a:hover, a:active { color: #ff8833 !important; } /* 主要按钮(橙色主题) */ .btn-primary, .primary, .blue, button:contains("播放"), button:contains("观看"), button:contains("下载"), button:contains("收藏") { filter: invert(1) hue-rotate(180deg) !important; background-color: #ff6600 !important; border-color: #ff6600 !important; color: #ffffff !important; } /* 滚动条优化 */ ::-webkit-scrollbar { width: 12px !important; height: 12px !important; background-color: #0a0a0a !important; } ::-webkit-scrollbar-thumb { background-color: #333333 !important; border-radius: 6px !important; } ::-webkit-scrollbar-thumb:hover { background-color: #444444 !important; } ::-webkit-scrollbar-track { background-color: #121212 !important; } ::-webkit-scrollbar-corner { background-color: #0a0a0a !important; } /* 列表和表格 */ table, .table, .list, .data-table, [class*="table"], [class*="Table"], [class*="list"], [class*="List"] { background-color: #0a0a0a !important; color: #cccccc !important; border-color: #333333 !important; } th, .table-header, thead th { background-color: #121212 !important; color: #cccccc !important; } td, .table-cell, tbody td { background-color: #0a0a0a !important; color: #cccccc !important; } tr:hover td, .table-row:hover { background-color: #1a1a1a !important; } /* 卡片和面板 */ .card, .panel, .box, [class*="card"], [class*="Card"], [class*="panel"], [class*="Panel"] { background-color: #121212 !important; color: #cccccc !important; border-color: #333333 !important; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important; } /* 文字颜色通用设置 */ p, span, div, h1, h2, h3, h4, h5, h6, li, label, strong, em, i, b, u, .text, .title, .name, .info, .desc, .content, .label, .tip, .hint, .help, .ant-typography, .ant-text, [class*="text"], [class*="Text"], [class*="title"], [class*="Title"], [class*="name"], [class*="Name"], [class*="label"], [class*="Label"], [class*="desc"], [class*="Desc"], [class*="info"], [class*="Info"], [class*="content"], [class*="Content"], [class*="tip"], [class*="Tip"], [class*="hint"], [class*="Hint"], [class*="help"], [class*="Help"] { color: #cccccc !important; } /* 输入框占位符 */ ::placeholder, .ant-input::placeholder, input::placeholder, textarea::placeholder { color: #888888 !important; } /* Firefox兼容性 */ @-moz-document url-prefix() { html { filter: invert(${style_30}%) hue-rotate(180deg) !important; background-image: url() !important; background-color: #0a0a0a !important; } /* Firefox滚动条 */ * { scrollbar-color: #333333 #0a0a0a !important; scrollbar-width: thin !important; } } /* 深色主题色 */ meta[name="theme-color"] { content: "#0a0a0a" !important; } `; this.applyStyle(css, 'video-invert-mode'); this.applyThemeColor('#0a0a0a'); }, // 生成墨黑模式CSS generateInkModeCSS(bgColor, textColor, secondaryBg, borderColor, primaryColor, hoverColor) { return ` /* 墨黑模式 */ html, body { background-color: ${bgColor} !important; color: ${textColor} !important; } div, section, main, article, nav, header, footer, aside, .container, .wrapper, .content, .card, .box { background-color: ${bgColor} !important; color: ${textColor} !important; border-color: ${borderColor} !important; } p, span, h1, h2, h3, h4, h5, h6 { color: ${textColor} !important; } a, a:link, a:visited { color: ${primaryColor} !important; } a:hover, a:active { color: ${hoverColor} !important; } button, .btn, input[type="button"], input[type="submit"] { background-color: ${secondaryBg} !important; color: ${textColor} !important; border-color: ${borderColor} !important; } button:hover, .btn:hover { background-color: ${primaryColor} !important; border-color: ${primaryColor} !important; } input, textarea, select { background-color: ${secondaryBg} !important; color: ${textColor} !important; border-color: ${borderColor} !important; } input:focus, textarea:focus { border-color: ${primaryColor} !important; } table, tr, th, td { background-color: ${bgColor} !important; color: ${textColor} !important; border-color: ${borderColor} !important; } th { background-color: ${secondaryBg} !important; } tr:nth-child(even) { background-color: ${secondaryBg} !important; } ::-webkit-scrollbar { width: 12px !important; height: 12px !important; background-color: ${secondaryBg} !important; } ::-webkit-scrollbar-thumb { background-color: ${borderColor} !important; } ::-webkit-scrollbar-thumb:hover { background-color: ${primaryColor} !important; } `; }, // ================ 新增:豆沙绿背景护眼模式 ================ // 固定豆沙绿颜色值 beanGreenColor: '#CCE8CF', // 应用豆沙绿模式 applyGreenMode() { // 彻底清理所有样式 this.cleanupAllStyles(); // 1. 创建全局CSS样式,强制设置html/body背景色,并覆盖常见白色背景 let css = ` /* 豆沙绿护眼背景模式 */ html, body { background-color: ${this.beanGreenColor} !important; } /* 强制覆盖所有可能的白色背景(内联样式) */ [style*="background-color: white"], [style*="background: white"], [style*="background:#fff"], [style*="background-color:#fff"], [style*="background-color: #fff"], [style*="background-color: #ffffff"], [style*="background: #fff"], [style*="background: #ffffff"], [style*="background-color:rgb(255,255,255)"], [style*="background-color: rgb(255,255,255)"], [style*="background-color: rgb(255, 255, 255)"] { background-color: ${this.beanGreenColor} !important; } /* 常见白色背景类名 */ .bg-white, .bgWhite, .white-bg, [class*="bg-white"], [class*="bg_white"], [class*="background-white"], [class*="background_white"] { background-color: ${this.beanGreenColor} !important; } /* 强制覆盖常见的白色容器 */ .card, .panel, .box, .container, .wrapper, .content, .main, .section, .article, header, footer, nav, aside, div[class*="container"], div[class*="wrapper"] { background-color: ${this.beanGreenColor} !important; } /* 滚动条保持中性 */ ::-webkit-scrollbar { background-color: #d4e8d7 !important; } ::-webkit-scrollbar-thumb { background-color: #a0b9a3 !important; } /* Firefox滚动条 */ @-moz-document url-prefix() { * { scrollbar-color: #a0b9a3 #d4e8d7 !important; } } `; this.applyStyle(css, 'green-mode'); // 2. 一次性遍历现有元素,修正白色背景(避免漏网之鱼) this.fixExistingWhiteBackgrounds(); // 3. 设置主题色为豆沙绿相近色 this.applyThemeColor('#C0D8C0'); }, // 遍历现有元素,将纯白背景的元素替换为豆沙绿 fixExistingWhiteBackgrounds() { if (!document.body) return; const elements = document.querySelectorAll('*'); elements.forEach(el => { this.applyGreenBackgroundToElement(el, this.beanGreenColor); }); }, // 单个元素背景修正逻辑 applyGreenBackgroundToElement(element, color) { // 跳过已处理的元素 if (element.hasAttribute('data-eye-protect-bg')) return; // 跳过 body/html,因为已经通过CSS设置 if (element.tagName === 'HTML' || element.tagName === 'BODY') return; const bg = window.getComputedStyle(element).backgroundColor; const rgb = bg.match(/\d+/g); if (rgb && rgb.length === 3) { const [r, g, b] = rgb.map(Number); // 纯白或非常接近白色(允许容差) if (r > 240 && g > 240 && b > 240) { element.style.backgroundColor = color; element.setAttribute('data-eye-protect-bg', 'green'); } } }, // 是否应该排除当前网站 shouldExcludeSite() { let hostname = window.location.hostname; // 对于特定网站,我们使用专门的处理逻辑 if (hostname.includes('bilivod.com') || hostname.includes('bilivod2.cc') || hostname.includes('bilitv.top') || hostname.includes('lanzou') || hostname.includes('scriptcat.org') || hostname.includes('updategf.qytechs.cn')) { return false; } let forcedList = this.getConfig('forcedEnableList'); if (forcedList.includes(location.host)) { return false; } // 通用排除逻辑 let html = document.documentElement; let body = document.body; if (document.querySelector('head>meta[name="color-scheme"],head>link[href^="resource:"]')) { return true; } if (html.className && (html.className.includes('dark') || body.className && body.className.includes('dark'))) { return true; } if (html.getAttribute('data-theme') && html.getAttribute('data-theme').includes('dark')) { return true; } if (html.getAttribute('data-color-mode') && html.getAttribute('data-color-mode').includes('dark')) { return true; } return false; }, // 是否应该应用模式 shouldApplyMode() { let globalEnable = this.getConfig('globalEnable'); let enableList = this.getConfig('enableList'); let blacklist = this.getConfig('blacklist'); let forcedList = this.getConfig('forcedEnableList'); let host = location.host; // 第一步:检查黑名单(最高优先级) if (blacklist.includes(host)) { return false; } // 第二步:检查强制启用列表(修改:受全局开关和白名单影响) if (forcedList.includes(host)) { // 强制启用需要满足:全局开关开启 或 该网站在白名单中 if (globalEnable || enableList.includes(host)) { return true; } return false; } // 第三步:检查全局开关 if (globalEnable) { return true; } // 第四步:检查白名单 if (enableList.includes(host)) { return true; } // 都不满足,不应用模式 return false; }, // 切换黑名单状态 toggleBlacklist() { let blacklist = this.getConfig('blacklist'); let host = location.host; if (blacklist.includes(host)) { blacklist = blacklist.filter(domain => domain !== host); this.setConfig('blacklist', blacklist); this.showNotification('已将当前网站从黑名单中移除'); if (this.shouldApplyMode()) { this.applyMode(); } } else { blacklist.push(host); this.setConfig('blacklist', blacklist); this.showNotification('已将当前网站添加到黑名单'); this.cleanupAllStyles(); } this.refreshMenu(); }, // 清空黑名单 clearBlacklist() { if (confirm('确定要清空黑名单吗?这将移除所有在黑名单中的网站。')) { this.setConfig('blacklist', []); this.showNotification('已清空黑名单'); this.refreshMenu(); } }, // 清空强制启用列表 clearForcedList() { if (confirm('确定要清空强制启用列表吗?这将移除所有强制启用的网站。')) { this.setConfig('forcedEnableList', []); this.showNotification('已清空强制启用列表'); this.applyMode(); this.refreshMenu(); } }, // 应用模式 applyMode() { if (!this.shouldApplyMode()) { this.cleanupAllStyles(); return; } if (this.getConfig('autoExclude') && this.shouldExcludeSite()) { this.cleanupAllStyles(); return; } let siteSpecificMode = this.getSiteSpecificMode(); if (siteSpecificMode && siteSpecificMode !== 'default') { switch(siteSpecificMode) { case 'light': this.cleanupAllStyles(); break; case 'dark': this.applyDarkMode(); break; case 'ink': this.applyInkMode(); break; case 'filter': this.applyFilterMode(); break; case 'video-invert': this.applyVideoInvertMode(); break; case 'green': // 新增:豆沙绿模式 this.applyGreenMode(); break; } } else { let mode = this.getCurrentMode(); switch(mode) { case 'dark': this.applyDarkMode(); break; case 'green': this.applyGreenMode(); break; case 'light': default: this.cleanupAllStyles(); break; } } }, // 切换模式(循环 light → dark → green → light ...) switchMode() { let siteSpecificMode = this.getSiteSpecificMode(); if (siteSpecificMode && siteSpecificMode !== 'default') { this.showNotification('当前网站使用专用模式,请在设置面板中修改'); setTimeout(() => this.showSettings(), 100); return; } let currentMode = this.currentMode || this.getConfig('currentMode') || 'light'; // 全局循环顺序:light → dark → green → light let nextMode; switch(currentMode) { case 'light': nextMode = 'dark'; break; case 'dark': nextMode = 'green'; break; case 'green': nextMode = 'light'; break; default: nextMode = 'light'; } this.currentMode = nextMode; this.setConfig('currentMode', nextMode); this.showNotification(`正在切换到 ${this.getModeName(nextMode)}`); setTimeout(() => { this.applyMode(); this.refreshMenu(); this.showNotification(`已切换到 ${this.getModeName(nextMode)}`); }, 100); }, // 获取模式名称 getModeName(mode) { switch(mode) { case 'light': return '白天模式'; case 'dark': return '夜间模式'; case 'ink': return '墨黑模式'; case 'filter': return '滤镜模式'; case 'video-invert': return '影视反色模式'; case 'green': return '豆沙绿模式'; default: return '白天模式'; } }, // 获取网站模式名称 getSiteModeName(mode) { switch(mode) { case 'light': return '白天模式'; case 'dark': return '夜间模式'; case 'ink': return '墨黑模式'; case 'filter': return '滤镜模式'; case 'video-invert': return '影视反色模式'; case 'green': return '豆沙绿模式'; default: return '默认'; } }, // 切换全局开关 toggleGlobal() { let current = this.getConfig('globalEnable'); this.setConfig('globalEnable', !current); this.applyMode(); this.refreshMenu(); this.showNotification(!current ? '已开启全局模式' : '已关闭全局模式'); }, // 切换当前网站开关(白名单管理) toggleCurrentSite() { let enableList = this.getConfig('enableList'); let host = location.host; if (enableList.includes(host)) { enableList = enableList.filter(domain => domain !== host); this.cleanupAllStyles(); this.setConfig('enableList', enableList); this.showNotification('已在当前网站禁用护眼模式'); } else { enableList.push(host); this.setConfig('enableList', enableList); this.applyMode(); this.showNotification('已在当前网站启用护眼模式'); } this.refreshMenu(); }, // 切换强制启用 toggleForceEnable() { let forcedList = this.getConfig('forcedEnableList'); let host = location.host; if (forcedList.includes(host)) { forcedList = forcedList.filter(domain => domain !== host); this.showNotification('已取消强制启用当前网站'); } else { forcedList.push(host); this.showNotification('已强制启用当前网站'); } this.setConfig('forcedEnableList', forcedList); this.applyMode(); this.refreshMenu(); }, // 显示通知 showNotification(message) { let oldNotifications = document.querySelectorAll('.eye-protect-notification'); oldNotifications.forEach(notification => { notification.remove(); }); let notification = document.createElement('div'); notification.className = 'eye-protect-notification'; notification.style.cssText = ` position: fixed; top: 20px; right: 20px; background: rgba(0, 0, 0, 0.8); color: white; padding: 10px 20px; border-radius: 5px; z-index: 999999; font-size: 14px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); opacity: 1; transition: opacity 0.5s; max-width: 300px; word-wrap: break-word; `; notification.textContent = message; if (document.body) { document.body.appendChild(notification); setTimeout(() => { notification.style.opacity = '0'; setTimeout(() => notification.remove(), 500); }, 2000); } }, // 显示设置面板(完整版,已移除影视反色,调整墨黑/豆沙绿顺序) showSettings() { // 移除现有的设置面板 let existingPanel = document.querySelector('.eye-protect-settings-panel'); if (existingPanel) { existingPanel.remove(); return; } // 获取当前配置 let currentMode = this.getCurrentMode(); let globalEnable = this.getConfig('globalEnable'); let enableList = this.getConfig('enableList'); let blacklist = this.getConfig('blacklist'); let autoExclude = this.getConfig('autoExclude'); let forcedList = this.getConfig('forcedEnableList'); let runDuringDay = this.getConfig('runDuringDay'); let darkAuto = this.getConfig('darkAuto'); let inkConfig = this.getConfig('inkModeConfig'); let autoSwitch = this.getConfig('autoSwitch'); let customDayNight = this.getConfig('customDayNight'); let customDark3 = this.getConfig('customDark3'); let host = location.host; let siteEnabled = enableList.includes(host); let isForced = forcedList.includes(host); let isBlacklisted = blacklist.includes(host); let blacklistCount = blacklist.length; // 获取当前网站的专用模式 let siteSpecificMode = this.getSiteSpecificMode(); // 创建设置面板 let panel = document.createElement('div'); panel.className = 'eye-protect-settings-panel'; // 使用亮色主题样式,不受当前模式影响 panel.style.cssText = ` position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; width: 550px !important; max-width: 90% !important; max-height: 85vh !important; background: #ffffff !important; color: #333333 !important; border-radius: 10px !important; box-shadow: 0 5px 20px rgba(0,0,0,0.2) !important; z-index: 1000000 !important; overflow: hidden !important; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; border: 1px solid #e0e0e0 !important; `; // 面板内容 - 已移除影视反色模式,调整墨黑/豆沙绿顺序 panel.innerHTML = `