Greasy Fork is available in English.

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 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

Advertisement:

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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ć.
})();