// ==UserScript== // @name Linuxdo-share // @namespace http://tampermonkey.net/ // @version 0.15.36 // @description 从linux do论坛页面获取文章的板块、标题、链接、标签和内容总结,并在标题旁添加复制按钮。支持设置界面配置。 // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDY0IDY0Ij48cmVjdCB4PSIxOCIgeT0iMTQiIHdpZHRoPSIzMCIgaGVpZ2h0PSIzOCIgcng9IjYiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzRlNTk2OSIgc3Ryb2tlLXdpZHRoPSI0Ii8+PHJlY3QgeD0iMTIiIHk9IjIwIiB3aWR0aD0iMzAiIGhlaWdodD0iMzgiIHJ4PSI2IiBmaWxsPSJub25lIiBzdHJva2U9IiMxNjRkZTUiIHN0cm9rZS13aWR0aD0iNCIvPjwvc3ZnPg== // @icon64 data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDY0IDY0Ij48cmVjdCB4PSIxOCIgeT0iMTQiIHdpZHRoPSIzMCIgaGVpZ2h0PSIzOCIgcng9IjYiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzRlNTk2OSIgc3Ryb2tlLXdpZHRoPSI0Ii8+PHJlY3QgeD0iMTIiIHk9IjIwIiB3aWR0aD0iMzAiIGhlaWdodD0iMzgiIHJ4PSI2IiBmaWxsPSJub25lIiBzdHJva2U9IiMxNjRkZTUiIHN0cm9rZS13aWR0aD0iNCIvPjwvc3ZnPg== // @author @Loveyless https://github.com/Loveyless/linuxdo-share // @match *://*.linux.do/* // @match *://*.idcflare.com/* // @updateURL https://raw.githubusercontent.com/Loveyless/linuxdo-share/main/script.user.js // @downloadURL https://raw.githubusercontent.com/Loveyless/linuxdo-share/main/script.user.js // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest // @grant GM_addStyle // @grant GM_registerMenuCommand // @run-at document-idle // 更可靠的运行时间,等待DOM和资源加载完成且浏览器空闲 // ==/UserScript== (function () { 'use strict'; // #region 脚本配置与常量 // ========================================================== /** * @description 默认配置项,当油猴存储中没有对应值时使用。 */ const DEFAULT_CONFIG = { // 是否启用简洁模式:标题+摘要合并一段,隐藏作者/板块/标签,链接单独一行 COMPACT_MODE: false, // 是否启用 AI 进行内容总结 USE_AI_FOR_SUMMARY: false, // AI Key,如果 USE_AI_FOR_SUMMARY 为 true,则需要填写此项 API_KEY: '', // API 地址 (OpenAI Compatible 格式,完整地址如 https://api.openai.com/v1/chat/completions) API_BASE_URL: 'https://api.openai.com/v1/chat/completions', // 模型名称 MODEL_NAME: 'gpt-4o-mini', // 总结后的最大字符数 LOCAL_SUMMARY_MAX_CHARS: 90, // 自定义总结 Prompt CUSTOM_SUMMARY_PROMPT: `你是一个信息获取专家,可以精准的总结文章的精华内容和重点,请对以下文章内容进行归纳总结,回复不要有对我的问候语,或者(你好这是我的总结)(总结)等类似废话,直接返回你的总结,长度不超过{maxChars}个字符(或尽可能短,保持中文语义完整): {content}`, // 文章复制模板 ARTICLE_COPY_TEMPLATE: [ `{{title}}`, `@{{username}}-{{category}}/{{tags}}`, ``, `{{summary}}`, `{{link}}`, ].join('\n') }; /** * @description 脚本内部使用的常量配置 */ const SCRIPT_CONSTANTS = { // API 请求超时时间 (毫秒) API_TIMEOUT_MS: 30000, // AI 总结时发送的最大内容长度 AI_CONTENT_MAX_LENGTH: 4000, // 脚本初始化节流时间 (毫秒) INIT_THROTTLE_MS: 300, // 复制成功提示显示时间 (毫秒) COPY_SUCCESS_DURATION_MS: 2000, // 复制失败提示显示时间 (毫秒) COPY_FAILURE_DURATION_MS: 3000, // 设置保存后关闭延迟 (毫秒) SETTINGS_CLOSE_DELAY_MS: 300, // Dialog 关闭动画时间 (毫秒) DIALOG_CLOSE_ANIMATION_MS: 200, // 历史复制内容:存储空间不足时的保底条数 COPY_HISTORY_FALLBACK_LIMIT: 20 }; // #endregion // #region 配置管理 // ========================================================== /** * @description 从油猴存储中获取指定键的配置值。 * @param {string} key - 配置项的键名。 * @returns {*} 对应配置项的值,如果不存在则返回默认值。 */ function getConfig(key) { return GM_getValue(key, DEFAULT_CONFIG[key]); } /** * @description 将配置值保存到油猴存储中。 * @param {string} key - 配置项的键名。 * @param {*} value - 要保存的配置值。 */ function setConfig(key, value) { GM_setValue(key, value); } /** * @description 创建一个动态配置代理对象。 * 当访问 CONFIG.someKey 时,会自动调用 getConfig('someKey')。 * 当设置 CONFIG.someKey = value 时,会自动调用 setConfig('someKey', value)。 */ const CONFIG = new Proxy({}, { get(target, prop) { return getConfig(prop); }, set(target, prop, value) { setConfig(prop, value); return true; } }); // #endregion // #region 样式注入 // ========================================================== /** * @description 脚本所需的全部 CSS 样式字符串。 */ const copyBtnStyle = /*css*/` .copy-button { /* 统一命名为 .copy-button */ --button-bg: #e5e6eb; --button-hover-bg: #d7dbe2; --button-text-color: #4e5969; --button-hover-text-color: #164de5; --button-border-radius: 6px; --button-diameter: 24px; --button-outline-width: 2px; --button-outline-color: #9f9f9f; --tooltip-bg: #1d2129; --tooltip-border-radius: 4px; --tooltip-font-family: JetBrains Mono, Consolas, Menlo, Roboto Mono, monospace; --tooltip-font-size: 12px; --tooltip-text-color: #fff; --tooltip-padding-x: 7px; --tooltip-padding-y: 7px; --tooltip-offset: 8px; } html[style*="color-scheme: dark"] .copy-button, html.dark .copy-button { --button-bg: #353434; --button-hover-bg: #464646; --button-text-color: #ccc; --button-outline-color: #999; --button-hover-text-color: #8bb9fe; --tooltip-bg: #f4f3f3; --tooltip-text-color: #111; } .copy-button { box-sizing: border-box; width: var(--button-diameter); height: var(--button-diameter); border-radius: var(--button-border-radius); background-color: var(--button-bg); color: var(--button-text-color); border: none; cursor: pointer; position: relative; outline: var(--button-outline-width) solid transparent; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin-left: 8px; } /* 调整标题的父元素 (h1[data-topic-id]) 为 flex 布局,确保按钮能紧随标题且对齐 */ h1[data-topic-id] { display: flex !important; /* 强制 flexbox */ align-items: center !important; /* 垂直居中对齐 */ gap: 8px; /* 增加标题和按钮之间的间距 */ } h1[data-topic-id] .fancy-title { margin-right: 0 !important; /* 覆盖可能存在的右外边距 */ } .tooltip { position: absolute; opacity: 0; left: calc(100% + var(--tooltip-offset)); top: 50%; transform: translateY(-50%); white-space: nowrap; font: var(--tooltip-font-size) var(--tooltip-font-family); color: var(--tooltip-text-color); background: var(--tooltip-bg); padding: var(--tooltip-padding-y) var(--tooltip-padding-x); border-radius: var(--tooltip-border-radius); pointer-events: none; transition: all var(--tooltip-transition-duration, 0.3s) cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 1000; } .tooltip::before { content: attr(data-text-initial); } .tooltip::after { content: ""; width: var(--tooltip-padding-y); height: var(--tooltip-padding-y); background: inherit; position: absolute; top: 50%; left: calc(var(--tooltip-padding-y) / 2 * -1); transform: translateY(-50%) rotate(45deg); z-index: -999; pointer-events: none; } .copy-button svg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .checkmark, .failedmark { display: none; } .copy-button:hover .tooltip, .copy-button:focus:not(:focus-visible) .tooltip { opacity: 1; visibility: visible; } .copy-button:focus:not(:focus-visible) .tooltip::before { content: attr(data-text-end); } .copy-button.copy-failed:focus:not(:focus-visible) .tooltip::before { content: attr(data-text-failed); } .copy-button:focus:not(:focus-visible) .clipboard { display: none; } .copy-button:focus:not(:focus-visible) .checkmark { display: block; } .copy-button.copy-failed:focus:not(:focus-visible) .checkmark { display: none; } .copy-button.copy-failed:focus:not(:focus-visible) .failedmark { display: block; } .copy-button:hover, .copy-button:focus { background-color: var(--button-hover-bg); } .copy-button:active { outline: var(--button-outline-width) solid var(--button-outline-color); } .copy-button:hover svg { color: var(--button-hover-text-color); } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } } /* 当按钮处于 loading 状态时,应用脉冲动画 */ .copy-button.loading { animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; } .copy-button.loading .checkmark, .copy-button.loading .failedmark { display: none; /* Loading 时隐藏对勾和叉号 */ } /* 设置界面样式 - shadcn 风格(简约) */ .linuxdo-settings-dialog { /* 优先使用 Discourse 主题变量,自动适配深浅色;无变量时回退到浅色 */ --ld-bg: var(--secondary, #ffffff); --ld-fg: var(--primary, #0f172a); --ld-muted: var(--primary-very-low, #f1f5f9); --ld-muted-fg: var(--primary-medium, #64748b); --ld-card: var(--secondary, #ffffff); --ld-border: var(--content-border-color, rgba(15, 23, 42, 0.12)); --ld-ring: var(--tertiary-low, rgba(59, 130, 246, 0.45)); --ld-primary: var(--primary, #0f172a); --ld-primary-fg: var(--secondary, #ffffff); border: none; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: min(85vh, 760px); background: transparent; overflow: visible; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji"; } .linuxdo-settings-dialog, .linuxdo-settings-dialog * { box-sizing: border-box; } html[style*="color-scheme: dark"] .linuxdo-settings-dialog, html.dark .linuxdo-settings-dialog { /* 深色模式兜底:仅当站点未提供主题变量时生效 */ --ld-bg: var(--secondary, #0b1220); --ld-fg: var(--primary, #e2e8f0); --ld-muted: var(--primary-very-low, rgba(148, 163, 184, 0.12)); --ld-muted-fg: var(--primary-medium, #94a3b8); --ld-card: var(--secondary, #0f172a); --ld-border: var(--content-border-color, rgba(148, 163, 184, 0.18)); --ld-ring: var(--tertiary-low, rgba(59, 130, 246, 0.55)); --ld-primary: var(--primary, #e2e8f0); --ld-primary-fg: var(--secondary, #0b1220); } .linuxdo-settings-dialog::backdrop { background: rgba(2, 6, 23, 0.65); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); } .linuxdo-settings-content { background: var(--ld-bg); color: var(--ld-fg); border: 1px solid var(--ld-border); border-radius: 12px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; max-height: inherit; overflow: hidden; } .linuxdo-settings-dialog[closing] .linuxdo-settings-content { animation: ldDialogOut 0.16s ease-in forwards; } @keyframes ldDialogOut { to { opacity: 0; transform: translateY(6px) scale(0.985); } } .linuxdo-settings-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--ld-border); background: var(--ld-bg); flex-shrink: 0; } .linuxdo-settings-title { font-size: 16px; font-weight: 600; line-height: 1.25; margin: 0; letter-spacing: -0.01em; } .linuxdo-settings-subtitle { margin: 6px 0 0; font-size: 12px; color: var(--ld-muted-fg); line-height: 1.3; } .linuxdo-settings-close { appearance: none; border: 1px solid var(--ld-border); background: transparent; color: var(--ld-muted-fg); border-radius: 10px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; flex-shrink: 0; line-height: 1; } .linuxdo-settings-close:hover { background: var(--ld-muted); color: var(--ld-fg); } .linuxdo-settings-close:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ld-ring); } .linuxdo-settings-form { padding: 18px; overflow-y: auto; flex: 1; } .linuxdo-settings-section + .linuxdo-settings-section { margin-top: 18px; } .linuxdo-settings-section-header { margin-bottom: 10px; } .linuxdo-settings-section-title { font-size: 12px; font-weight: 600; color: var(--ld-muted-fg); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 4px; } .linuxdo-settings-section-desc { margin: 0; font-size: 12px; color: var(--ld-muted-fg); } .linuxdo-settings-card { border: 1px solid var(--ld-border); border-radius: 12px; background: var(--ld-card); padding: 14px; display: flex; flex-direction: column; gap: 14px; } .linuxdo-settings-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; } .linuxdo-settings-item-text { min-width: 0; flex: 1; } .linuxdo-settings-item-label { display: block; font-size: 14px; font-weight: 500; color: var(--ld-fg); margin: 0; } .linuxdo-settings-description { font-size: 12px; color: var(--ld-muted-fg); margin-top: 6px; line-height: 1.4; } .linuxdo-settings-separator { height: 1px; width: 100%; background: var(--ld-border); } .linuxdo-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .linuxdo-settings-field { display: flex; flex-direction: column; gap: 6px; } .linuxdo-settings-label { font-size: 11px; font-weight: 500; color: var(--ld-fg); } .linuxdo-settings-input, .linuxdo-settings-textarea { width: 100%; border: 1px solid var(--ld-border); background: var(--ld-bg); color: var(--ld-fg); border-radius: 9px; padding: 7px 9px; font-size: 11px; line-height: 1.4; font-family: inherit; outline: none; transition: box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease; } .linuxdo-settings-control { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; } .linuxdo-settings-input.small { width: 68px; text-align: center; padding: 6px 8px; } .linuxdo-settings-unit { font-size: 11px; color: var(--ld-muted-fg); line-height: 1; } .linuxdo-settings-input::placeholder, .linuxdo-settings-textarea::placeholder { color: var(--ld-muted-fg); } .linuxdo-settings-input:focus-visible, .linuxdo-settings-textarea:focus-visible { box-shadow: 0 0 0 3px var(--ld-ring); border-color: rgba(59, 130, 246, 0.65); } .linuxdo-settings-textarea { resize: vertical; min-height: 90px; } /* Switch */ .linuxdo-settings-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; } .linuxdo-settings-switch input { opacity: 0; width: 0; height: 0; } .linuxdo-settings-switch-slider { position: absolute; inset: 0; border-radius: 999px; border: 1px solid var(--ld-border); background: var(--ld-muted); cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; } .linuxdo-settings-switch-slider:before { position: absolute; content: ""; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 999px; background: var(--ld-bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); transition: transform 0.15s ease, background 0.15s ease; } .linuxdo-settings-switch input:checked + .linuxdo-settings-switch-slider { background: var(--ld-primary); border-color: var(--ld-primary); } .linuxdo-settings-switch input:checked + .linuxdo-settings-switch-slider:before { transform: translateX(20px); background: var(--ld-primary-fg); } .linuxdo-settings-switch input:focus-visible + .linuxdo-settings-switch-slider { box-shadow: 0 0 0 3px var(--ld-ring); } .linuxdo-settings-footer { display: flex; gap: 10px; padding: 14px 18px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--ld-border); background: var(--ld-bg); flex-shrink: 0; } .linuxdo-settings-button { flex: 1; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--ld-border); background: transparent; color: var(--ld-fg); cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit; transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease; } .linuxdo-settings-button:hover { background: var(--ld-muted); } .linuxdo-settings-button:active { transform: translateY(1px); } .linuxdo-settings-button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ld-ring); } .linuxdo-settings-button.primary { background: var(--ld-primary); border-color: var(--ld-primary); color: var(--ld-primary-fg); } .linuxdo-settings-button.primary:hover { filter: brightness(0.98); } @media (max-width: 520px) { .linuxdo-settings-dialog { width: calc(100vw - 16px); max-height: 92vh; } .linuxdo-settings-form { padding: 14px; } .linuxdo-settings-header, .linuxdo-settings-footer { padding-left: 14px; padding-right: 14px; } .linuxdo-settings-grid { grid-template-columns: 1fr; } } /* 历史复制内容(搜索框右侧) */ .linuxdo-copy-history-trigger { --ld-h-bg: var(--secondary, #ffffff); --ld-h-fg: var(--primary, #0f172a); --ld-h-muted: var(--primary-very-low, #f1f5f9); --ld-h-muted-fg: var(--primary-medium, #64748b); --ld-h-border: var(--primary-low, rgba(15, 23, 42, 0.12)); --ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.45)); appearance: none; border: 1px solid var(--ld-h-border); background: transparent; color: var(--ld-h-muted-fg); width: 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin-left: 2px; margin-right: 2px; transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; } html[style*="color-scheme: dark"] .linuxdo-copy-history-trigger, html.dark .linuxdo-copy-history-trigger { --ld-h-bg: var(--secondary, #111827); --ld-h-fg: var(--primary, #e5e7eb); --ld-h-muted: var(--primary-very-low, rgba(148, 163, 184, 0.12)); --ld-h-muted-fg: var(--primary-medium, #9ca3af); --ld-h-border: var(--primary-low, rgba(148, 163, 184, 0.18)); --ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.55)); } .linuxdo-copy-history-trigger:hover { background: var(--ld-h-muted); color: var(--ld-h-fg); } .linuxdo-copy-history-trigger:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-trigger svg { width: 16px; height: 16px; display: block; } .linuxdo-copy-history-popover { --ld-h-bg: var(--secondary, #ffffff); --ld-h-fg: var(--primary, #0f172a); --ld-h-muted: var(--primary-very-low, #f1f5f9); --ld-h-muted-fg: var(--primary-medium, #64748b); --ld-h-border: var(--primary-low, rgba(15, 23, 42, 0.12)); --ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.18)); position: fixed; z-index: 100000; width: min(520px, calc(100vw - 24px)); max-height: min(70vh, 520px); overflow: auto; background: var(--ld-h-bg); color: var(--ld-h-fg); border: 1px solid var(--ld-h-border); border-radius: 12px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28); padding: 10px; display: none; } html[style*="color-scheme: dark"] .linuxdo-copy-history-popover, html.dark .linuxdo-copy-history-popover { --ld-h-bg: var(--secondary, #111827); --ld-h-fg: var(--primary, #e5e7eb); --ld-h-muted: var(--primary-very-low, rgba(148, 163, 184, 0.12)); --ld-h-muted-fg: var(--primary-medium, #9ca3af); --ld-h-border: var(--primary-low, rgba(148, 163, 184, 0.18)); --ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.24)); box-shadow: 0 24px 90px rgba(0, 0, 0, 0.52); } .linuxdo-copy-history-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 2px 10px; border-bottom: 1px solid var(--ld-h-border); margin-bottom: 8px; } .linuxdo-copy-history-header-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; } .linuxdo-copy-history-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ld-h-muted-fg); } .linuxdo-copy-history-select-all { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--ld-h-border); background: transparent; font-size: 12px; font-weight: 500; line-height: 1; color: var(--ld-h-muted-fg); user-select: none; cursor: pointer; white-space: nowrap; transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease; } .linuxdo-copy-history-select-all:hover { background: var(--ld-h-muted); color: var(--ld-h-fg); box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-select-all:active { transform: translateY(1px); } .linuxdo-copy-history-select-all input[type="checkbox"] { width: 14px; height: 14px; margin: 0; display: block; cursor: pointer; accent-color: var(--tertiary, #3b82f6); } .linuxdo-copy-history-settings-btn, .linuxdo-copy-history-delete-btn { appearance: none; border: 1px solid var(--ld-h-border); background: transparent; color: var(--ld-h-muted-fg); height: 24px; padding: 0 10px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; font-weight: 500; line-height: 1; transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease; } .linuxdo-copy-history-settings-btn:hover, .linuxdo-copy-history-delete-btn:hover { background: var(--ld-h-muted); color: var(--ld-h-fg); box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-settings-btn:active, .linuxdo-copy-history-delete-btn:active { transform: translateY(1px); } .linuxdo-copy-history-settings-btn:focus-visible, .linuxdo-copy-history-delete-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-delete-btn { color: var(--danger, #b91c1c); } .linuxdo-copy-history-delete-btn:hover { background: var(--danger-low, rgba(239, 68, 68, 0.12)); color: var(--danger, #991b1b); box-shadow: 0 0 0 3px var(--danger-low, rgba(239, 68, 68, 0.22)); } .linuxdo-copy-history-delete-btn:disabled { opacity: 0.5; cursor: not-allowed; } .linuxdo-copy-history-delete-btn:disabled:hover { background: transparent; color: var(--ld-h-muted-fg); box-shadow: none; } .linuxdo-copy-history-hint { font-size: 12px; color: var(--ld-h-muted-fg); white-space: nowrap; } .linuxdo-copy-history-list { display: flex; flex-direction: column; gap: 8px; } .linuxdo-copy-history-item { border: 1px solid var(--ld-h-border); border-radius: 12px; padding: 10px; background: transparent; transition: background 0.15s ease, box-shadow 0.15s ease; } .linuxdo-copy-history-item.is-selected { background: var(--ld-h-muted); box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-item:hover { background: var(--ld-h-muted); box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; } .linuxdo-copy-history-item-checkbox-wrap { display: inline-flex; align-items: flex-start; padding-top: 2px; flex-shrink: 0; } .linuxdo-copy-history-item-checkbox { width: 14px; height: 14px; margin: 0; display: block; cursor: pointer; accent-color: var(--tertiary, #3b82f6); } .linuxdo-copy-history-item-text { min-width: 0; flex: 1; } .linuxdo-copy-history-item-title { font-size: 13px; font-weight: 600; line-height: 1.35; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .linuxdo-copy-history-item-snippet { margin-top: 4px; font-size: 12px; color: var(--ld-h-muted-fg); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .linuxdo-copy-history-actions { display: flex; gap: 6px; flex-shrink: 0; } .linuxdo-copy-history-btn { appearance: none; border: 1px solid var(--ld-h-border); background: transparent; color: var(--ld-h-fg); border-radius: 10px; padding: 6px 10px; font-size: 12px; font-weight: 500; cursor: pointer; transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease; white-space: nowrap; } .linuxdo-copy-history-btn:hover { background: var(--ld-h-muted); box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-btn:active { transform: translateY(1px); } .linuxdo-copy-history-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ld-h-ring); } .linuxdo-copy-history-empty { padding: 18px 8px; text-align: center; font-size: 12px; color: var(--ld-h-muted-fg); } `; /** * @description 将 CSS 样式注入到页面中。 * 优先使用 GM_addStyle API,如果不可用,则创建一个