Last active
July 8, 2023 10:23
-
-
Save n-miyo/da556a60c43e6301356fe9f2cd56f841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Suppresses unwanted sending with Enter key | |
// @namespace http://tempus.org | |
// @version 0.3 | |
// @description Suppresses unwanted sending with Enter key on ChatGPT. | |
// @author n-miyo | |
// @match https://chat.openai.com | |
// @match https://chat.openai.com/?model* | |
// @match https://chat.openai.com/c/* | |
// @grant none | |
// @downloadURL https://gist.githubusercontent.com/n-miyo/da556a60c43e6301356fe9f2cd56f841/raw | |
// @updateURL https://gist.githubusercontent.com/n-miyo/da556a60c43e6301356fe9f2cd56f841/raw | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const HOLD_MILLSEC = 100; | |
const VERMILLON = 'rgb(253, 60, 47, 0.3)'; | |
function waitTextAreaPreparation() { | |
let textArea = document.getElementById('prompt-textarea'); | |
if (textArea === null) { | |
setTimeout(waitTextAreaPreparation, HOLD_MILLSEC); | |
return; | |
} | |
let container = textArea.closest('div') | |
if (container !== null) { | |
container.style.borderColor=VERMILLON; | |
} | |
textArea.addEventListener('keydown', (e) => { | |
if (e.code == "Enter" && !e.metaKey) { | |
e.stopPropagation(); | |
} | |
}, { capture: true }); | |
} | |
waitTextAreaPreparation(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment