Greasy Fork is available in English.

Gemini Auto Model Selector

Automatically select default model (thinking). You can choose default model in code

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Gemini Auto Model Selector
// @namespace    http://greasyfork.org/
// @version      1.4
// @description  Automatically select default model (thinking). You can choose default model in code
// @author       Bui Quoc Dung
// @match        https://gemini.google.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const TARGET_KEYWORDS = ["Thinking", "Tư duy"];
    let isSwitching = false;
    let lastUrl = location.href;

    function checkAndSwitchModel() {
        if (isSwitching) return;

        const pickerContainer = document.querySelector('div[aria-label="Open mode picker"], div[aria-label="Mở bộ chọn chế độ"]');
        const pickerBtn = pickerContainer ? pickerContainer.querySelector('button') : null;

        if (!pickerBtn) {
            setTimeout(checkAndSwitchModel, 500);
            return;
        }

        const currentLabel = pickerBtn.innerText || "";
        if (TARGET_KEYWORDS.some(keyword => currentLabel.includes(keyword))) {
            return;
        }

        isSwitching = true;

        pickerBtn.click();

        setTimeout(() => {
            const menuItems = document.querySelectorAll('.mat-mdc-menu-item-text, div[role="menu"] button');
            let found = false;

            for (let item of menuItems) {
                const itemText = item.innerText;
                if (TARGET_KEYWORDS.some(keyword => itemText.includes(keyword))) {
                    const clickableItem = item.closest('button') || item;
                    clickableItem.click();
                    found = true;
                    break;
                }
            }

            if (!found) {
                document.body.click();
            }
            isSwitching = false;
        }, 500);
    }

    checkAndSwitchModel();


    setInterval(() => {
        if (location.href !== lastUrl) {
            lastUrl = location.href;
            setTimeout(checkAndSwitchModel, 1000);
        }
    }, 2000);

})();