// ==UserScript== // @name 小L书——LinuxDo仿小红书主题 // @namespace http://tampermonkey.net/ // @version 2.9.3 // @license MIT // @description 将LinuxDo改造成小红书风格瀑布流布局,支持自定义主题色 // @author JackyLiii // @match https://linux.do/* // @icon https://raw.githubusercontent.com/caigg188/littleLBook/main/llb_icon.png // @updateURL https://raw.githubusercontent.com/caigg188/littleLBook/main/littleLBook.user.js // @downloadURL https://raw.githubusercontent.com/caigg188/littleLBook/main/littleLBook.user.js // @supportURL https://github.com/caigg188/littleLBook/issues // @homepageURL https://github.com/caigg188/littleLBook // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @run-at document-start // ==/UserScript== (function () { 'use strict'; // 从 GM_info 自动读取版本号 const VERSION = (typeof GM_info !== 'undefined' && GM_info.script?.version) || '2.7'; /* ============================================ * 早期样式注入(防止闪烁) * ============================================ */ const EarlyStyles = { injected: false, styleId: 'xhs-early-styles', // 早期检测暗色模式 _detectDarkEarly() { // 读取缓存的用户设置 let darkMode = 'auto'; try { const saved = localStorage.getItem('xhs_darkmode_cache'); if (saved) darkMode = saved; } catch { } if (darkMode === 'dark') return true; if (darkMode === 'light') return false; // auto 模式:检测系统/扩展 if (document.documentElement.hasAttribute('data-darkreader-scheme')) { return document.documentElement.getAttribute('data-darkreader-scheme') === 'dark'; } if (document.documentElement.classList.contains('dark') || document.documentElement.getAttribute('data-theme') === 'dark') { return true; } return window.matchMedia?.('(prefers-color-scheme: dark)').matches || false; }, inject() { if (this.injected) return; this.injected = true; // 尝试从存储读取配置判断是否启用 let enabled = true; try { const saved = localStorage.getItem('xhs_enabled_cache'); if (saved !== null) enabled = saved === 'true'; } catch { } if (!enabled) return; const isDark = this._detectDarkEarly(); // 立即注入关键样式,隐藏原始列表 + 预加载卡片样式 const css = ` /* 早期隐藏原始列表,防止闪烁 */ body.xhs-early .topic-list, body.xhs-early .topic-list-header { opacity: 0 !important; pointer-events: none !important; position: absolute !important; visibility: hidden !important; } /* 预设背景色 */ body.xhs-early { background: ${isDark ? '#1a1a1a' : '#f5f5f7'} !important; } /* ===== 预加载卡片核心样式,避免闪烁 ===== */ /* 文字特效 - 必须早期加载 */ .xhs-hl { display: inline; padding: 2px 4px; margin: 0 1px; font-weight: 600; background: linear-gradient(to top, var(--hl-color, rgba(255,200,0,0.5)) 0%, var(--hl-color, rgba(255,200,0,0.5)) 70%, transparent 70%, transparent 100%); } .xhs-ul { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; font-weight: 600; } .xhs-wave { text-decoration: underline wavy; text-decoration-thickness: 1.5px; text-underline-offset: 3px; font-weight: 600; } .xhs-dot { position: relative; } .xhs-dot::after { content: '•'; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); font-size: 8px; } .xhs-bd { font-weight: 700; } /* 卡片配色 - 必须早期加载 */ ${isDark ? ` /* 暗色模式卡片配色 */ .xhs-card-bg.s1 { background: #3D2222; color: #F5C6C6; } .xhs-card-bg.s1 .xhs-hl { --hl-color: rgba(252,129,129,0.5); } .xhs-card-bg.s1 .xhs-ul, .xhs-card-bg.s1 .xhs-wave { text-decoration-color: #FC8181; } .xhs-card-bg.s1 .xhs-deco { color: #7C3030; } .xhs-card-bg.s2 { background: #1E3A5F; color: #BEE3F8; } .xhs-card-bg.s2 .xhs-hl { --hl-color: rgba(99,179,237,0.5); } .xhs-card-bg.s2 .xhs-ul, .xhs-card-bg.s2 .xhs-wave { text-decoration-color: #63B3ED; } .xhs-card-bg.s2 .xhs-deco { color: #4A79A8; } .xhs-card-bg.s3 { background: #1C3D2D; color: #C6F6D5; } .xhs-card-bg.s3 .xhs-hl { --hl-color: rgba(104,211,145,0.5); } .xhs-card-bg.s3 .xhs-ul, .xhs-card-bg.s3 .xhs-wave { text-decoration-color: #68D391; } .xhs-card-bg.s3 .xhs-deco { color: #48BB78; } .xhs-card-bg.s4 { background: #2D2248; color: #E9D8FD; } .xhs-card-bg.s4 .xhs-hl { --hl-color: rgba(183,148,244,0.5); } .xhs-card-bg.s4 .xhs-ul, .xhs-card-bg.s4 .xhs-wave { text-decoration-color: #B794F4; } .xhs-card-bg.s4 .xhs-deco { color: #9F7AEA; } .xhs-card-bg.s5 { background: #3D3020; color: #FEEBC8; } .xhs-card-bg.s5 .xhs-hl { --hl-color: rgba(246,173,85,0.5); } .xhs-card-bg.s5 .xhs-ul, .xhs-card-bg.s5 .xhs-wave { text-decoration-color: #F6AD55; } .xhs-card-bg.s5 .xhs-deco { color: #ED8936; } .xhs-card-bg.s6 { background: #1A3D3D; color: #B2F5EA; } .xhs-card-bg.s6 .xhs-hl { --hl-color: rgba(79,209,197,0.5); } .xhs-card-bg.s6 .xhs-ul, .xhs-card-bg.s6 .xhs-wave { text-decoration-color: #4FD1C5; } .xhs-card-bg.s6 .xhs-deco { color: #38B2AC; } .xhs-card-bg.s7 { background: #3D3D1A; color: #FAF089; } .xhs-card-bg.s7 .xhs-hl { --hl-color: rgba(236,201,75,0.5); } .xhs-card-bg.s7 .xhs-ul, .xhs-card-bg.s7 .xhs-wave { text-decoration-color: #ECC94B; } .xhs-card-bg.s7 .xhs-deco { color: #D69E2E; } .xhs-card-bg.s8 { background: #3D1A2D; color: #FED7E2; } .xhs-card-bg.s8 .xhs-hl { --hl-color: rgba(246,135,179,0.5); } .xhs-card-bg.s8 .xhs-ul, .xhs-card-bg.s8 .xhs-wave { text-decoration-color: #F687B3; } .xhs-card-bg.s8 .xhs-deco { color: #ED64A6; } .xhs-card-bg.s9 { background: #1A3A3D; color: #C4F1F9; } .xhs-card-bg.s9 .xhs-hl { --hl-color: rgba(118,228,247,0.5); } .xhs-card-bg.s9 .xhs-ul, .xhs-card-bg.s9 .xhs-wave { text-decoration-color: #76E4F7; } .xhs-card-bg.s9 .xhs-deco { color: #0BC5EA; } .xhs-card-bg.s10 { background: #3D2A1A; color: #FFE4CA; } .xhs-card-bg.s10 .xhs-hl { --hl-color: rgba(255,159,90,0.5); } .xhs-card-bg.s10 .xhs-ul, .xhs-card-bg.s10 .xhs-wave { text-decoration-color: #FF9F5A; } .xhs-card-bg.s10 .xhs-deco { color: #ED8936; } ` : ` /* 亮色模式卡片配色 */ .xhs-card-bg.s1 { background: #FFF5F5; color: #4A2C2C; } .xhs-card-bg.s1 .xhs-hl { --hl-color: rgba(254,178,178,0.6); } .xhs-card-bg.s1 .xhs-ul, .xhs-card-bg.s1 .xhs-wave { text-decoration-color: #FC8181; } .xhs-card-bg.s1 .xhs-deco { color: #FEB2B2; } .xhs-card-bg.s2 { background: #EBF8FF; color: #2A4365; } .xhs-card-bg.s2 .xhs-hl { --hl-color: rgba(144,205,244,0.6); } .xhs-card-bg.s2 .xhs-ul, .xhs-card-bg.s2 .xhs-wave { text-decoration-color: #63B3ED; } .xhs-card-bg.s2 .xhs-deco { color: #90CDF4; } .xhs-card-bg.s3 { background: #F0FFF4; color: #22543D; } .xhs-card-bg.s3 .xhs-hl { --hl-color: rgba(154,230,180,0.6); } .xhs-card-bg.s3 .xhs-ul, .xhs-card-bg.s3 .xhs-wave { text-decoration-color: #68D391; } .xhs-card-bg.s3 .xhs-deco { color: #9AE6B4; } .xhs-card-bg.s4 { background: #FAF5FF; color: #44337A; } .xhs-card-bg.s4 .xhs-hl { --hl-color: rgba(214,188,250,0.6); } .xhs-card-bg.s4 .xhs-ul, .xhs-card-bg.s4 .xhs-wave { text-decoration-color: #B794F4; } .xhs-card-bg.s4 .xhs-deco { color: #D6BCFA; } .xhs-card-bg.s5 { background: #FFFAF0; color: #744210; } .xhs-card-bg.s5 .xhs-hl { --hl-color: rgba(251,211,141,0.6); } .xhs-card-bg.s5 .xhs-ul, .xhs-card-bg.s5 .xhs-wave { text-decoration-color: #F6AD55; } .xhs-card-bg.s5 .xhs-deco { color: #FBD38D; } .xhs-card-bg.s6 { background: #E6FFFA; color: #234E52; } .xhs-card-bg.s6 .xhs-hl { --hl-color: rgba(129,230,217,0.6); } .xhs-card-bg.s6 .xhs-ul, .xhs-card-bg.s6 .xhs-wave { text-decoration-color: #4FD1C5; } .xhs-card-bg.s6 .xhs-deco { color: #81E6D9; } .xhs-card-bg.s7 { background: #FFFFF0; color: #5F370E; } .xhs-card-bg.s7 .xhs-hl { --hl-color: rgba(246,224,94,0.6); } .xhs-card-bg.s7 .xhs-ul, .xhs-card-bg.s7 .xhs-wave { text-decoration-color: #ECC94B; } .xhs-card-bg.s7 .xhs-deco { color: #F6E05E; } .xhs-card-bg.s8 { background: #FFF5F7; color: #521B41; } .xhs-card-bg.s8 .xhs-hl { --hl-color: rgba(251,182,206,0.6); } .xhs-card-bg.s8 .xhs-ul, .xhs-card-bg.s8 .xhs-wave { text-decoration-color: #F687B3; } .xhs-card-bg.s8 .xhs-deco { color: #FBB6CE; } .xhs-card-bg.s9 { background: #EDFDFD; color: #1D4044; } .xhs-card-bg.s9 .xhs-hl { --hl-color: rgba(157,236,249,0.6); } .xhs-card-bg.s9 .xhs-ul, .xhs-card-bg.s9 .xhs-wave { text-decoration-color: #76E4F7; } .xhs-card-bg.s9 .xhs-deco { color: #9DECF9; } .xhs-card-bg.s10 { background: #FFF8F1; color: #63351D; } .xhs-card-bg.s10 .xhs-hl { --hl-color: rgba(255,189,138,0.6); } .xhs-card-bg.s10 .xhs-ul, .xhs-card-bg.s10 .xhs-wave { text-decoration-color: #FF9F5A; } .xhs-card-bg.s10 .xhs-deco { color: #FFBD8A; } `} /* 装饰元素 */ .xhs-deco { position: absolute; pointer-events: none; line-height: 1; } .xhs-deco.corner { font-size: 16px; opacity: 0.5; } .xhs-deco.tl { top: 12px; left: 12px; } .xhs-deco.tr { top: 12px; right: 12px; } .xhs-deco.bl { bottom: 12px; left: 12px; } .xhs-deco.br { bottom: 12px; right: 12px; } .xhs-deco.line { font-size: 8px; letter-spacing: 4px; opacity: 0.25; } .xhs-deco.line-t { top: 6px; left: 50%; transform: translateX(-50%); } .xhs-deco.line-b { bottom: 6px; left: 50%; transform: translateX(-50%); } /* 卡片基础样式 */ .xhs-card { break-inside: avoid; background: ${isDark ? '#2d2d2d' : '#fff'}; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 8px ${isDark ? 'rgba(0,0,0,0.3)' : 'rgba(0,0,0,0.04)'}; margin-bottom: 16px; contain: layout style paint; } .xhs-card-bg { position: relative; padding: 24px 18px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; text-align: left; overflow: hidden; } .xhs-card-bg.size-normal { min-height: 180px; } .xhs-card-bg.size-tall { min-height: 240px; } .xhs-card-emoji { font-size: 32px; margin-bottom: 12px; position: relative; z-index: 1; } .xhs-card-excerpt { font-size: 14px; line-height: 2; font-weight: 500; word-break: break-word; position: relative; z-index: 1; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; } `; const style = document.createElement('style'); style.id = this.styleId; style.textContent = css; // 尽早插入 if (document.head) { document.head.appendChild(style); } else if (document.documentElement) { document.documentElement.appendChild(style); } // 立即添加 body class(如果 body 存在) if (document.body) { document.body.classList.add('xhs-early'); } else { // 监听 body 创建 const observer = new MutationObserver(() => { if (document.body) { document.body.classList.add('xhs-early'); observer.disconnect(); } }); observer.observe(document.documentElement, { childList: true }); } }, remove() { document.getElementById(this.styleId)?.remove(); document.body?.classList.remove('xhs-early'); }, // 缓存启用状态到 localStorage 供下次早期读取 cacheEnabled(enabled) { try { localStorage.setItem('xhs_enabled_cache', String(enabled)); } catch { } }, // 缓存暗色模式设置供下次早期读取 cacheDarkMode(mode) { try { localStorage.setItem('xhs_darkmode_cache', mode); } catch { } } }; // 立即执行早期样式注入 EarlyStyles.inject(); /* ============================================ * 配置模块 * ============================================ */ const Config = { KEY: 'xhs_style_config_v2', defaults: { enabled: true, themeColor: '#ff2442', showStats: true, darkMode: 'auto', // 'auto' | 'light' | 'dark' cardStagger: true // 卡片错落布局 }, themes: { '小L书红': '#ff2442', '天空蓝': '#1890ff', '清新绿': '#59cf1eff', '神秘紫': '#722ed1', '活力橙': '#fa541c', '少女粉': '#eb2f96' }, _cache: null, get() { if (this._cache) return this._cache; try { const saved = GM_getValue(this.KEY); this._cache = saved ? { ...this.defaults, ...JSON.parse(saved) } : { ...this.defaults }; } catch { this._cache = { ...this.defaults }; } return this._cache; }, set(key, value) { this._cache[key] = value; GM_setValue(this.KEY, JSON.stringify(this._cache)); }, reset() { this._cache = { ...this.defaults }; GM_setValue(this.KEY, JSON.stringify(this._cache)); } }; /* ============================================ * 工具模块 * ============================================ */ const Utils = { hexToRgb(hex) { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result ? `${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)}` : '255, 36, 66'; }, adjustColor(hex, amount) { const num = parseInt(hex.slice(1), 16); const r = Math.min(255, Math.max(0, (num >> 16) + amount)); const g = Math.min(255, Math.max(0, ((num >> 8) & 0xFF) + amount)); const b = Math.min(255, Math.max(0, (num & 0xFF) + amount)); return `#${(1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1)}`; }, formatNumber(n) { n = parseInt(n) || 0; if (n >= 10000) return (n / 10000).toFixed(1) + 'w'; if (n >= 1000) return (n / 1000).toFixed(1) + 'k'; return String(n); }, debounce(fn, delay) { let timer = null; return function (...args) { clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), delay); }; }, isTopicPage: () => /\/t\/[^/]+\/\d+/.test(location.pathname), isListPage: () => !!document.querySelector('tbody.topic-list-body'), // 检测系统是否为暗色模式 detectSystemDark() { // 1. 检测 Dark Reader 扩展 if (document.documentElement.hasAttribute('data-darkreader-scheme')) { return document.documentElement.getAttribute('data-darkreader-scheme') === 'dark'; } // 2. 检测常见的暗色模式 class/属性 if (document.documentElement.classList.contains('dark') || document.body?.classList.contains('dark') || document.documentElement.getAttribute('data-theme') === 'dark' || document.body?.getAttribute('data-theme') === 'dark') { return true; } // 3. 检测系统偏好 return window.matchMedia?.('(prefers-color-scheme: dark)').matches || false; }, // 根据配置判断是否应该使用暗色模式 isDarkMode() { const config = Config.get(); if (config.darkMode === 'dark') return true; if (config.darkMode === 'light') return false; // auto 模式:跟随系统 return this.detectSystemDark(); }, escapeHtml(str) { const div = document.createElement('div'); div.textContent = str; return div.innerHTML; }, seededRandom(seed) { let h = 0; for (let i = 0; i < seed.length; i++) { h = Math.imul(31, h) + seed.charCodeAt(i) | 0; } return () => { h = Math.imul(h ^ h >>> 15, h | 1); h ^= h + Math.imul(h ^ h >>> 7, h | 61); return ((h ^ h >>> 14) >>> 0) / 4294967296; }; }, // 使用 requestIdleCallback 处理非关键任务 scheduleIdle(fn) { if ('requestIdleCallback' in window) { requestIdleCallback(fn, { timeout: 2000 }); } else { setTimeout(fn, 50); } }, // 检测是否为移动端设备 isMobile() { // 检测触摸设备 + 屏幕宽度 const hasTouchScreen = 'ontouchstart' in window || navigator.maxTouchPoints > 0; const isNarrowScreen = window.innerWidth <= 768; // User-Agent 检测作为补充 const mobileUA = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); return (hasTouchScreen && isNarrowScreen) || mobileUA; }, // 检测是否为低带宽/省流量模式 isDataSaverMode() { // 检测 Save-Data 请求头(通过 navigator.connection) if ('connection' in navigator) { const conn = navigator.connection; if (conn.saveData) return true; // 检测慢速网络 if (conn.effectiveType && ['slow-2g', '2g'].includes(conn.effectiveType)) return true; } return false; } }; /* ============================================ * 样式模块 * ============================================ */ const Styles = { baseStyleId: 'xhs-base-styles', themeStyleId: 'xhs-theme-styles', injectBase() { if (document.getElementById(this.baseStyleId)) return; GM_addStyle(` /* ===== 设置按钮 ===== */ .xhs-btn { display: flex !important; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; transition: background 0.2s; position: relative; } .xhs-btn:hover { background: var(--xhs-light, rgba(255, 36, 66, 0.1)); } .xhs-btn svg { width: 20px; height: 20px; transition: fill 0.2s; } .xhs-btn.on svg { fill: var(--xhs-c, #ff2442); } .xhs-btn.off svg { fill: #999; } .xhs-btn.on::after { content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; background: var(--xhs-c, #ff2442); border-radius: 50%; } /* ===== 设置面板 ===== */ .xhs-overlay { display: none; position: fixed; inset: 0; z-index: 99998; background: rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.2s; } .xhs-overlay.show { display: block; opacity: 1; } .xhs-panel { position: fixed; top: 60px; right: 16px; width: 320px; background: #fff; border-radius: 16px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15); z-index: 99999; opacity: 0; visibility: hidden; transform: translateY(-10px) scale(0.98); transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; max-height: calc(100vh - 80px); overflow-y: auto; } .xhs-panel.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); } .xhs-panel-header { padding: 16px 20px; background: linear-gradient(135deg, var(--xhs-c, #ff2442), var(--xhs-lighter, #ff6b81)); color: #fff; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1; } .xhs-panel-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; } .xhs-panel-ver { font-size: 10px; background: rgba(255,255,255,0.25); padding: 2px 8px; border-radius: 8px; } .xhs-panel-close { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; background: rgba(255,255,255,0.2); font-size: 18px; transition: all 0.2s; } .xhs-panel-close:hover { background: rgba(255,255,255,0.35); transform: rotate(90deg); } .xhs-panel-body { padding: 16px 20px; } .xhs-section { margin-bottom: 18px; } .xhs-section:last-child { margin-bottom: 0; } .xhs-section-title { font-size: 11px; font-weight: 600; color: #999; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; } .xhs-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #f8f8f8; border-radius: 12px; margin-bottom: 8px; } .xhs-row:last-child { margin-bottom: 0; } .xhs-row-info { display: flex; align-items: center; gap: 10px; } .xhs-row-icon { font-size: 16px; } .xhs-row-label { font-size: 13px; color: #333; font-weight: 500; } .xhs-row-desc { font-size: 10px; color: #999; margin-top: 2px; } .xhs-switch { width: 44px; height: 24px; background: #ddd; border-radius: 12px; cursor: pointer; position: relative; transition: background 0.2s; flex-shrink: 0; } .xhs-switch.on { background: linear-gradient(135deg, var(--xhs-c, #ff2442), var(--xhs-lighter, #ff6b81)); } .xhs-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 2px 4px rgba(0,0,0,0.15); } .xhs-switch.on::after { transform: translateX(20px); } .xhs-colors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; } .xhs-color { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 10px; cursor: pointer; border: 2px solid transparent; background: #f8f8f8; transition: all 0.15s; } .xhs-color:hover { background: #f0f0f0; } .xhs-color.on { border-color: currentColor; background: #fff; } .xhs-color-dot { width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,0.15); } .xhs-color-name { font-size: 10px; color: #666; } .xhs-custom { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #f8f8f8; border-radius: 12px; margin-top: 8px; } .xhs-picker { width: 36px; height: 36px; border: none; border-radius: 8px; cursor: pointer; padding: 0; } .xhs-picker::-webkit-color-swatch-wrapper { padding: 0; } .xhs-picker::-webkit-color-swatch { border: none; border-radius: 6px; } .xhs-custom-label { font-size: 12px; color: #666; } .xhs-panel-footer { padding: 12px 20px; background: #fafafa; border-top: 1px solid #eee; display: flex; align-items: center; justify-content: space-between; position: sticky; bottom: 0; } .xhs-footer-links { display: flex; align-items: center; gap: 12px; } .xhs-footer-author { font-size: 11px; color: #999; } .xhs-footer-author a { color: var(--xhs-c, #ff2442); text-decoration: none; } .xhs-footer-author a:hover { text-decoration: underline; } .xhs-github-link { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: #fff; text-decoration: none; padding: 5px 10px; border-radius: 8px; background: linear-gradient(135deg, #24292e, #40464d); transition: all 0.2s; font-weight: 500; } .xhs-github-link:hover { background: linear-gradient(135deg, #40464d, #24292e); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.15); } .xhs-github-link .star-icon { color: #f1c40f; font-size: 12px; } .xhs-reset { font-size: 11px; color: var(--xhs-c, #ff2442); cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: background 0.15s; } .xhs-reset:hover { background: var(--xhs-light, rgba(255,36,66,0.1)); } .xhs-select { padding: 6px 12px; border-radius: 8px; border: 1px solid #ddd; background: #fff; font-size: 12px; color: #333; cursor: pointer; outline: none; transition: border-color 0.2s; } .xhs-select:hover { border-color: var(--xhs-c, #ff2442); } .xhs-select:focus { border-color: var(--xhs-c, #ff2442); box-shadow: 0 0 0 2px var(--xhs-light, rgba(255,36,66,0.1)); } /* 冷却提示动画 */ @keyframes xhs-notice-in { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } } @keyframes xhs-notice-out { from { opacity: 1; transform: translateX(-50%) translateY(0); } to { opacity: 0; transform: translateX(-50%) translateY(20px); } } /* ===== 移动端适配 ===== */ @media (max-width: 768px) { /* 设置面板全屏 */ .xhs-panel { top: 0 !important; right: 0 !important; left: 0 !important; bottom: 0 !important; width: 100% !important; max-width: 100% !important; max-height: 100% !important; border-radius: 0 !important; transform: translateY(100%) !important; } .xhs-panel.show { transform: translateY(0) !important; } .xhs-panel-header { padding: 20px !important; position: sticky !important; top: 0 !important; } .xhs-panel-body { padding: 16px !important; padding-bottom: 100px !important; } .xhs-panel-footer { position: fixed !important; bottom: 0 !important; left: 0 !important; right: 0 !important; padding: 16px 20px !important; padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important; background: #fff !important; border-top: 1px solid #eee !important; } .xhs-colors { grid-template-columns: repeat(3, 1fr) !important; gap: 10px !important; } .xhs-color { padding: 12px 8px !important; } .xhs-color-dot { width: 32px !important; height: 32px !important; } .xhs-row { padding: 14px 16px !important; } .xhs-switch { width: 50px !important; height: 28px !important; } .xhs-switch::after { width: 24px !important; height: 24px !important; } .xhs-switch.on::after { transform: translateX(22px) !important; } /* 设置按钮增大触摸区域 */ .xhs-btn { width: 44px !important; height: 44px !important; } .xhs-btn span { font-size: 24px !important; } } /* 更小屏幕的额外适配 */ @media (max-width: 375px) { .xhs-colors { grid-template-columns: repeat(2, 1fr) !important; } .xhs-panel-body { padding: 12px !important; padding-bottom: 100px !important; } .xhs-row-label { font-size: 12px !important; } .xhs-row-desc { font-size: 9px !important; } } /* 触摸设备优化 - 禁用 hover 效果 */ @media (hover: none) and (pointer: coarse) { .xhs-card:hover { transform: none !important; box-shadow: 0 2px 8px var(--xhs-shadow) !important; } .xhs-card:active { transform: scale(0.98) !important; opacity: 0.9; } .xhs-switch:active { transform: scale(0.95); } .xhs-color:active { transform: scale(0.95); } .xhs-btn:active { transform: scale(0.9); } } /* ===== 暗色模式设置面板适配 ===== */ body.xhs-dark .xhs-panel { background: #2d2d2d !important; } body.xhs-dark .xhs-panel-body { background: #2d2d2d !important; } body.xhs-dark .xhs-row { background: #3d3d3d !important; } body.xhs-dark .xhs-row-label { color: #e0e0e0 !important; } body.xhs-dark .xhs-row-desc { color: #888 !important; } body.xhs-dark .xhs-section-title { color: #888 !important; } body.xhs-dark .xhs-color { background: #3d3d3d !important; } body.xhs-dark .xhs-color:hover { background: #4d4d4d !important; } body.xhs-dark .xhs-color.on { background: #2d2d2d !important; } body.xhs-dark .xhs-color-name { color: #aaa !important; } body.xhs-dark .xhs-custom { background: #3d3d3d !important; } body.xhs-dark .xhs-custom-label { color: #aaa !important; } body.xhs-dark .xhs-panel-footer { background: #252525 !important; border-top-color: #404040 !important; } body.xhs-dark .xhs-footer-author { color: #888 !important; } body.xhs-dark .xhs-select { background: #3d3d3d !important; border-color: #555 !important; color: #e0e0e0 !important; } body.xhs-dark .xhs-switch { background: #555 !important; } /* 移动端暗色模式面板 footer */ @media (max-width: 768px) { body.xhs-dark .xhs-panel-footer { background: #252525 !important; } } `); }, injectTheme() { this.removeTheme(); const config = Config.get(); if (!config.enabled) return; const c = config.themeColor; const rgb = Utils.hexToRgb(c); const lighter = Utils.adjustColor(c, 15); const isDark = Utils.isDarkMode(); // 添加/移除 dark class 以便其他样式识别 document.body.classList.toggle('xhs-dark', isDark); const css = ` :root { --xhs-c: ${c}; --xhs-rgb: ${rgb}; --xhs-light: rgba(${rgb}, ${isDark ? '0.15' : '0.1'}); --xhs-lighter: ${lighter}; --xhs-bg: ${isDark ? '#1a1a1a' : '#f5f5f7'}; --xhs-card-bg: ${isDark ? '#2d2d2d' : '#fff'}; --xhs-text: ${isDark ? '#e0e0e0' : '#222'}; --xhs-text-secondary: ${isDark ? '#aaa' : '#666'}; --xhs-text-muted: ${isDark ? '#888' : '#999'}; --xhs-border: ${isDark ? '#404040' : '#f0f0f0'}; --xhs-shadow: ${isDark ? 'rgba(0,0,0,0.4)' : 'rgba(0,0,0,0.04)'}; --xhs-shadow-hover: ${isDark ? 'rgba(0,0,0,0.5)' : 'rgba(0,0,0,0.08)'}; } body.xhs-on { background: var(--xhs-bg) !important; } body.xhs-on .d-header { background: ${isDark ? '#1e1e1e' : '#fff'} !important; box-shadow: 0 1px 0 var(--xhs-c), 0 2px 12px var(--xhs-shadow) !important; border: none !important; z-index: 1100 !important; position: relative !important; } body.xhs-on .d-header-icons .btn:hover, body.xhs-on .d-header-icons .icon:hover { background: var(--xhs-light) !important; } /* 新消息提醒样式 */ body.xhs-on .show-more.has-topics .alert.alert-info.clickable { display: inline-flex !important; align-items: center !important; gap: 6px !important; padding: 10px 20px !important; background: linear-gradient(135deg, var(--xhs-c), var(--xhs-lighter)) !important; color: #fff !important; border: none !important; border-radius: 22px !important; font-size: 13px !important; font-weight: 500 !important; box-shadow: 0 4px 20px rgba(var(--xhs-rgb), 0.35) !important; } body.xhs-on .show-more.has-topics .alert.alert-info.clickable::before { content: '🔥' !important; } body.xhs-on .show-more.has-topics .alert.alert-info.clickable span { color: #fff !important; } body.xhs-on .d-icon-circle { color: var(--xhs-c) !important; fill: var(--xhs-c) !important; } body.xhs-on .badge-notification { position: relative !important; z-index: 9999 !important; } body.xhs-on .badge-notification.new-topic, body.xhs-on .badge-notification.unread-posts { background: var(--xhs-c) !important; } body.xhs-on .sidebar-wrapper { background: ${isDark ? '#252525' : '#fff'} !important; } body.xhs-on .sidebar-section-link { border-radius: 10px !important; margin: 2px 6px !important; } body.xhs-on .sidebar-section-link:hover, body.xhs-on .sidebar-section-link.active { background: var(--xhs-light) !important; color: var(--xhs-c) !important; } body.xhs-on .btn-primary { background: linear-gradient(135deg, var(--xhs-c), var(--xhs-lighter)) !important; border: none !important; border-radius: 18px !important; box-shadow: 0 2px 8px rgba(var(--xhs-rgb), 0.25) !important; } body.xhs-on .btn-primary:hover { box-shadow: 0 4px 16px rgba(var(--xhs-rgb), 0.35) !important; transform: translateY(-1px) !important; } /* ===== 导航栏主题色 ===== */ body.xhs-on .navigation-container, body.xhs-on section.navigation-container { background: ${isDark ? '#252525' : '#fff'} !important; border-radius: 12px !important; padding: 12px 16px !important; margin-bottom: 16px !important; margin-left: 0 !important; margin-right: 0 !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; box-shadow: 0 2px 8px var(--xhs-shadow) !important; } /* 类别/标签下拉 */ body.xhs-on .category-breadcrumb .select-kit-header, body.xhs-on .category-breadcrumb details summary, body.xhs-on .tag-drop .select-kit-header, body.xhs-on .tag-drop details summary { border-radius: 8px !important; border: 1px solid var(--xhs-border) !important; background: ${isDark ? '#333' : '#f8f8f8'} !important; } body.xhs-on .category-breadcrumb .select-kit-header:hover, body.xhs-on .category-breadcrumb details summary:hover, body.xhs-on .tag-drop .select-kit-header:hover, body.xhs-on .tag-drop details summary:hover { border-color: var(--xhs-c) !important; background: var(--xhs-light) !important; } /* 覆盖 Discourse 导航下划线变量 */ body.xhs-on { --d-nav-underline-height: 0 !important; --d-nav-border-color--active: transparent !important; } /* 导航标签 - 加强选择器 */ body.xhs-on ul.nav.nav-pills li a, body.xhs-on ul#navigation-bar.nav-pills li a, body.xhs-on .nav-pills > li > a { border-radius: 16px !important; padding: 6px 14px !important; margin: 0 2px !important; color: var(--xhs-text-secondary) !important; background: transparent !important; border: none !important; border-bottom: none !important; text-decoration: none !important; box-shadow: none !important; outline: none !important; transition: all 0.2s ease !important; position: relative !important; } /* 移除伪元素下划线 */ body.xhs-on ul.nav.nav-pills li a::before, body.xhs-on ul.nav.nav-pills li a::after, body.xhs-on ul#navigation-bar.nav-pills li a::before, body.xhs-on ul#navigation-bar.nav-pills li a::after, body.xhs-on .nav-pills > li > a::before, body.xhs-on .nav-pills > li > a::after { display: none !important; content: none !important; border: none !important; background: none !important; height: 0 !important; width: 0 !important; } body.xhs-on ul.nav.nav-pills li a:hover, body.xhs-on ul#navigation-bar.nav-pills li a:hover, body.xhs-on .nav-pills > li > a:hover { background: var(--xhs-light) !important; color: var(--xhs-c) !important; border: none !important; border-bottom: none !important; text-decoration: none !important; } body.xhs-on ul.nav.nav-pills li.active a, body.xhs-on ul#navigation-bar.nav-pills li.active a, body.xhs-on ul.nav.nav-pills li a.active, body.xhs-on ul#navigation-bar.nav-pills li a.active, body.xhs-on .nav-pills > li.active > a, body.xhs-on .nav-pills > li > a.active, body.xhs-on .nav-pills > li > a[aria-current="page"] { background: linear-gradient(135deg, var(--xhs-c), var(--xhs-lighter)) !important; color: #fff !important; font-weight: 600 !important; border: none !important; border-bottom: none !important; text-decoration: none !important; box-shadow: 0 2px 8px rgba(var(--xhs-rgb), 0.3) !important; } /* 移除激活状态的伪元素 */ body.xhs-on ul.nav.nav-pills li.active a::before, body.xhs-on ul.nav.nav-pills li.active a::after, body.xhs-on ul.nav.nav-pills li a.active::before, body.xhs-on ul.nav.nav-pills li a.active::after, body.xhs-on .nav-pills > li.active > a::before, body.xhs-on .nav-pills > li.active > a::after, body.xhs-on .nav-pills > li > a.active::before, body.xhs-on .nav-pills > li > a.active::after, body.xhs-on .nav-pills > li > a[aria-current="page"]::before, body.xhs-on .nav-pills > li > a[aria-current="page"]::after { display: none !important; content: none !important; border: none !important; background: none !important; height: 0 !important; width: 0 !important; opacity: 0 !important; visibility: hidden !important; } /* 强制移除 li 元素上的可能下划线 */ body.xhs-on ul.nav.nav-pills li, body.xhs-on ul.nav.nav-pills li.active, body.xhs-on ul#navigation-bar.nav-pills li, body.xhs-on ul#navigation-bar.nav-pills li.active { border: none !important; border-bottom: none !important; background: transparent !important; } body.xhs-on ul.nav.nav-pills li::before, body.xhs-on ul.nav.nav-pills li::after, body.xhs-on ul.nav.nav-pills li.active::before, body.xhs-on ul.nav.nav-pills li.active::after, body.xhs-on ul#navigation-bar.nav-pills li::before, body.xhs-on ul#navigation-bar.nav-pills li::after { display: none !important; content: none !important; border: none !important; background: none !important; height: 0 !important; width: 0 !important; } /* 新建话题按钮 */ body.xhs-on #create-topic, body.xhs-on button#create-topic, body.xhs-on .navigation-controls #create-topic { background: linear-gradient(135deg, var(--xhs-c), var(--xhs-lighter)) !important; color: #fff !important; border: none !important; border-radius: 18px !important; padding: 8px 16px !important; font-weight: 600 !important; box-shadow: 0 2px 8px rgba(var(--xhs-rgb), 0.25) !important; transition: all 0.2s ease !important; } body.xhs-on #create-topic:hover, body.xhs-on button#create-topic:hover { box-shadow: 0 4px 16px rgba(var(--xhs-rgb), 0.35) !important; transform: translateY(-1px) !important; } body.xhs-on #create-topic .d-icon, body.xhs-on #create-topic svg, body.xhs-on button#create-topic .d-icon, body.xhs-on button#create-topic svg { color: #fff !important; fill: #fff !important; } body.xhs-on #create-topic .d-button-label { color: #fff !important; } /* 草稿菜单按钮 */ body.xhs-on .topic-drafts-menu-trigger, body.xhs-on button.topic-drafts-menu-trigger { border-radius: 8px !important; border: 1px solid var(--xhs-border) !important; background: ${isDark ? '#333' : '#f8f8f8'} !important; } body.xhs-on .topic-drafts-menu-trigger:hover, body.xhs-on button.topic-drafts-menu-trigger:hover { border-color: var(--xhs-c) !important; background: var(--xhs-light) !important; } body.xhs-on .topic-list, body.xhs-on .topic-list-header, body.xhs-on .topics table.topic-list, body.xhs-on .topics .topic-list-header, body.xhs-on .topics table { display: none !important; } /* ===== 瀑布流布局(错落模式) ===== */ .xhs-grid { column-count: 4; column-gap: 16px; padding: 16px 0; } @media (max-width: 1400px) { .xhs-grid { column-count: 4; } } @media (max-width: 1200px) { .xhs-grid { column-count: 3; } } @media (max-width: 900px) { .xhs-grid { column-count: 2; column-gap: 12px; } } @media (max-width: 520px) { .xhs-grid { column-count: 2; column-gap: 10px; } } /* ===== 行布局(等高模式) ===== */ .xhs-grid.grid-mode { column-count: unset; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; } @media (max-width: 1200px) { .xhs-grid.grid-mode { grid-template-columns: repeat(3, 1fr); } } @media (max-width: 900px) { .xhs-grid.grid-mode { grid-template-columns: repeat(2, 1fr); gap: 12px; } } @media (max-width: 520px) { .xhs-grid.grid-mode { grid-template-columns: repeat(2, 1fr); gap: 10px; } } .xhs-grid.grid-mode .xhs-card { margin-bottom: 0; } /* ===== 卡片 ===== */ .xhs-card { break-inside: avoid; background: var(--xhs-card-bg); border-radius: 14px; overflow: hidden; box-shadow: 0 2px 8px var(--xhs-shadow); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s; margin-bottom: 16px; will-change: transform; contain: layout style paint; } @media (max-width: 900px) { .xhs-card { margin-bottom: 12px; border-radius: 12px; } } @media (max-width: 520px) { .xhs-card { margin-bottom: 10px; border-radius: 10px; } } .xhs-card:hover { transform: translateY(-6px); box-shadow: 0 12px 32px ${isDark ? 'rgba(var(--xhs-rgb), 0.25)' : 'rgba(var(--xhs-rgb), 0.12)'}; } .xhs-card-cover { display: block; position: relative; overflow: hidden; text-decoration: none; } /* ===== 文字封面 ===== */ .xhs-card-bg { position: relative; padding: 24px 18px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; text-align: left; overflow: hidden; box-sizing: border-box; } @media (max-width: 520px) { .xhs-card-bg { padding: 18px 14px; } } .xhs-card-bg.size-normal { min-height: 180px; } .xhs-card-bg.size-tall { min-height: 240px; } .grid-mode .xhs-card-bg.size-normal, .grid-mode .xhs-card-bg.size-tall { height: 180px !important; box-sizing: border-box !important; display: flex !important; flex-direction: column !important; } @media (max-width: 520px) { .xhs-card-bg.size-normal { min-height: 150px; } .xhs-card-bg.size-tall { min-height: 200px; } .grid-mode .xhs-card-bg.size-normal, .grid-mode .xhs-card-bg.size-tall { height: 150px !important; } } .xhs-card-body { flex: 1 !important; display: flex !important; flex-direction: column !important; } .xhs-card-meta { margin-top: auto !important; } /* 活动时间 - 右下角 */ .xhs-card-activity { position: absolute; right: 10px; bottom: 10px; font-size: 11px; color: var(--xhs-text-muted); opacity: 0.7; } @media (max-width: 520px) { .xhs-card-activity { font-size: 10px; right: 8px; bottom: 8px; } } /* 手绘装饰 */ .xhs-deco { position: absolute; pointer-events: none; line-height: 1; transition: opacity 0.3s, transform 0.3s; } .xhs-deco.corner { font-size: 16px; opacity: 0.5; } @media (max-width: 520px) { .xhs-deco.corner { font-size: 14px; } } .xhs-deco.tl { top: 12px; left: 12px; } .xhs-deco.tr { top: 12px; right: 12px; } .xhs-deco.bl { bottom: 12px; left: 12px; } .xhs-deco.br { bottom: 12px; right: 12px; } .xhs-deco.line { font-size: 8px; letter-spacing: 4px; opacity: 0.25; } .xhs-deco.line-t { top: 6px; left: 50%; transform: translateX(-50%); } .xhs-deco.line-b { bottom: 6px; left: 50%; transform: translateX(-50%); } .xhs-card:hover .xhs-deco.corner { opacity: 0.7; transform: scale(1.1); } .xhs-card-emoji { font-size: 32px; margin-bottom: 12px; position: relative; z-index: 1; transition: transform 0.3s; } @media (max-width: 520px) { .xhs-card-emoji { font-size: 28px; margin-bottom: 10px; } } .xhs-card:hover .xhs-card-emoji { transform: scale(1.15) rotate(-8deg); } .xhs-card-excerpt { font-size: 14px; line-height: 2; font-weight: 500; word-break: break-word; position: relative; z-index: 1; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; } @media (max-width: 520px) { .xhs-card-excerpt { font-size: 12px; line-height: 1.9; -webkit-line-clamp: 3; } } /* 文字效果 */ .xhs-hl { display: inline; padding: 2px 6px; margin: 0 1px; border-radius: 4px; font-weight: 700; background: linear-gradient(to top, var(--hl-color, rgba(255,200,0,0.5)) 0%, var(--hl-color, rgba(255,200,0,0.5)) 70%, transparent 70%, transparent 100%); } .xhs-ul { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; font-weight: 600; } .xhs-wave { text-decoration: underline wavy; text-decoration-thickness: 1.5px; text-underline-offset: 3px; font-weight: 600; } .xhs-dot { position: relative; } .xhs-dot::after { content: '•'; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); font-size: 8px; } .xhs-bd { font-weight: 700; } /* ===== 卡片配色 (根据暗色/亮色模式自动切换) ===== */ ${isDark ? ` .xhs-card-bg.s1 { background: #3D2222; color: #F5C6C6; } .xhs-card-bg.s1 .xhs-hl { --hl-color: rgba(252,129,129,0.5); } .xhs-card-bg.s1 .xhs-ul, .xhs-card-bg.s1 .xhs-wave { text-decoration-color: #FC8181; } .xhs-card-bg.s1 .xhs-deco { color: #7C3030; } .xhs-card-bg.s2 { background: #1E3A5F; color: #BEE3F8; } .xhs-card-bg.s2 .xhs-hl { --hl-color: rgba(99,179,237,0.5); } .xhs-card-bg.s2 .xhs-ul, .xhs-card-bg.s2 .xhs-wave { text-decoration-color: #63B3ED; } .xhs-card-bg.s2 .xhs-deco { color: #4A79A8; } .xhs-card-bg.s3 { background: #1C3D2D; color: #C6F6D5; } .xhs-card-bg.s3 .xhs-hl { --hl-color: rgba(104,211,145,0.5); } .xhs-card-bg.s3 .xhs-ul, .xhs-card-bg.s3 .xhs-wave { text-decoration-color: #68D391; } .xhs-card-bg.s3 .xhs-deco { color: #48BB78; } .xhs-card-bg.s4 { background: #2D2248; color: #E9D8FD; } .xhs-card-bg.s4 .xhs-hl { --hl-color: rgba(183,148,244,0.5); } .xhs-card-bg.s4 .xhs-ul, .xhs-card-bg.s4 .xhs-wave { text-decoration-color: #B794F4; } .xhs-card-bg.s4 .xhs-deco { color: #9F7AEA; } .xhs-card-bg.s5 { background: #3D3020; color: #FEEBC8; } .xhs-card-bg.s5 .xhs-hl { --hl-color: rgba(246,173,85,0.5); } .xhs-card-bg.s5 .xhs-ul, .xhs-card-bg.s5 .xhs-wave { text-decoration-color: #F6AD55; } .xhs-card-bg.s5 .xhs-deco { color: #ED8936; } .xhs-card-bg.s6 { background: #1A3D3D; color: #B2F5EA; } .xhs-card-bg.s6 .xhs-hl { --hl-color: rgba(79,209,197,0.5); } .xhs-card-bg.s6 .xhs-ul, .xhs-card-bg.s6 .xhs-wave { text-decoration-color: #4FD1C5; } .xhs-card-bg.s6 .xhs-deco { color: #38B2AC; } .xhs-card-bg.s7 { background: #3D3D1A; color: #FAF089; } .xhs-card-bg.s7 .xhs-hl { --hl-color: rgba(236,201,75,0.5); } .xhs-card-bg.s7 .xhs-ul, .xhs-card-bg.s7 .xhs-wave { text-decoration-color: #ECC94B; } .xhs-card-bg.s7 .xhs-deco { color: #D69E2E; } .xhs-card-bg.s8 { background: #3D1A2D; color: #FED7E2; } .xhs-card-bg.s8 .xhs-hl { --hl-color: rgba(246,135,179,0.5); } .xhs-card-bg.s8 .xhs-ul, .xhs-card-bg.s8 .xhs-wave { text-decoration-color: #F687B3; } .xhs-card-bg.s8 .xhs-deco { color: #ED64A6; } .xhs-card-bg.s9 { background: #1A3A3D; color: #C4F1F9; } .xhs-card-bg.s9 .xhs-hl { --hl-color: rgba(118,228,247,0.5); } .xhs-card-bg.s9 .xhs-ul, .xhs-card-bg.s9 .xhs-wave { text-decoration-color: #76E4F7; } .xhs-card-bg.s9 .xhs-deco { color: #0BC5EA; } .xhs-card-bg.s10 { background: #3D2A1A; color: #FFE4CA; } .xhs-card-bg.s10 .xhs-hl { --hl-color: rgba(255,159,90,0.5); } .xhs-card-bg.s10 .xhs-ul, .xhs-card-bg.s10 .xhs-wave { text-decoration-color: #FF9F5A; } .xhs-card-bg.s10 .xhs-deco { color: #ED8936; } ` : ` .xhs-card-bg.s1 { background: #FFF5F5; color: #4A2C2C; } .xhs-card-bg.s1 .xhs-hl { --hl-color: rgba(254,178,178,0.6); } .xhs-card-bg.s1 .xhs-ul, .xhs-card-bg.s1 .xhs-wave { text-decoration-color: #FC8181; } .xhs-card-bg.s1 .xhs-deco { color: #FEB2B2; } .xhs-card-bg.s2 { background: #EBF8FF; color: #2A4365; } .xhs-card-bg.s2 .xhs-hl { --hl-color: rgba(144,205,244,0.6); } .xhs-card-bg.s2 .xhs-ul, .xhs-card-bg.s2 .xhs-wave { text-decoration-color: #63B3ED; } .xhs-card-bg.s2 .xhs-deco { color: #90CDF4; } .xhs-card-bg.s3 { background: #F0FFF4; color: #22543D; } .xhs-card-bg.s3 .xhs-hl { --hl-color: rgba(154,230,180,0.6); } .xhs-card-bg.s3 .xhs-ul, .xhs-card-bg.s3 .xhs-wave { text-decoration-color: #68D391; } .xhs-card-bg.s3 .xhs-deco { color: #9AE6B4; } .xhs-card-bg.s4 { background: #FAF5FF; color: #44337A; } .xhs-card-bg.s4 .xhs-hl { --hl-color: rgba(214,188,250,0.6); } .xhs-card-bg.s4 .xhs-ul, .xhs-card-bg.s4 .xhs-wave { text-decoration-color: #B794F4; } .xhs-card-bg.s4 .xhs-deco { color: #D6BCFA; } .xhs-card-bg.s5 { background: #FFFAF0; color: #744210; } .xhs-card-bg.s5 .xhs-hl { --hl-color: rgba(251,211,141,0.6); } .xhs-card-bg.s5 .xhs-ul, .xhs-card-bg.s5 .xhs-wave { text-decoration-color: #F6AD55; } .xhs-card-bg.s5 .xhs-deco { color: #FBD38D; } .xhs-card-bg.s6 { background: #E6FFFA; color: #234E52; } .xhs-card-bg.s6 .xhs-hl { --hl-color: rgba(129,230,217,0.6); } .xhs-card-bg.s6 .xhs-ul, .xhs-card-bg.s6 .xhs-wave { text-decoration-color: #4FD1C5; } .xhs-card-bg.s6 .xhs-deco { color: #81E6D9; } .xhs-card-bg.s7 { background: #FFFFF0; color: #5F370E; } .xhs-card-bg.s7 .xhs-hl { --hl-color: rgba(246,224,94,0.6); } .xhs-card-bg.s7 .xhs-ul, .xhs-card-bg.s7 .xhs-wave { text-decoration-color: #ECC94B; } .xhs-card-bg.s7 .xhs-deco { color: #F6E05E; } .xhs-card-bg.s8 { background: #FFF5F7; color: #521B41; } .xhs-card-bg.s8 .xhs-hl { --hl-color: rgba(251,182,206,0.6); } .xhs-card-bg.s8 .xhs-ul, .xhs-card-bg.s8 .xhs-wave { text-decoration-color: #F687B3; } .xhs-card-bg.s8 .xhs-deco { color: #FBB6CE; } .xhs-card-bg.s9 { background: #EDFDFD; color: #1D4044; } .xhs-card-bg.s9 .xhs-hl { --hl-color: rgba(157,236,249,0.6); } .xhs-card-bg.s9 .xhs-ul, .xhs-card-bg.s9 .xhs-wave { text-decoration-color: #76E4F7; } .xhs-card-bg.s9 .xhs-deco { color: #9DECF9; } .xhs-card-bg.s10 { background: #FFF8F1; color: #63351D; } .xhs-card-bg.s10 .xhs-hl { --hl-color: rgba(255,189,138,0.6); } .xhs-card-bg.s10 .xhs-ul, .xhs-card-bg.s10 .xhs-wave { text-decoration-color: #FF9F5A; } .xhs-card-bg.s10 .xhs-deco { color: #FFBD8A; } `} /* ===== 图片封面 ===== */ .xhs-card-img-box { position: relative; width: 100%; overflow: hidden; background: ${isDark ? '#3d3d3d' : '#f0f0f0'}; } .xhs-card-img-box.size-normal, .xhs-card-img-box.size-tall { height: 180px; } @media (max-width: 520px) { .xhs-card-img-box.size-normal, .xhs-card-img-box.size-tall { height: 150px; } } .xhs-card-img { width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 0; transition: opacity 0.3s, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1); } .xhs-card-img.show { opacity: 1; } .xhs-card:hover .xhs-card-img.show { transform: scale(1.05); } .xhs-card-img-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: ${isDark ? 'linear-gradient(135deg, #3d3d3d, #2d2d2d)' : 'linear-gradient(135deg, #f5f5f5, #eee)'}; color: ${isDark ? '#666' : '#ccc'}; font-size: 24px; } .xhs-card-img.show ~ .xhs-card-img-ph { display: none; } .xhs-card-tag { position: absolute; top: 10px; left: 10px; background: ${isDark ? 'rgba(45,45,45,0.95)' : 'rgba(255,255,255,0.95)'}; color: var(--xhs-c); font-size: 10px; font-weight: 600; padding: 4px 10px; border-radius: 10px; z-index: 2; box-shadow: 0 2px 8px ${isDark ? 'rgba(0,0,0,0.3)' : 'rgba(0,0,0,0.08)'}; backdrop-filter: blur(8px); } @media (max-width: 520px) { .xhs-card-tag { font-size: 9px; padding: 3px 8px; } } .xhs-card-pin { position: absolute; top: 10px; right: 10px; background: linear-gradient(135deg, var(--xhs-c), var(--xhs-lighter)); color: #fff; font-size: 10px; font-weight: 600; padding: 4px 10px; border-radius: 10px; z-index: 3; box-shadow: 0 2px 8px rgba(var(--xhs-rgb), 0.3); } @media (max-width: 520px) { .xhs-card-pin { font-size: 9px; padding: 3px 8px; } } .xhs-card-count { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,0.65); color: #fff; font-size: 10px; padding: 4px 10px; border-radius: 10px; z-index: 2; display: none; align-items: center; gap: 4px; backdrop-filter: blur(8px); } .xhs-card-count.show { display: flex; } .xhs-card-body { padding: 14px; display: flex; flex-direction: column; flex: 1; } @media (max-width: 520px) { .xhs-card-body { padding: 10px 12px; } } .xhs-card-title { display: -webkit-box; font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--xhs-text); text-decoration: none; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; margin-bottom: 12px; transition: color 0.15s; } @media (max-width: 520px) { .xhs-card-title { font-size: 13px; margin-bottom: 10px; min-height: 2.9em; } } .xhs-card-title:hover { color: var(--xhs-c); } .xhs-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: auto; } .xhs-card-author { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; } .xhs-card-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--xhs-light); } @media (max-width: 520px) { .xhs-card-avatar { width: 20px; height: 20px; } } .xhs-card-name { font-size: 12px; color: var(--xhs-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } @media (max-width: 520px) { .xhs-card-name { font-size: 11px; } } .xhs-card-like { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--xhs-text-muted); padding: 6px 10px; border-radius: 14px; cursor: pointer; transition: all 0.2s; flex-shrink: 0; } @media (max-width: 520px) { .xhs-card-like { font-size: 11px; padding: 4px 8px; } } .xhs-card-like:hover { background: var(--xhs-light); color: var(--xhs-c); } .xhs-card-like .xhs-heart { font-size: 15px; transition: transform 0.2s; } .xhs-card-like:hover .xhs-heart { transform: scale(1.2); } .xhs-card-like.liked { color: var(--xhs-c); } .xhs-card-stats { display: flex; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--xhs-border); font-size: 11px; color: var(--xhs-text-muted); } @media (max-width: 520px) { .xhs-card-stats { gap: 10px; margin-top: 10px; padding-top: 10px; font-size: 10px; } } /* ===== 帖子详情页 ===== */ body.xhs-on.xhs-topic { background: var(--xhs-bg) !important; } body.xhs-on.xhs-topic .topic-post { background: var(--xhs-card-bg) !important; border-radius: 20px !important; margin-bottom: 16px !important; box-shadow: 0 2px 12px var(--xhs-shadow) !important; overflow: hidden !important; border: none !important; } body.xhs-on.xhs-topic .topic-post:first-child { border-top: 3px solid var(--xhs-c) !important; } /* ===== 首次发帖提示样式 ===== */ body.xhs-on.xhs-topic .post-notice { background: var(--xhs-light) !important; border: 1px solid rgba(var(--xhs-rgb), 0.2) !important; border-radius: 12px !important; padding: 12px 16px !important; margin: 12px 20px !important; display: flex !important; align-items: center !important; gap: 8px !important; font-size: 13px !important; color: var(--xhs-text-secondary) !important; max-width: calc(100% - 40px) !important; box-sizing: border-box !important; overflow: hidden !important; } body.xhs-on.xhs-topic .post-notice.new-user { background: linear-gradient(135deg, rgba(var(--xhs-rgb), 0.08), rgba(var(--xhs-rgb), 0.15)) !important; } body.xhs-on.xhs-topic .post-notice p { margin: 0 !important; color: var(--xhs-text) !important; flex: 1 !important; min-width: 0 !important; word-wrap: break-word !important; overflow-wrap: break-word !important; } body.xhs-on.xhs-topic .post-notice .emoji { width: 20px !important; height: 20px !important; flex-shrink: 0 !important; } /* v2.8 原版布局 - 不做任何修改 */ body.xhs-on.xhs-topic .topic-post article.boxed { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; } body.xhs-on.xhs-topic .topic-avatar { order: -1 !important; flex-shrink: 0 !important; padding: 20px 0 20px 20px !important; } body.xhs-on.xhs-topic .topic-body { flex: 1 !important; min-width: 0 !important; padding: 20px !important; } body.xhs-on.xhs-topic .topic-avatar .avatar { width: 48px !important; height: 48px !important; border: 3px solid var(--xhs-light) !important; border-radius: 50% !important; box-shadow: 0 2px 8px rgba(var(--xhs-rgb), 0.15) !important; } /* 首次发帖提示 - 占据整行宽度,显示在顶部 */ body.xhs-on.xhs-topic .post-notice { order: -2 !important; width: 100% !important; flex-basis: 100% !important; background: var(--xhs-light) !important; border: 1px solid rgba(var(--xhs-rgb), 0.2) !important; border-radius: 12px !important; padding: 12px 16px !important; margin: 16px 20px 0 20px !important; font-size: 13px !important; color: var(--xhs-text-secondary) !important; display: flex !important; align-items: center !important; gap: 8px !important; box-sizing: border-box !important; } body.xhs-on.xhs-topic .post-notice.new-user { background: linear-gradient(135deg, rgba(var(--xhs-rgb), 0.08), rgba(var(--xhs-rgb), 0.15)) !important; } body.xhs-on.xhs-topic .post-notice p { margin: 0 !important; flex: 1 !important; } body.xhs-on.xhs-topic .post-notice .emoji { flex-shrink: 0 !important; } body.xhs-on.xhs-topic .names .username a { font-weight: 600 !important; font-size: 15px !important; color: var(--xhs-text) !important; } body.xhs-on.xhs-topic .names .username a:hover { color: var(--xhs-c) !important; } /* 深色模式帖子详情页文字颜色修复 */ body.xhs-on.xhs-topic .topic-body, body.xhs-on.xhs-topic .topic-body *, body.xhs-on.xhs-topic .names, body.xhs-on.xhs-topic .names span, body.xhs-on.xhs-topic .names a, body.xhs-on.xhs-topic .post-infos, body.xhs-on.xhs-topic .post-date, body.xhs-on.xhs-topic .relative-date, body.xhs-on.xhs-topic .user-title, body.xhs-on.xhs-topic .full-name a, body.xhs-on.xhs-topic .second.username a { color: var(--xhs-text) !important; } body.xhs-on.xhs-topic .post-infos, body.xhs-on.xhs-topic .post-date, body.xhs-on.xhs-topic .relative-date, body.xhs-on.xhs-topic .user-title { color: var(--xhs-text-secondary) !important; } body.xhs-on.xhs-topic .post-controls .btn, body.xhs-on.xhs-topic .post-controls .d-icon, body.xhs-on.xhs-topic .post-controls .btn .d-button-label, body.xhs-on.xhs-topic .actions .btn { color: var(--xhs-text-muted) !important; } body.xhs-on.xhs-topic .post-controls .btn:hover, body.xhs-on.xhs-topic .post-controls .btn:hover .d-icon { color: var(--xhs-c) !important; } body.xhs-on.xhs-topic .cooked, body.xhs-on.xhs-topic .cooked p:not(.onebox p):not(.onebox-body p), body.xhs-on.xhs-topic .cooked li:not(.onebox li):not(.onebox-body li), body.xhs-on.xhs-topic .cooked span:not(.onebox span):not(.onebox-body span), body.xhs-on.xhs-topic .cooked div:not(.onebox):not(.onebox-body):not(.onebox div):not(.onebox-body div):not(.github-row) { font-size: 15px !important; line-height: 1.8 !important; color: var(--xhs-text) !important; } /* onebox (GitHub卡片等) 使用默认样式 */ body.xhs-on.xhs-topic .cooked aside.onebox { all: revert !important; box-shadow: 0 0 0 1px var(--onebox-border-color), 0 0 0 4px var(--onebox-shadow-color) !important; border-radius: var(--d-border-radius) !important; margin-bottom: 1em !important; padding: 1em !important; font-size: var(--font-0) !important; background: var(--secondary) !important; color: var(--primary) !important; } body.xhs-on.xhs-topic .cooked aside.onebox * { color: inherit !important; font-size: inherit !important; line-height: normal !important; } body.xhs-on.xhs-topic .cooked aside.onebox a { color: var(--tertiary) !important; } body.xhs-on.xhs-topic .cooked aside.onebox h3 a { color: var(--primary) !important; font-weight: bold !important; } body.xhs-on.xhs-topic .cooked aside.onebox img { border-radius: var(--d-border-radius) !important; margin: 0 !important; } body.xhs-on.xhs-topic .cooked a:not(.onebox a):not(.onebox-body a) { color: var(--xhs-c) !important; } body.xhs-on.xhs-topic .cooked img:not(.emoji):not(.avatar):not(.onebox img):not(.onebox-body img) { border-radius: 12px !important; margin: 12px 0 !important; } body.xhs-on.xhs-topic .cooked blockquote:not(.onebox blockquote) { border-left: 4px solid var(--xhs-c) !important; background: var(--xhs-light) !important; border-radius: 0 12px 12px 0 !important; padding: 16px 20px !important; margin: 16px 0 !important; } body.xhs-on.xhs-topic .cooked pre:not(.onebox pre) { border-radius: 12px !important; } body.xhs-on.xhs-topic .cooked code:not(pre code):not(.onebox code) { background: var(--xhs-light) !important; color: var(--xhs-c) !important; padding: 2px 8px !important; border-radius: 6px !important; } body.xhs-on.xhs-topic .post-controls .btn { border-radius: 8px !important; } body.xhs-on.xhs-topic .post-controls .btn:hover { background: var(--xhs-light) !important; color: var(--xhs-c) !important; } body.xhs-on.xhs-topic .like-button.has-like, body.xhs-on.xhs-topic .like-button.has-like .d-icon { color: var(--xhs-c) !important; } body.xhs-on #reply-control { border-top: 3px solid var(--xhs-c) !important; border-radius: 20px 20px 0 0 !important; background: var(--xhs-card-bg) !important; width: 100% !important; left: 0 !important; right: 0 !important; } /* 隐藏未激活的回复控件 */ body.xhs-on #reply-control.closed { display: none !important; } /* ===== 推荐话题等高网格布局 ===== */ /* 使用 flexbox 重新排列布局,让 .row 显示在卡片上方 */ body.xhs-on.xhs-topic .more-topics__container { display: flex !important; flex-direction: column !important; } body.xhs-on.xhs-topic .more-topics__container > .row { order: 1 !important; position: relative !important; z-index: 100 !important; margin-bottom: 20px !important; } body.xhs-on.xhs-topic .more-topics__container > .more-topics__lists { order: 2 !important; } /* 推荐/相关导航按钮小红书风格 */ body.xhs-on.xhs-topic .more-topics__container .nav-pills { display: flex !important; gap: 8px !important; padding: 0 !important; list-style: none !important; } body.xhs-on.xhs-topic .more-topics__container .nav-pills li { margin: 0 !important; } body.xhs-on.xhs-topic .more-topics__container .nav-pills .btn { background: var(--xhs-card-bg) !important; border: 1px solid var(--xhs-border) !important; border-radius: 20px !important; padding: 6px 16px !important; font-size: 14px !important; color: var(--xhs-text-secondary) !important; transition: all 0.2s ease !important; } body.xhs-on.xhs-topic .more-topics__container .nav-pills .btn:hover { border-color: var(--xhs-c) !important; color: var(--xhs-c) !important; } body.xhs-on.xhs-topic .more-topics__container .nav-pills .btn.active { background: linear-gradient(135deg, var(--xhs-c), var(--xhs-lighter)) !important; border-color: var(--xhs-c) !important; color: #fff !important; } body.xhs-on.xhs-topic .more-topics__container .nav-pills .btn.active .d-icon { color: #fff !important; } /* 推荐区域隐藏无数据的头像/用户名 */ body.xhs-on.xhs-topic .more-topics__lists .xhs-card-author { display: none !important; } body.xhs-on.xhs-topic .topics .xhs-grid { position: relative !important; z-index: 1 !important; column-count: unset !important; display: grid !important; grid-template-columns: repeat(5, 1fr) !important; gap: 16px !important; padding: 20px 0 !important; } /* 推荐话题卡片禁止向上悬浮,避免遮挡 */ body.xhs-on.xhs-topic .more-topics__lists .xhs-card:hover { transform: none !important; box-shadow: 0 8px 24px var(--xhs-shadow-hover) !important; } @media (max-width: 1400px) { body.xhs-on.xhs-topic .topics .xhs-grid { grid-template-columns: repeat(4, 1fr) !important; } } @media (max-width: 1100px) { body.xhs-on.xhs-topic .topics .xhs-grid { grid-template-columns: repeat(3, 1fr) !important; } } @media (max-width: 768px) { body.xhs-on.xhs-topic .topics .xhs-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; } } body.xhs-on.xhs-topic .topics .xhs-card { margin-bottom: 0 !important; height: 100% !important; display: flex !important; flex-direction: column !important; } body.xhs-on.xhs-topic .topics .xhs-card-cover { flex-shrink: 0 !important; } body.xhs-on.xhs-topic .topics .xhs-card-bg { min-height: 140px !important; height: 140px !important; } body.xhs-on.xhs-topic .topics .xhs-card-bg.size-tall, body.xhs-on.xhs-topic .topics .xhs-card-bg.size-normal { min-height: 140px !important; height: 140px !important; } body.xhs-on.xhs-topic .topics .xhs-card-img-box { height: 140px !important; } body.xhs-on.xhs-topic .topics .xhs-card-img-box.size-tall, body.xhs-on.xhs-topic .topics .xhs-card-img-box.size-normal { height: 140px !important; } body.xhs-on.xhs-topic .topics .xhs-card-body { flex: 1 !important; display: flex !important; flex-direction: column !important; padding: 12px !important; } body.xhs-on.xhs-topic .topics .xhs-card-title { font-size: 13px !important; -webkit-line-clamp: 2 !important; margin-bottom: 8px !important; flex: 1 !important; } body.xhs-on.xhs-topic .topics .xhs-card-meta { margin-top: auto !important; } body.xhs-on.xhs-topic .topics .xhs-card-stats { display: none !important; } body.xhs-on.xhs-topic .topics .xhs-card-emoji { font-size: 24px !important; margin-bottom: 8px !important; } body.xhs-on.xhs-topic .topics .xhs-card-excerpt { font-size: 12px !important; line-height: 1.6 !important; -webkit-line-clamp: 3 !important; } /* ===== 帖子详情页 ===== */ body.xhs-on.xhs-topic { background: var(--xhs-bg) !important; } body.xhs-on.xhs-topic .topic-post { background: var(--xhs-card-bg) !important; border-radius: 20px !important; margin-bottom: 16px !important; box-shadow: 0 2px 12px var(--xhs-shadow) !important; overflow: hidden !important; border: none !important; } body.xhs-on.xhs-topic .topic-post:first-child { border-top: 3px solid var(--xhs-c) !important; } /* v2.8 原版布局 */ body.xhs-on.xhs-topic .topic-post article.boxed { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; width: 100% !important; box-sizing: border-box !important; } body.xhs-on.xhs-topic .topic-post article.boxed > .row { width: 100% !important; max-width: 100% !important; margin: 0 !important; box-sizing: border-box !important; display: flex !important; } body.xhs-on.xhs-topic .topic-avatar { order: -1 !important; flex-shrink: 0 !important; padding: 20px 0 20px 20px !important; } body.xhs-on.xhs-topic .topic-body { flex: 1 !important; min-width: 0 !important; padding: 20px !important; overflow-wrap: break-word !important; word-wrap: break-word !important; } body.xhs-on.xhs-topic .topic-avatar .avatar { width: 48px !important; height: 48px !important; border: 3px solid var(--xhs-light) !important; border-radius: 50% !important; box-shadow: 0 2px 8px rgba(var(--xhs-rgb), 0.15) !important; } /* 首次发帖提示 - 占据整行宽度,显示在顶部 */ body.xhs-on.xhs-topic .post-notice { order: -2 !important; width: 100% !important; flex-basis: 100% !important; background: var(--xhs-light) !important; border: 1px solid rgba(var(--xhs-rgb), 0.2) !important; border-radius: 10px !important; padding: 10px 14px !important; margin: 12px 16px 0 16px !important; font-size: 12px !important; color: var(--xhs-text-secondary) !important; display: flex !important; align-items: center !important; gap: 8px !important; box-sizing: border-box !important; } body.xhs-on.xhs-topic .post-notice.new-user { background: linear-gradient(135deg, rgba(var(--xhs-rgb), 0.08), rgba(var(--xhs-rgb), 0.15)) !important; } body.xhs-on.xhs-topic .post-notice p { margin: 0 !important; flex: 1 !important; } body.xhs-on.xhs-topic .post-notice .emoji { flex-shrink: 0 !important; width: 18px !important; height: 18px !important; } /* 帖子详情页响应式布局 */ body.xhs-on.xhs-topic .post-stream, body.xhs-on.xhs-topic .topic-post, body.xhs-on.xhs-topic article.boxed, body.xhs-on.xhs-topic .posts-wrapper { max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; } body.xhs-on.xhs-topic .topic-map { width: 100% !important; max-width: 100% !important; } body.xhs-on.xhs-topic #main-outlet { box-sizing: border-box !important; max-width: 100% !important; } body.xhs-on.xhs-topic .topic-post { overflow: hidden !important; } body.xhs-on.xhs-topic .cooked { max-width: 100% !important; overflow-wrap: break-word !important; word-wrap: break-word !important; } body.xhs-on.xhs-topic .cooked img:not(.emoji):not(.avatar):not(.onebox img):not(.onebox-body img) { max-width: 100% !important; height: auto !important; } body.xhs-on.xhs-topic .cooked pre:not(.onebox pre) { max-width: 100% !important; overflow-x: auto !important; } /* 移动端 post-notice 样式 */ @media (max-width: 900px) { /* 小屏幕保持 flex-wrap,让 post-notice 单独占一行 */ body.xhs-on.xhs-topic .topic-post article.boxed { flex-direction: row !important; flex-wrap: wrap !important; } /* .row 内头像和内容水平排列 */ body.xhs-on.xhs-topic .topic-post article.boxed > .row { display: flex !important; flex-direction: row !important; align-items: flex-start !important; width: 100% !important; gap: 0 !important; } body.xhs-on.xhs-topic .topic-avatar { padding: 14px 10px 14px 14px !important; order: -1 !important; flex-shrink: 0 !important; } body.xhs-on.xhs-topic .topic-body { padding: 14px 14px 14px 0 !important; flex: 1 !important; min-width: 0 !important; } /* 移除 topic-meta-data 的左侧 margin,让昵称紧挨头像 */ body.xhs-on.xhs-topic .topic-meta-data { margin-left: 0 !important; } body.xhs-on.xhs-topic .topic-avatar .avatar { width: 40px !important; height: 40px !important; } body.xhs-on.xhs-topic #main-outlet { padding-left: 8px !important; padding-right: 8px !important; } /* 移动端 post-notice 样式调整 - 占满整行在顶部 */ body.xhs-on.xhs-topic .post-notice { order: -2 !important; width: 100% !important; flex-basis: 100% !important; margin: 12px 12px 0 12px !important; padding: 10px 12px !important; font-size: 12px !important; } } body.xhs-on.xhs-topic .names .username a { font-weight: 600 !important; font-size: 15px !important; } body.xhs-on.xhs-topic .names .username a:hover { color: var(--xhs-c) !important; } body.xhs-on.xhs-topic .cooked { font-size: 15px !important; line-height: 1.8 !important; } body.xhs-on.xhs-topic .cooked a:not(.onebox a):not(.onebox-body a) { color: var(--xhs-c) !important; } body.xhs-on.xhs-topic .cooked img:not(.emoji):not(.avatar):not(.onebox img):not(.onebox-body img) { border-radius: 12px !important; margin: 12px 0 !important; } body.xhs-on.xhs-topic .cooked blockquote:not(.onebox blockquote) { border-left: 4px solid var(--xhs-c) !important; background: var(--xhs-light) !important; border-radius: 0 12px 12px 0 !important; padding: 16px 20px !important; margin: 16px 0 !important; } body.xhs-on.xhs-topic .cooked pre:not(.onebox pre) { border-radius: 12px !important; } body.xhs-on.xhs-topic .cooked code:not(pre code):not(.onebox code) { background: var(--xhs-light) !important; color: var(--xhs-c) !important; padding: 2px 8px !important; border-radius: 6px !important; } body.xhs-on.xhs-topic .post-controls .btn { border-radius: 8px !important; } body.xhs-on.xhs-topic .post-controls .btn:hover { background: var(--xhs-light) !important; color: var(--xhs-c) !important; } body.xhs-on.xhs-topic .like-button.has-like, body.xhs-on.xhs-topic .like-button.has-like .d-icon { color: var(--xhs-c) !important; } body.xhs-on #reply-control { border-top: 3px solid var(--xhs-c) !important; border-radius: 20px 20px 0 0 !important; background: var(--xhs-card-bg) !important; width: 100% !important; left: 0 !important; right: 0 !important; } /* 隐藏未激活的回复控件 */ body.xhs-on #reply-control.closed { display: none !important; } /* ===== 话题底部按钮小红书风格 ===== */ body.xhs-on.xhs-topic .topic-footer-main-buttons { background: var(--xhs-card-bg) !important; border-radius: 16px !important; padding: 12px 16px !important; margin: 16px 0 !important; box-shadow: 0 2px 12px var(--xhs-shadow) !important; display: flex !important; align-items: center !important; justify-content: space-between !important; gap: 12px !important; } body.xhs-on.xhs-topic .topic-footer-main-buttons__actions { display: flex !important; gap: 8px !important; flex-wrap: wrap !important; } body.xhs-on.xhs-topic .topic-footer-button { background: var(--xhs-light) !important; border: none !important; border-radius: 20px !important; padding: 8px 16px !important; font-size: 13px !important; font-weight: 500 !important; color: var(--xhs-c) !important; transition: all 0.2s !important; display: inline-flex !important; align-items: center !important; gap: 6px !important; } body.xhs-on.xhs-topic .topic-footer-button .d-button-label, body.xhs-on.xhs-topic .topic-footer-button span { color: var(--xhs-c) !important; } /* 回复按钮(btn-primary)文字为白色 */ body.xhs-on.xhs-topic .topic-footer-button.btn-primary .d-button-label, body.xhs-on.xhs-topic .topic-footer-button.btn-primary span { color: #fff !important; } body.xhs-on.xhs-topic .topic-footer-button:hover { background: rgba(var(--xhs-rgb), 0.2) !important; transform: translateY(-1px) !important; } body.xhs-on.xhs-topic .topic-footer-button svg { width: 14px !important; height: 14px !important; fill: var(--xhs-c) !important; } body.xhs-on.xhs-topic .topic-footer-button.btn-primary { background: linear-gradient(135deg, var(--xhs-c), var(--xhs-lighter)) !important; color: #fff !important; padding: 10px 24px !important; font-weight: 600 !important; box-shadow: 0 4px 12px rgba(var(--xhs-rgb), 0.3) !important; } body.xhs-on.xhs-topic .topic-footer-button.btn-primary:hover { box-shadow: 0 6px 20px rgba(var(--xhs-rgb), 0.4) !important; transform: translateY(-2px) !important; } body.xhs-on.xhs-topic .topic-footer-button.btn-primary svg { fill: #fff !important; } /* ===== 全局通知浅色主题 ===== */ body.xhs-on .global-notice .alert-global-notice { background: var(--xhs-light) !important; border: 1px solid rgba(var(--xhs-rgb), 0.15) !important; border-radius: 12px !important; color: var(--xhs-c) !important; padding: 12px 20px !important; margin: 12px 0 !important; } body.xhs-on .global-notice .alert-global-notice .text { color: #333 !important; } body.xhs-on .global-notice .alert-global-notice .text strong { color: var(--xhs-c) !important; font-weight: 600 !important; } body.xhs-on .global-notice .alert-global-notice .text a { color: var(--xhs-c) !important; font-weight: 500 !important; text-decoration: none !important; border-bottom: 1px dashed var(--xhs-c) !important; } body.xhs-on .global-notice .alert-global-notice .text a:hover { border-bottom-style: solid !important; } /* ===== 移动端全面优化 ===== */ @media (max-width: 768px) { /* 首页导航栏适配 */ body.xhs-on .navigation-container, body.xhs-on section.navigation-container { padding: 10px 12px !important; margin-bottom: 12px !important; border-radius: 10px !important; flex-wrap: wrap !important; } /* 导航按钮缩小 */ body.xhs-on ul.nav.nav-pills li a, body.xhs-on .nav-pills > li > a { padding: 5px 10px !important; font-size: 12px !important; border-radius: 14px !important; } /* 新建话题按钮 */ body.xhs-on #create-topic, body.xhs-on button#create-topic { padding: 6px 12px !important; font-size: 12px !important; border-radius: 14px !important; } body.xhs-on #create-topic .d-button-label { display: none !important; } body.xhs-on #create-topic .d-icon { margin: 0 !important; } /* 类别选择器缩小 */ body.xhs-on .category-breadcrumb, body.xhs-on .tag-drop { font-size: 12px !important; } /* 瀑布流布局优化 */ .xhs-grid { padding: 12px 0 !important; } /* 首页主内容区域边距 */ body.xhs-on #main-outlet { padding-left: 10px !important; padding-right: 10px !important; } /* 帖子详情页优化 */ body.xhs-on.xhs-topic .topic-post { border-radius: 14px !important; margin-bottom: 12px !important; } body.xhs-on.xhs-topic .topic-post:first-child { border-top-width: 2px !important; } /* 帖子详情页内容 */ body.xhs-on.xhs-topic .cooked { font-size: 14px !important; line-height: 1.7 !important; } body.xhs-on.xhs-topic .cooked blockquote:not(.onebox blockquote) { padding: 12px 14px !important; margin: 12px 0 !important; border-radius: 0 10px 10px 0 !important; } body.xhs-on.xhs-topic .cooked img:not(.emoji):not(.avatar):not(.onebox img):not(.onebox-body img) { border-radius: 10px !important; margin: 10px 0 !important; } /* 首次发帖提示移动端适配 */ body.xhs-on.xhs-topic .post-notice { margin: 10px 12px !important; padding: 10px 12px !important; border-radius: 10px !important; font-size: 12px !important; } /* 底部按钮栏 */ body.xhs-on.xhs-topic .topic-footer-main-buttons { padding: 10px 12px !important; margin: 12px 0 !important; border-radius: 12px !important; flex-direction: column !important; gap: 10px !important; } body.xhs-on.xhs-topic .topic-footer-main-buttons__actions { width: 100% !important; justify-content: center !important; } body.xhs-on.xhs-topic .topic-footer-button { padding: 8px 14px !important; font-size: 12px !important; } body.xhs-on.xhs-topic .topic-footer-button.btn-primary { width: 100% !important; justify-content: center !important; padding: 12px 20px !important; } /* 推荐话题区域移动端布局 */ body.xhs-on.xhs-topic .topics .xhs-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; padding: 12px 0 !important; } body.xhs-on.xhs-topic .topics .xhs-card-bg, body.xhs-on.xhs-topic .topics .xhs-card-img-box { height: 110px !important; min-height: 110px !important; } body.xhs-on.xhs-topic .topics .xhs-card-title { font-size: 12px !important; margin-bottom: 6px !important; } body.xhs-on.xhs-topic .topics .xhs-card-body { padding: 10px !important; } body.xhs-on.xhs-topic .topics .xhs-card-excerpt { font-size: 11px !important; -webkit-line-clamp: 2 !important; } body.xhs-on.xhs-topic .topics .xhs-card-emoji { font-size: 20px !important; margin-bottom: 6px !important; } /* 推荐/相关导航按钮 */ body.xhs-on.xhs-topic .more-topics__container .nav-pills .btn { padding: 5px 12px !important; font-size: 12px !important; border-radius: 16px !important; } /* 回复框移动端优化 */ body.xhs-on #reply-control { border-radius: 16px 16px 0 0 !important; border-top-width: 2px !important; } /* 帖子控制按钮增大触摸区域 */ body.xhs-on.xhs-topic .post-controls .btn { min-width: 36px !important; min-height: 36px !important; padding: 8px !important; } /* 时间线隐藏(移动端空间有限) */ body.xhs-on.xhs-topic .topic-timeline-container { display: none !important; } /* 侧边栏隐藏优化 */ body.xhs-on .sidebar-wrapper { z-index: 1000 !important; } } /* 更小屏幕(<= 480px)额外优化 */ @media (max-width: 480px) { body.xhs-on #main-outlet { padding-left: 6px !important; padding-right: 6px !important; } /* 小屏幕下头像进一步缩小 */ body.xhs-on.xhs-topic .topic-avatar .avatar { width: 32px !important; height: 32px !important; } body.xhs-on.xhs-topic .names .username a { font-size: 14px !important; } body.xhs-on.xhs-topic .cooked { font-size: 13px !important; } /* 导航栏按钮进一步缩小 */ body.xhs-on ul.nav.nav-pills li a { padding: 4px 8px !important; font-size: 11px !important; } body.xhs-on .navigation-container { padding: 8px 10px !important; } } /* 横屏模式优化 */ @media (max-height: 500px) and (orientation: landscape) { body.xhs-on.xhs-topic .topic-avatar .avatar { width: 36px !important; height: 36px !important; } } `; const style = document.createElement('style'); style.id = this.themeStyleId; style.textContent = css; document.head.appendChild(style); }, removeTheme() { document.getElementById(this.themeStyleId)?.remove(); } }; /* ============================================ * 设置面板模块 * ============================================ */ const Panel = { btn: null, panel: null, overlay: null, create() { const li = document.createElement('li'); li.innerHTML = `
${excerptHtml}