Gemini Enter Change

Zamienia Enter i Shift+Enter w Gemini. Teraz Enter odpowiada za nową linie a shift enter za wysłanie. Jeśli będą jakieś problemy to poproszę poprostu abyście wysłali mi kilka rzeczy jakie macie na stronie czatu gemini a to naprawie.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

// ==UserScript==
// @name         Gemini Enter Change
// @version      1.0
// @description  Zamienia Enter i Shift+Enter w Gemini. Teraz Enter odpowiada za nową linie a shift enter za wysłanie. Jeśli będą jakieś problemy to poproszę poprostu abyście wysłali mi kilka rzeczy jakie macie na stronie czatu gemini a to naprawie.
// @author       SkyWhy
// @match        https://gemini.google.com/*
// @namespace https://greasyfork.org/users/1616478
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('keydown', function(event) {
        const target = event.target;
        if (!target) return;

        const isEditableDiv = target.closest('div.ql-editor[contenteditable="true"], div[role="textbox"][contenteditable="true"]');
        const isTextareaMatch = target.matches && target.matches('textarea[enterkeyhint="send"], textarea[aria-label*="Prompt"], textarea[aria-label*="Wiadomość"], textarea[placeholder*="Message Gemini"], textarea[placeholder*="Zapytaj Gemini"]');

        if (!isEditableDiv && !isTextareaMatch) return;

        const el = isEditableDiv || target;

        if (event.key === 'Enter') {
            if (event.shiftKey) {

                event.preventDefault();
                event.stopImmediatePropagation();

                const sendButton = document.querySelector('button[aria-label*="Send"], button[aria-label*="Wyślij"], button[data-test-id="send-button"]');
                if (sendButton && !sendButton.disabled) {
                    sendButton.click();
                } else {
                    const form = el.closest('form');
                    if (form) {
                        if (typeof form.requestSubmit === 'function') { form.requestSubmit(); } else { form.submit(); }
                    }
                }
            } else {
                event.preventDefault();
                event.stopImmediatePropagation();

                if (isEditableDiv) {
                    el.focus();
                    let success = document.execCommand('insertParagraph', false, null);
                    if (!success) {
                        document.execCommand('insertHTML', false, '<br>');
                    }
                    el.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
                } else if (isTextareaMatch) {
                    const start = el.selectionStart;
                    const end = el.selectionEnd;
                    el.value = el.value.substring(0, start) + "\n" + el.value.substring(end);
                    el.selectionStart = el.selectionEnd = start + 1;
                    el.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
                }
            }
        }
    }, true); /// <- Pod żadnym pozorem tego nie ruszać, grozi zawaleniem, reszte możecie się bawić.
})();