Created
January 16, 2026 18:53
-
-
Save typester/40ac7d5cb7ad77f8a2b29aaecf413dc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Gemini Model Switcher (Cmd+Ctrl) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.2 | |
| // @description Switch Gemini models using Cmd+Ctrl+1 (Fast), Cmd+Ctrl+2 (Thinking), Cmd+Ctrl+3 (Pro) | |
| // @author You | |
| // @match https://gemini.google.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const CONFIG = { | |
| triggerSelector: 'div[data-test-id="bard-mode-menu-button"]', | |
| keyMap: { | |
| 'Digit1': 'button[data-test-id="bard-mode-option-fast"]', // Cmd + Ctrl + 1 -> Fast | |
| 'Digit2': 'button[data-test-id="bard-mode-option-thinking"]', // Cmd + Ctrl + 2 -> Thinking | |
| 'Digit3': 'button[data-test-id="bard-mode-option-pro"]' // Cmd + Ctrl + 3 -> Pro | |
| }, | |
| pollingIntervalMs: 50, | |
| maxRetries: 20 | |
| }; | |
| function waitForElement(selector, callback) { | |
| let retries = 0; | |
| const interval = setInterval(() => { | |
| const element = document.querySelector(selector); | |
| if (element) { | |
| clearInterval(interval); | |
| callback(element); | |
| } else { | |
| retries++; | |
| if (retries >= CONFIG.maxRetries) { | |
| clearInterval(interval); | |
| // console.warn(`[GeminiSwitcher] Timeout waiting for selector: ${selector}`); | |
| } | |
| } | |
| }, CONFIG.pollingIntervalMs); | |
| } | |
| function triggerClick(element) { | |
| if (!element) return; | |
| element.click(); | |
| } | |
| document.addEventListener('keydown', (e) => { | |
| if (!e.metaKey || !e.ctrlKey) return; | |
| const targetModelSelector = CONFIG.keyMap[e.code]; | |
| if (targetModelSelector) { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| const triggerBtn = document.querySelector(CONFIG.triggerSelector); | |
| if (!triggerBtn) { | |
| console.error('[GeminiSwitcher] Menu trigger button not found.'); | |
| return; | |
| } | |
| triggerClick(triggerBtn); | |
| waitForElement(targetModelSelector, (modelBtn) => { | |
| console.log(`[GeminiSwitcher] Switching model via Cmd+Ctrl+${e.key}...`); | |
| triggerClick(modelBtn); | |
| }); | |
| } | |
| }); | |
| console.log('[GeminiSwitcher] Loaded. Use Cmd+Ctrl+1/2/3 to switch models.'); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment