可为Gemini切换多种主题(暖黄护眼、Atom One Dark、Monokai、Dracula),并可随时恢复默认主题。
当前为
// ==UserScript==
// @name Gemini Theme Switcher
// @name:zh-CN Gemini 主题切换器
// @namespace http://tampermonkey.net/
// @version 1.0
// @description A single script to switch between multiple themes (Warm Yellow, Atom One Dark, Monokai, Dracula) for Gemini, with an option to restore the default.
// @description:zh-CN 可为Gemini切换多种主题(暖黄护眼、Atom One Dark、Monokai、Dracula),并可随时恢复默认主题。
// @author Gemini
// @match https://gemini.google.com/*
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// --- 主题定义 ---
const themes = {
warm: {
className: 'warm-yellow-theme',
displayName: 'Warm Yellow',
css: `
.warm-yellow-theme, body.warm-yellow-theme {
color-scheme: light !important;
--gem-sys-color--primary: #D97706 !important; --gem-sys-color--on-primary: #FFFFFF !important; --gem-sys-color--primary-container: #FAEFE0 !important; --gem-sys-color--on-primary-container: #5D4037 !important;
--gem-sys-color--secondary: #A1887F !important; --gem-sys-color--on-secondary: #FFFFFF !important; --gem-sys-color--secondary-container: #EFEBE9 !important; --gem-sys-color--on-secondary-container: #5D4037 !important;
--gem-sys-color--tertiary: #689F38 !important; --gem-sys-color--on-tertiary: #FFFFFF !important; --gem-sys-color--error: #C62828 !important; --gem-sys-color--on-error: #FFFFFF !important;
--gem-sys-color--surface: #FDF6E3 !important; --gem-sys-color--surface-bright: #FEFBF3 !important; --gem-sys-color--surface-container: #F8F0D9 !important; --gem-sys-color--surface-container-high: #F3EADF !important; --gem-sys-color--surface-container-highest: #EDE4D5 !important; --gem-sys-color--surface-container-low: #FEFBF3 !important; --gem-sys-color--surface-container-lowest: #FFFFFF !important;
--bard-color-synthetic--chat-window-surface: var(--gem-sys-color--surface) !important; --mat-app-background-color: var(--gem-sys-color--surface) !important;
--gem-sys-color--on-surface: #4F4A45 !important; --gem-sys-color--on-surface-variant: #655F5A !important; --mat-app-text-color: var(--gem-sys-color--on-surface) !important; --bard-color-form-field-placeholder: #9E9A97 !important;
--gem-sys-color--outline: #DCD5C9 !important; --gem-sys-color--outline-variant: #CEC8BD !important;
--bard-color-response-container-flipped-background: #F8F0D9 !important; --bard-color-zero-state-prompt-chip-background: #FAEFE0 !important; --bard-color-zero-state-prompt-chip-text: #D97706 !important; --bard-color-image-placeholder-background: #EDE4D5 !important;
--bard-color-code-comment: #A08C7D !important; --bard-color-code-variables: #B7410E !important; --bard-color-code-literal: #6C6C6C !important; --bard-color-code-class: #A67B5B !important; --bard-color-code-string: #556B2F !important; --bard-color-code-quotes-and-meta: #3E646E !important; --bard-color-code-keyword: #C77800 !important;
}
body.dark-theme.warm-yellow-theme, body.warm-yellow-theme { background-color: var(--gem-sys-color--surface) !important; color: var(--gem-sys-color--on-surface) !important; }
`
},
atom: {
className: 'atom-one-dark-theme',
displayName: 'Atom One Dark',
css: `
.atom-one-dark-theme, body.atom-one-dark-theme {
color-scheme: dark !important;
--gem-sys-color--primary: #528bff !important; --gem-sys-color--on-primary: #FFFFFF !important; --gem-sys-color--primary-container: #2a3a5c !important; --gem-sys-color--on-primary-container: #a6c8ff !important;
--gem-sys-color--secondary: #c679dd !important; --gem-sys-color--on-secondary: #FFFFFF !important; --gem-sys-color--secondary-container: #4a2c58 !important; --gem-sys-color--on-secondary-container: #e0aaff !important;
--gem-sys-color--tertiary: #97c378 !important; --gem-sys-color--on-tertiary: #1a2b1f !important; --gem-sys-color--error: #df6a73 !important; --gem-sys-color--on-error: #FFFFFF !important;
--gem-sys-color--surface: #272b33 !important; --gem-sys-color--surface-bright: #3d4350 !important; --gem-sys-color--surface-container: #2b3039 !important; --gem-sys-color--surface-container-high: #3d4350 !important; --gem-sys-color--surface-container-highest: #4a5160 !important; --gem-sys-color--surface-container-low: #292d35 !important; --gem-sys-color--surface-container-lowest: #272b33 !important;
--bard-color-synthetic--chat-window-surface: var(--gem-sys-color--surface) !important; --mat-app-background-color: var(--gem-sys-color--surface) !important;
--gem-sys-color--on-surface: #abb2c0 !important; --gem-sys-color--on-surface-variant: #5b626f !important; --mat-app-text-color: var(--gem-sys-color--on-surface) !important; --bard-color-form-field-placeholder: #5b626f !important;
--gem-sys-color--outline: #3d4350 !important; --gem-sys-color--outline-variant: #636e84 !important;
--bard-color-response-container-flipped-background: #2b3039 !important; --bard-color-zero-state-prompt-chip-background: #3d4350 !important; --bard-color-zero-state-prompt-chip-text: #97c378 !important; --bard-color-image-placeholder-background: #2b3039 !important;
--bard-color-code-comment: #5b626f !important; --bard-color-code-variables: #df6a73 !important; --bard-color-code-literal: #d29b67 !important; --bard-color-code-class: #e5c17c !important; --bard-color-code-string: #97c378 !important; --bard-color-code-quotes-and-meta: #57b6c2 !important; --bard-color-code-keyword: #c679dd !important;
--mat-form-field-outlined-input-text-color: #abb2c0 !important; --mat-form-field-filled-input-text-color: #abb2c0 !important; --mat-select-enabled-trigger-text-color: #abb2c0 !important; --mat-menu-item-label-text-color: #abb2c0 !important; --mat-list-list-item-label-text-color: #abb2c0 !important; --mat-dialog-subhead-color: #abb2c0 !important; --mat-dialog-supporting-text-color: #abb2c0 !important;
}
body.light-theme.atom-one-dark-theme, body.atom-one-dark-theme { background-color: var(--gem-sys-color--surface) !important; color: var(--gem-sys-color--on-surface) !important; }
`
},
monokai: {
className: 'monokai-dark-theme',
displayName: 'Monokai',
css: `
.monokai-dark-theme, body.monokai-dark-theme {
color-scheme: dark !important;
--gem-sys-color--primary: #AE81FF !important; --gem-sys-color--on-primary: #272822 !important; --gem-sys-color--primary-container: #3D3063 !important; --gem-sys-color--on-primary-container: #E0CFFD !important;
--gem-sys-color--secondary: #F92672 !important; --gem-sys-color--on-secondary: #FFFFFF !important; --gem-sys-color--secondary-container: #5D1D38 !important; --gem-sys-color--on-secondary-container: #F92672 !important;
--gem-sys-color--tertiary: #A6E22E !important; --gem-sys-color--on-tertiary: #272822 !important; --gem-sys-color--error: #F92672 !important; --gem-sys-color--on-error: #FFFFFF !important;
--gem-sys-color--surface: #272822 !important; --gem-sys-color--surface-bright: #49483E !important; --gem-sys-color--surface-container: #373831 !important; --gem-sys-color--surface-container-high: #49483E !important; --gem-sys-color--surface-container-highest: #5A5953 !important; --gem-sys-color--surface-container-low: #2E2F29 !important; --gem-sys-color--surface-container-lowest: #272822 !important;
--bard-color-synthetic--chat-window-surface: var(--gem-sys-color--surface) !important; --mat-app-background-color: var(--gem-sys-color--surface) !important;
--gem-sys-color--on-surface: #F8F8F2 !important; --gem-sys-color--on-surface-variant: #75715E !important; --mat-app-text-color: var(--gem-sys-color--on-surface) !important; --bard-color-form-field-placeholder: #75715E !important;
--gem-sys-color--outline: #49483E !important; --gem-sys-color--outline-variant: #75715E !important;
--bard-color-response-container-flipped-background: #373831 !important; --bard-color-zero-state-prompt-chip-background: #49483E !important; --bard-color-zero-state-prompt-chip-text: #E6DB74 !important; --bard-color-image-placeholder-background: #373831 !important;
--bard-color-code-comment: #75715e !important; --bard-color-code-variables: #a6e22e !important; --bard-color-code-literal: #ae81ff !important; --bard-color-code-class: #a6e22e !important; --bard-color-code-string: #e6db74 !important; --bard-color-code-quotes-and-meta: #fd971f !important; --bard-color-code-keyword: #f92672 !important;
--mat-form-field-outlined-input-text-color: #F8F8F2 !important; --mat-form-field-filled-input-text-color: #F8F8F2 !important; --mat-select-enabled-trigger-text-color: #F8F8F2 !important; --mat-menu-item-label-text-color: #F8F8F2 !important; --mat-list-list-item-label-text-color: #F8F8F2 !important; --mat-dialog-subhead-color: #F8F8F2 !important; --mat-dialog-supporting-text-color: #F8F8F2 !important;
}
body.light-theme.monokai-dark-theme, body.monokai-dark-theme { background-color: var(--gem-sys-color--surface) !important; color: var(--gem-sys-color--on-surface) !important; }
`
},
dracula: {
className: 'dracula-dark-theme',
displayName: 'Dracula',
css: `
.dracula-dark-theme, body.dracula-dark-theme {
color-scheme: dark !important;
--gem-sys-color--primary: #bd93f9 !important; --gem-sys-color--on-primary: #282a36 !important; --gem-sys-color--primary-container: #4c396e !important; --gem-sys-color--on-primary-container: #e0b3ff !important;
--gem-sys-color--secondary: #8be9fd !important; --gem-sys-color--on-secondary: #282a36 !important; --gem-sys-color--secondary-container: #2a505c !important; --gem-sys-color--on-secondary-container: #b5ffff !important;
--gem-sys-color--tertiary: #50fa7b !important; --gem-sys-color--on-tertiary: #282a36 !important; --gem-sys-color--error: #ff5555 !important; --gem-sys-color--on-error: #FFFFFF !important;
--gem-sys-color--surface: #282a36 !important; --gem-sys-color--surface-bright: #44475a !important; --gem-sys-color--surface-container: #44475a !important; --gem-sys-color--surface-container-high: #535870 !important; --gem-sys-color--surface-container-highest: #6272a4 !important; --gem-sys-color--surface-container-low: #353746 !important; --gem-sys-color--surface-container-lowest: #282a36 !important;
--bard-color-synthetic--chat-window-surface: var(--gem-sys-color--surface) !important; --mat-app-background-color: var(--gem-sys-color--surface) !important;
--gem-sys-color--on-surface: #f8f8f2 !important; --gem-sys-color--on-surface-variant: #6272a4 !important; --mat-app-text-color: var(--gem-sys-color--on-surface) !important; --bard-color-form-field-placeholder: #6272a4 !important;
--gem-sys-color--outline: #44475a !important; --gem-sys-color--outline-variant: #6272a4 !important;
--bard-color-response-container-flipped-background: #44475a !important; --bard-color-zero-state-prompt-chip-background: #44475a !important; --bard-color-zero-state-prompt-chip-text: #f1fa8c !important; --bard-color-image-placeholder-background: #44475a !important;
--bard-color-code-comment: #6272a4 !important; --bard-color-code-variables: #ffb86c !important; --bard-color-code-literal: #bd93f9 !important; --bard-color-code-class: #8be9fd !important; --bard-color-code-string: #f1fa8c !important; --bard-color-code-quotes-and-meta: #50fa7b !important; --bard-color-code-keyword: #ff79c6 !important;
--mat-form-field-outlined-input-text-color: #f8f8f2 !important; --mat-form-field-filled-input-text-color: #f8f8f2 !important; --mat-select-enabled-trigger-text-color: #f8f8f2 !important; --mat-menu-item-label-text-color: #f8f8f2 !important; --mat-list-list-item-label-text-color: #f8f8f2 !important; --mat-dialog-subhead-color: #f8f8f2 !important; --mat-dialog-supporting-text-color: #f8f8f2 !important;
}
body.light-theme.dracula-dark-theme, body.dracula-dark-theme { background-color: var(--gem-sys-color--surface) !important; color: var(--gem-sys-color--on-surface) !important; }
`
}
};
// --- 脚本逻辑 ---
// 1. 组合所有主题的CSS
let fullCSS = "";
for (const themeKey in themes) {
fullCSS += themes[themeKey].css;
}
// 额外添加一个全局规则,确保在切换主题时动画平滑
fullCSS += `
body, .mat-app-background {
transition: background-color 0.3s ease, color 0.3s ease !important;
}
`;
// 2. 注入所有CSS
if (fullCSS) {
GM_addStyle(fullCSS);
}
// 3. 读取用户保存的选择
const activeThemeKey = GM_getValue('selectedTheme', 'default');
// 4. 应用当前激活的主题
if (activeThemeKey && themes[activeThemeKey]) {
document.body.classList.add(themes[activeThemeKey].className);
}
// 5. 设置主题并重新加载页面的函数
function applyThemeAndReload(themeKey) {
GM_setValue('selectedTheme', themeKey);
window.location.reload();
}
// 6. 注册菜单命令
for (const themeKey in themes) {
const theme = themes[themeKey];
const isActive = activeThemeKey === themeKey;
GM_registerMenuCommand(`${isActive ? '✅ ' : ''}${theme.displayName}`, () => applyThemeAndReload(themeKey));
}
// 添加恢复默认的选项
const isDefaultActive = activeThemeKey === 'default';
GM_registerMenuCommand(`${isDefaultActive ? '✅ ' : ''}Restore Default`, () => applyThemeAndReload('default'));
console.log(`Gemini Theme Switcher: Active theme is "${activeThemeKey}".`);
})();