Gemini force 2.0 Flash

Auto change 1.5 to 2.0 (Google may change it later)

当前为 2024-12-15 提交的版本,查看 最新版本

// ==UserScript==
// @name        Gemini force 2.0 Flash
// @namespace   Violentmonkey Scripts
// @description Auto change 1.5 to 2.0 (Google may change it later)
// @match       *://gemini.google.com/*
// @grant       none
// @version     1.0
// @license MIT
// @author      Artin
// @description 12/15/2024, 9:35:58 PM
// ==/UserScript==

function checkAndClick() {
    // Select the span element
    const spanElement = document.querySelector("#app-root > main > side-navigation-v2 > bard-sidenav-container > bard-sidenav-content > bard-mode-switcher > button > span.mdc-button__label > div.current-mode-title.ng-star-inserted > span");

    // Check if the text content is "1.5 flash"
    if (spanElement && spanElement.textContent.trim() === '1.5 Flash') {
        // Click the first button
        const firstButton = document.querySelector('#app-root > main > side-navigation-v2 > bard-sidenav-container > bard-sidenav-content > bard-mode-switcher > button');
        if (firstButton) {
            firstButton.click();

            // Wait for the menu to appear and then click the third button
            setTimeout(() => {
                const thirdButton = document.querySelector('#mat-menu-panel-3 > div > button:nth-child(3)');
                if (thirdButton) {
                    thirdButton.click();
                }
            }, 500); // Wait 500ms for the menu to appear
        }
    }
}

// Run the check initially
checkAndClick();

// Set up an observer to monitor changes
const targetNode = document.querySelector('#app-root');
if (targetNode) {
    const observer = new MutationObserver(() => {
        checkAndClick();
    });

    observer.observe(targetNode, {
        childList: true,
        subtree: true,
        characterData: true
    });
}