Google AI Studio 主题切换器(含日夜自动切换)

为Google AI Studio提供可切换的数种护眼主题。自动日夜模式可记忆您最后选择的浅色与深色主题。

  1. // ==UserScript==
  2. // @name Google AI Studio Theme Switcher with Auto Day/Night
  3. // @name:zh-CN Google AI Studio 主题切换器(含日夜自动切换)
  4. // @namespace http://tampermonkey.net/
  5. // @version 2.4.1
  6. // @description Instantly switch between themes (Warm Yellow, Mint Light, Atom One Dark, etc.) for Google AI Studio, with auto day/night mode that remembers your last chosen light and dark themes.
  7. // @description:zh-CN 为Google AI Studio提供可切换的数种护眼主题。自动日夜模式可记忆您最后选择的浅色与深色主题。
  8. // @author Gemini
  9. // @match https://aistudio.google.com/*
  10. // @grant GM_addStyle
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_registerMenuCommand
  14. // @grant GM_unregisterMenuCommand
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. // --- Theme Definitions ---
  22. const themes = {
  23. warm: {
  24. className: 'warm-yellow-theme',
  25. displayName: 'Warm Yellow',
  26. isDark: false,
  27. css: `
  28. body.warm-yellow-theme{color-scheme:light !important;--mat-sys-primary:#f8f0d9 !important;--mat-sys-on-primary:#5D4037 !important;--mat-sys-primary-container:#FAEFE0 !important;--mat-sys-on-primary-container:#5D4037 !important;--mat-sys-secondary:#A1887F !important;--mat-sys-on-secondary:#fff !important;--mat-sys-secondary-container:#EFEBE9 !important;--mat-sys-on-secondary-container:#5D4037 !important;--mat-sys-tertiary:#689F38 !important;--mat-sys-on-tertiary:#fff !important;--mat-sys-error:#C62828 !important;--mat-sys-on-error:#fff !important;--mat-sys-error-container:#fce8e6 !important;--mat-sys-on-error-container:#791a1a !important;--color-v3-error-container:var(--mat-sys-error-container) !important;--color-v3-error-text:#791a1a !important;--mat-sys-background:#FDF6E3 !important;--mat-sys-surface:#FDF6E3 !important;--mat-sys-surface-bright:#FEFBF3 !important;--mat-sys-surface-container:#F8f0d9 !important;--mat-sys-surface-container-high:#F3EADF !important;--mat-sys-surface-container-highest:#EDE4D5 !important;--mat-sys-surface-container-low:#FEFBF3 !important;--mat-sys-surface-container-lowest:#fff !important;--color-v3-surface:var(--mat-sys-surface) !important;--color-v3-surface-container:var(--mat-sys-surface-container) !important;--color-v3-surface-container-high:var(--mat-sys-surface-container-high) !important;--color-v3-surface-container-highest:var(--mat-sys-surface-container-highest) !important;--mat-app-background-color:var(--mat-sys-background) !important;--color-canvas-background:var(--mat-sys-background) !important;--color-v3-surface-left-nav:#f8f0d9 !important;--mat-sys-on-background:#4F4A45 !important;--mat-sys-on-surface:#4F4A45 !important;--mat-sys-on-surface-variant:#655F5A !important;--color-v3-text:var(--mat-sys-on-surface) !important;--color-v3-text-var:var(--mat-sys-on-surface-variant) !important;--color-v3-text-on-button:var(--mat-sys-on-primary) !important;--color-v3-text-link:#B7410E !important;--mat-app-text-color:var(--mat-sys-on-surface) !important;--mat-sys-outline:#DCD5C9 !important;--mat-sys-outline-variant:#CEC8BD !important;--color-v3-outline:var(--mat-sys-outline) !important;--color-v3-outline-var:var(--mat-sys-outline-variant) !important;--color-v3-button-container:var(--mat-sys-primary) !important;--color-v3-button-container-high:#f3e7c4 !important;--color-v3-button-container-highest:#f3e7c4 !important;--color-v3-hover:#F8F0D9 !important;background-color:var(--mat-sys-background) !important;color:var(--mat-sys-on-background) !important}.warm-yellow-theme ms-right-side-panel,.warm-yellow-theme .mat-mdc-row:hover,.warm-yellow-theme .prompt-input-wrapper{background:#f8f0d9 !important}.warm-yellow-theme .run-button,.warm-yellow-theme mat-expansion-panel-header:hover{background:#f3e7c4 !important}.warm-yellow-theme .mat-mdc-row a{color:#777 !important}.warm-yellow-theme .hljs{background:#F8F0D9 !important;color:#4F4A45 !important}.warm-yellow-theme .hljs-comment,.warm-yellow-theme .hljs-quote{color:#A08C7D !important}.warm-yellow-theme .hljs-variable,.warm-yellow-theme .hljs-template-variable,.warm-yellow-theme .hljs-attr,.warm-yellow-theme .hljs-selector-id,.warm-yellow-theme .hljs-selector-class,.warm-yellow-theme .hljs-regexp,.warm-yellow-theme .hljs-deletion{color:#B7410E !important}.warm-yellow-theme .hljs-number,.warm-yellow-theme .hljs-built_in,.warm-yellow-theme .hljs-literal,.warm-yellow-theme .hljs-type,.warm-yellow-theme .hljs-params,.warm-yellow-theme .hljs-meta,.warm-yellow-theme .hljs-link{color:#856b3d !important}.warm-yellow-theme .hljs-keyword,.warm-yellow-theme .hljs-selector-tag{color:#C77800 !important}.warm-yellow-theme .hljs-string,.warm-yellow-theme .hljs-symbol,.warm-yellow-theme .hljs-bullet,.warm-yellow-theme .hljs-addition{color:#556B2F !important}.warm-yellow-theme .hljs-title,.warm-yellow-theme .hljs-title.function_,.warm-yellow-theme .hljs-section{color:#A67B5B !important}.warm-yellow-theme .hljs-emphasis{font-style:italic !important}.warm-yellow-theme .hljs-strong{font-weight:700 !important}`
  29. },
  30. mintLight: {
  31. className: 'mint-light-theme',
  32. displayName: 'Mint Light',
  33. isDark: false,
  34. css: `
  35. body.mint-light-theme{color-scheme:light !important;--mat-sys-primary:#eaf4f4 !important;--mat-sys-on-primary:#3b413c !important;--mat-sys-primary-container:#daf0ee !important;--mat-sys-on-primary-container:#3b413c !important;--mat-sys-secondary:#cce3de !important;--mat-sys-on-secondary:#3b413c !important;--mat-sys-secondary-container:#eaf4f4 !important;--mat-sys-on-secondary-container:#3b413c !important;--mat-sys-tertiary:#a4c3b2 !important;--mat-sys-on-tertiary:#3b413c !important;--mat-sys-error:#ff686b !important;--mat-sys-on-error:#fff !important;--mat-sys-background:#f6fff8 !important;--mat-sys-surface:#f6fff8 !important;--mat-sys-surface-bright:#f6fff8 !important;--mat-sys-surface-container:#eaf4f4 !important;--mat-sys-surface-container-high:#daf0ee !important;--mat-sys-surface-container-highest:#cce3de !important;--mat-sys-surface-container-low:#f6fff8 !important;--mat-sys-surface-container-lowest:#f6fff8 !important;--color-v3-surface:var(--mat-sys-background) !important;--mat-app-background-color:var(--mat-sys-background) !important;--color-canvas-background:var(--mat-sys-background) !important;--color-v3-surface-left-nav:#eaf4f4 !important;--mat-sys-on-background:#3b413c !important;--mat-sys-on-surface:#3b413c !important;--mat-sys-on-surface-variant:#a4c3b2 !important;--color-v3-text-link:#6b9080 !important;--mat-sys-outline:#cce3de !important;--mat-sys-outline-variant:#a4c3b2 !important;--color-v3-hover:#cce3de !important;background-color:var(--mat-sys-background) !important;color:var(--mat-sys-on-background) !important}.mint-light-theme ms-right-side-panel,.mint-light-theme .mat-mdc-row:hover,.mint-light-theme .prompt-input-wrapper{background:#eaf4f4 !important}.mint-light-theme .run-button{background:#cce3de !important}.mint-light-theme .mat-mdc-row a{color:#3b413c !important}.mint-light-theme .hljs{background:#eaf4f4 !important;color:#3b413c !important}.mint-light-theme .hljs-comment,.mint-light-theme .hljs-quote{color:#aaaaaa !important;font-style:italic}.mint-light-theme .hljs-variable,.mint-light-theme .hljs-template-variable,.mint-light-theme .hljs-attr,.mint-light-theme .hljs-selector-id,.mint-light-theme .hljs-selector-class,.mint-light-theme .hljs-regexp,.mint-light-theme .hljs-deletion{color:#3a506b !important}.mint-light-theme .hljs-number,.mint-light-theme .hljs-built_in,.mint-light-theme .hljs-literal,.mint-light-theme .hljs-type,.mint-light-theme .hljs-params,.mint-light-theme .hljs-meta,.mint-light-theme .hljs-link{color:#ee6352 !important}.mint-light-theme .hljs-keyword,.mint-light-theme .hljs-selector-tag{color:#0b132b !important}.mint-light-theme .hljs-string,.mint-light-theme .hljs-symbol,.mint-light-theme .hljs-bullet,.mint-light-theme .hljs-addition{color:#448c27 !important}.mint-light-theme .hljs-title,.mint-light-theme .hljs-title.function_,.mint-light-theme .hljs-section{color:#ed6a5e !important;font-weight:700}.mint-light-theme .hljs-emphasis{font-style:italic !important}.mint-light-theme .hljs-strong{font-weight:700 !important}`
  36. },
  37. atom: {
  38. className: 'atom-one-dark-theme',
  39. displayName: 'Atom One Dark',
  40. isDark: true,
  41. css: `
  42. body.atom-one-dark-theme{color-scheme:dark !important;--mat-sys-primary:#528bff !important;--mat-sys-on-primary:#fff !important;--mat-sys-primary-container:#2a3a5c !important;--mat-sys-on-primary-container:#a6c8ff !important;--mat-sys-secondary:#c679dd !important;--mat-sys-on-secondary:#fff !important;--mat-sys-secondary-container:#4a2c58 !important;--mat-sys-on-secondary-container:#e0aaff !important;--mat-sys-tertiary:#97c378 !important;--mat-sys-on-tertiary:#1a2b1f !important;--mat-sys-error:#df6a73 !important;--mat-sys-on-error:#fff !important;--mat-sys-background:#282c34 !important;--mat-sys-surface:#282c34 !important;--mat-sys-surface-bright:#3d4350 !important;--mat-sys-surface-container:#21252b !important;--mat-sys-surface-container-high:#3d4350 !important;--mat-sys-surface-container-highest:#4a5160 !important;--mat-sys-surface-container-low:#292d35 !important;--mat-sys-surface-container-lowest:#272b33 !important;--color-v3-surface:var(--mat-sys-background) !important;--mat-app-background-color:var(--mat-sys-background) !important;--color-canvas-background:var(--mat-sys-background) !important;--color-v3-surface-left-nav:#21252b !important;--mat-sys-on-background:#9da5b4 !important;--mat-sys-on-surface:#9da5b4 !important;--mat-sys-on-surface-variant:#5c6370 !important;--color-v3-text-link:#528bff !important;--mat-sys-outline:#3d4350 !important;--mat-sys-outline-variant:#636e84 !important;--color-v3-hover:#3a4049 !important;background-color:var(--mat-sys-background) !important;color:var(--mat-sys-on-background) !important}.atom-one-dark-theme ms-right-side-panel,.atom-one-dark-theme .mat-mdc-row:hover,.atom-one-dark-theme .prompt-input-wrapper,.atom-one-dark-theme .hljs{background:#21252b !important}.atom-one-dark-theme .run-button{background:#3a4049 !important}.atom-one-dark-theme .mat-mdc-row a,.atom-one-dark-theme .hljs{color:#9da5b4 !important}.atom-one-dark-theme .hljs-comment,.atom-one-dark-theme .hljs-quote{color:#5c6370 !important}.atom-one-dark-theme .hljs-variable,.atom-one-dark-theme .hljs-template-variable,.atom-one-dark-theme .hljs-attr,.atom-one-dark-theme .hljs-selector-id,.atom-one-dark-theme .hljs-selector-class,.atom-one-dark-theme .hljs-regexp,.atom-one-dark-theme .hljs-deletion{color:#e06c75 !important}.atom-one-dark-theme .hljs-number,.atom-one-dark-theme .hljs-built_in,.atom-one-dark-theme .hljs-literal,.atom-one-dark-theme .hljs-type,.atom-one-dark-theme .hljs-params,.atom-one-dark-theme .hljs-meta,.atom-one-dark-theme .hljs-link{color:#d19a66 !important}.atom-one-dark-theme .hljs-keyword,.atom-one-dark-theme .hljs-selector-tag{color:#c678dd !important}.atom-one-dark-theme .hljs-string,.atom-one-dark-theme .hljs-symbol,.atom-one-dark-theme .hljs-bullet,.atom-one-dark-theme .hljs-addition{color:#98c379 !important}.atom-one-dark-theme .hljs-title,.atom-one-dark-theme .hljs-title.function_,.atom-one-dark-theme .hljs-section{color:#61afef !important}`
  43. },
  44. monokai: {
  45. className: 'monokai-dark-theme',
  46. displayName: 'Monokai',
  47. isDark: true,
  48. css: `
  49. body.monokai-dark-theme{color-scheme:dark !important;--mat-sys-primary:#AE81FF !important;--mat-sys-on-primary:#272822 !important;--mat-sys-primary-container:#3D3063 !important;--mat-sys-on-primary-container:#E0CFFD !important;--mat-sys-secondary:#F92672 !important;--mat-sys-on-secondary:#fff !important;--mat-sys-secondary-container:#5D1D38 !important;--mat-sys-on-secondary-container:#F92672 !important;--mat-sys-tertiary:#A6E22E !important;--mat-sys-on-tertiary:#272822 !important;--mat-sys-error:#F92672 !important;--mat-sys-on-error:#fff !important;--mat-sys-background:#2F2F2A !important;--mat-sys-surface:#2F2F2A !important;--mat-sys-surface-bright:#49483E !important;--mat-sys-surface-container:#272822 !important;--mat-sys-surface-container-high:#49483E !important;--mat-sys-surface-container-highest:#5A5953 !important;--mat-sys-surface-container-low:#2E2F29 !important;--mat-sys-surface-container-lowest:#272822 !important;--color-v3-surface:var(--mat-sys-background) !important;--mat-app-background-color:var(--mat-sys-background) !important;--color-canvas-background:var(--mat-sys-background) !important;--color-v3-surface-left-nav:#272822 !important;--mat-sys-on-background:#afaea3 !important;--mat-sys-on-surface:#C5C8C6 !important;--mat-sys-on-surface-variant:#75715E !important;--color-v3-text-link:#66D9EF !important;--mat-sys-outline:#49483E !important;--mat-sys-outline-variant:#75715E !important;--color-v3-hover:#3E3D32 !important;background-color:var(--mat-sys-background) !important;color:var(--mat-sys-on-background) !important}.monokai-dark-theme ms-right-side-panel,.monokai-dark-theme .mat-mdc-row:hover,.monokai-dark-theme .prompt-input-wrapper,.monokai-dark-theme .hljs{background:#272822 !important}.monokai-dark-theme .run-button{background:#3E3D32 !important}.monokai-dark-theme .mat-mdc-row a,.monokai-dark-theme .hljs{color:#C5C8C6 !important}.monokai-dark-theme .hljs-comment,.monokai-dark-theme .hljs-quote{color:#75715e !important}.monokai-dark-theme .hljs-variable,.monokai-dark-theme .hljs-template-variable,.monokai-dark-theme .hljs-attr,.monokai-dark-theme .hljs-selector-id,.monokai-dark-theme .hljs-selector-class,.monokai-dark-theme .hljs-regexp,.monokai-dark-theme .hljs-deletion{color:#a6e22e !important}.monokai-dark-theme .hljs-number,.monokai-dark-theme .hljs-built_in,.monokai-dark-theme .hljs-literal,.monokai-dark-theme .hljs-type,.monokai-dark-theme .hljs-params,.monokai-dark-theme .hljs-meta,.monokai-dark-theme .hljs-link{color:#ae81ff !important}.monokai-dark-theme .hljs-keyword,.monokai-dark-theme .hljs-selector-tag{color:#f92672 !important}.monokai-dark-theme .hljs-string,.monokai-dark-theme .hljs-symbol,.monokai-dark-theme .hljs-bullet,.monokai-dark-theme .hljs-addition{color:#e6db74 !important}.monokai-dark-theme .hljs-title,.monokai-dark-theme .hljs-title.function_,.monokai-dark-theme .hljs-section{color:#66d9ef !important}`
  50. },
  51. dracula: {
  52. className: 'dracula-dark-theme',
  53. displayName: 'Dracula',
  54. isDark: true,
  55. css: `
  56. body.dracula-dark-theme{color-scheme:dark !important;--mat-sys-primary:#bd93f9 !important;--mat-sys-on-primary:#282a36 !important;--mat-sys-primary-container:#4c396e !important;--mat-sys-on-primary-container:#e0b3ff !important;--mat-sys-secondary:#8be9fd !important;--mat-sys-on-secondary:#282a36 !important;--mat-sys-secondary-container:#2a505c !important;--mat-sys-on-secondary-container:#b5ffff !important;--mat-sys-tertiary:#50fa7b !important;--mat-sys-on-tertiary:#282a36 !important;--mat-sys-error:#ff5555 !important;--mat-sys-on-error:#fff !important;--mat-sys-background:#353746 !important;--mat-sys-surface:#353746 !important;--mat-sys-surface-bright:#44475a !important;--mat-sys-surface-container:#282a36 !important;--mat-sys-surface-container-high:#535870 !important;--mat-sys-surface-container-highest:#6272a4 !important;--mat-sys-surface-container-low:#353746 !important;--mat-sys-surface-container-lowest:#282a36 !important;--color-v3-surface:var(--mat-sys-background) !important;--mat-app-background-color:var(--mat-sys-background) !important;--color-canvas-background:var(--mat-sys-background) !important;--color-v3-surface-left-nav:#282a36 !important;--mat-sys-on-background:#BFC2D9 !important;--mat-sys-on-surface:#BFC2D9 !important;--mat-sys-on-surface-variant:#6272a4 !important;--color-v3-text-link:#8be9fd !important;--mat-sys-outline:#44475a !important;--mat-sys-outline-variant:#6272a4 !important;--color-v3-hover:#6272a4 !important;background-color:var(--mat-sys-background) !important;color:var(--mat-sys-on-background) !important}.dracula-dark-theme ms-right-side-panel,.dracula-dark-theme .mat-mdc-row:hover,.dracula-dark-theme .prompt-input-wrapper,.dracula-dark-theme .hljs{background:#282a36 !important}.dracula-dark-theme .run-button{background:#6272a4 !important}.dracula-dark-theme .mat-mdc-row a,.dracula-dark-theme .hljs{color:#BFC2D9 !important}.dracula-dark-theme .hljs-comment,.dracula-dark-theme .hljs-quote{color:#6272a4 !important}.dracula-dark-theme .hljs-variable,.dracula-dark-theme .hljs-template-variable,.dracula-dark-theme .hljs-attr,.dracula-dark-theme .hljs-selector-id,.dracula-dark-theme .hljs-selector-class,.dracula-dark-theme .hljs-regexp,.dracula-dark-theme .hljs-deletion{color:#ffb86c !important}.dracula-dark-theme .hljs-number,.dracula-dark-theme .hljs-built_in,.dracula-dark-theme .hljs-literal,.dracula-dark-theme .hljs-type,.dracula-dark-theme .hljs-params,.dracula-dark-theme .hljs-meta,.dracula-dark-theme .hljs-link{color:#bd93f9 !important}.dracula-dark-theme .hljs-keyword,.dracula-dark-theme .hljs-selector-tag{color:#ff79c6 !important}.dracula-dark-theme .hljs-string,.dracula-dark-theme .hljs-symbol,.dracula-dark-theme .hljs-bullet,.dracula-dark-theme .hljs-addition{color:#f1fa8c !important}.dracula-dark-theme .hljs-title,.dracula-dark-theme .hljs-title.function_,.dracula-dark-theme .hljs-section{color:#50fa7b !important}`
  57. }
  58. };
  59.  
  60. // --- Script Logic ---
  61. let menuCommands = [];
  62.  
  63. // 1. Combine all theme CSS and inject
  64. let fullCSS = "";
  65. for (const themeKey in themes) {
  66. fullCSS += themes[themeKey].css;
  67. }
  68. fullCSS += `body, .mat-app-background { transition: background-color 0.3s ease, color 0.3s ease !important; }`;
  69. GM_addStyle(fullCSS);
  70.  
  71. // 2. Core function to apply a theme class to the body
  72. function updateBodyClass(themeKey) {
  73. for (const key in themes) {
  74. document.body.classList.remove(themes[key].className);
  75. }
  76. if (themes[themeKey]) {
  77. document.body.classList.add(themes[themeKey].className);
  78. }
  79. }
  80.  
  81. // 3. Main function to determine and apply the correct theme based on settings
  82. function applyActiveTheme() {
  83. const settings = {
  84. autoSwitchEnabled: GM_getValue('autoSwitchEnabled', true),
  85. darkTime: GM_getValue('darkTime', '19:00'),
  86. lightTime: GM_getValue('lightTime', '07:00'),
  87. lastDarkTheme: GM_getValue('lastDarkTheme', 'dracula'),
  88. lastLightTheme: GM_getValue('lastLightTheme', 'warm'),
  89. selectedTheme: GM_getValue('selectedTheme', 'default')
  90. };
  91.  
  92. let themeToApplyKey = settings.selectedTheme;
  93.  
  94. if (settings.autoSwitchEnabled) {
  95. const now = new Date();
  96. const currentTime = now.getHours() * 60 + now.getMinutes();
  97. const [darkHour, darkMinute] = settings.darkTime.split(':').map(Number);
  98. const darkTimeTotalMinutes = darkHour * 60 + darkMinute;
  99. const [lightHour, lightMinute] = settings.lightTime.split(':').map(Number);
  100. const lightTimeTotalMinutes = lightHour * 60 + lightMinute;
  101.  
  102. if (darkTimeTotalMinutes > lightTimeTotalMinutes) { // Normal day/night
  103. if (currentTime >= darkTimeTotalMinutes || currentTime < lightTimeTotalMinutes) {
  104. themeToApplyKey = settings.lastDarkTheme;
  105. } else {
  106. themeToApplyKey = settings.lastLightTheme;
  107. }
  108. } else { // Inverted
  109. if (currentTime >= darkTimeTotalMinutes && currentTime < lightTimeTotalMinutes) {
  110. themeToApplyKey = settings.lastDarkTheme;
  111. } else {
  112. themeToApplyKey = settings.lastLightTheme;
  113. }
  114. }
  115. }
  116. updateBodyClass(themeToApplyKey);
  117. GM_setValue('selectedTheme', themeToApplyKey);
  118. }
  119.  
  120. // 4. Function to rebuild the menu commands. Necessary for instant checkmark updates.
  121. function registerMenuCommands() {
  122. // Clear existing commands
  123. menuCommands.forEach(cmdId => GM_unregisterMenuCommand(cmdId));
  124. menuCommands = [];
  125.  
  126. const settings = {
  127. autoSwitchEnabled: GM_getValue('autoSwitchEnabled', true),
  128. darkTime: GM_getValue('darkTime', '19:00'),
  129. lightTime: GM_getValue('lightTime', '07:00'),
  130. selectedTheme: GM_getValue('selectedTheme', 'default')
  131. };
  132.  
  133. const addCmd = (name, func) => menuCommands.push(GM_registerMenuCommand(name, func));
  134. const isActive = (key) => !settings.autoSwitchEnabled && settings.selectedTheme === key;
  135.  
  136. // Theme selection
  137. for (const themeKey in themes) {
  138. const theme = themes[themeKey];
  139. addCmd(`${isActive(themeKey) ? '✅ ' : ''}${theme.displayName}`, () => manualThemeChange(themeKey));
  140. }
  141.  
  142. // Restore Default
  143. addCmd(`${isActive('default') ? '✅ ' : ''}Restore Default`, () => manualThemeChange('default'));
  144.  
  145. // Automatic switching toggle
  146. addCmd(`Auto Day/Night: ${settings.autoSwitchEnabled ? '✅ On' : '❌ Off'}`, toggleAutoSwitch);
  147.  
  148. // Set custom times
  149. addCmd(`Set Times (Dark: ${settings.darkTime}, Light: ${settings.lightTime})`, setTimes);
  150. }
  151.  
  152. // 5. Handler functions for menu actions
  153. function manualThemeChange(themeKey) {
  154. if (themes[themeKey]) {
  155. if (themes[themeKey].isDark) {
  156. GM_setValue('lastDarkTheme', themeKey);
  157. } else {
  158. GM_setValue('lastLightTheme', themeKey);
  159. }
  160. }
  161. GM_setValue('selectedTheme', themeKey);
  162. GM_setValue('autoSwitchEnabled', false);
  163. updateBodyClass(themeKey);
  164. registerMenuCommands(); // Rebuild menu to update checkmarks
  165. }
  166.  
  167.  
  168.  
  169. function toggleAutoSwitch() {
  170. const currentVal = GM_getValue('autoSwitchEnabled', true);
  171. GM_setValue('autoSwitchEnabled', !currentVal);
  172. applyActiveTheme(); // Immediately apply the correct theme for the new mode
  173. registerMenuCommands();
  174. }
  175.  
  176. function setTimes() {
  177. const oldDark = GM_getValue('darkTime', '19:00');
  178. const newDarkTime = prompt('Enter dark theme start time (HH:MM, 24-hour format):', oldDark);
  179. if (newDarkTime && /^\d{2}:\d{2}$/.test(newDarkTime)) {
  180. GM_setValue('darkTime', newDarkTime);
  181. }
  182.  
  183. const oldLight = GM_getValue('lightTime', '07:00');
  184. const newLightTime = prompt('Enter light theme start time (HH:MM, 24-hour format):', oldLight);
  185. if (newLightTime && /^\d{2}:\d{2}$/.test(newLightTime)) {
  186. GM_setValue('lightTime', newLightTime);
  187. }
  188.  
  189. applyActiveTheme(); // Re-evaluate theme with new times
  190. registerMenuCommands(); // Rebuild menu to show new times
  191. }
  192.  
  193.  
  194. // --- Initial Execution ---
  195. applyActiveTheme();
  196. registerMenuCommands();
  197. console.log(`AI Studio Theme Switcher: Initialized with corrected low-contrast dark themes.`);
  198. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址