Save & Submit keyboard shortcut for ChatGPT

Press Alt + Enter to auto-click the Save & Submit button for Superpower ChatGPT and OpenAI

2024-05-09 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Save & Submit keyboard shortcut for ChatGPT
// @description  Press Alt + Enter to auto-click the Save & Submit button for Superpower ChatGPT and OpenAI
// @author       NWP
// @namespace    https://greatest.deepsurf.us/users/877912
// @version      0.5
// @license      MIT
// @match        https://chat.openai.com/*
// @match        https://chatgpt.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.addEventListener('keydown', function(event) {
        // Check if Alt key is pressed along with Enter key
        if (event.altKey && event.keyCode == 13) {
            event.preventDefault();
            const save_submit_openAIButton = document.querySelector("div > button.btn.relative.btn-primary.mr-2");
            const save_submit_superpowerChatGPTButton = document.querySelector("div > button.btn.flex.justify-center.gap-2.btn-primary.mr-2");
            (save_submit_openAIButton || save_submit_superpowerChatGPTButton).click();
            event.stopPropagation();
        }
    }, true);
})();


/*

TODO: to make it easy to find for which operating mode the save_and_submit_button has become obsolete
detect if Superpower ChatGPT is enabled for Chrome and Firefox.

This only works for Chrome within a userscript:

const extensionId = 'amhmeenmapldpjdedekalnfifgnpfnkc';
const resourcePath = 'icons/info.png'; // This works
//const resourcePath = 'manifest.json'; // This doesn't work due to restrictions
const imgUrl = `chrome-extension://${extensionId}/${resourcePath}`;

fetch(imgUrl)
    .then(response => {
        if(response.ok) console.log('Extension installed:', true);
        else throw new Error('Resource not accessible');
    })
    .catch(error => console.log('Extension installed:', false));

Since Firefox doesn't have a similar method that I know of, it's better to
check for an element that has been injected by Superpower ChatGPT (Auto Sync ON/ OFF)
for both Chrome and Firefox.

*/