Skip to content

Instantly share code, notes, and snippets.

@n-miyo
Last active July 8, 2023 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n-miyo/da556a60c43e6301356fe9f2cd56f841 to your computer and use it in GitHub Desktop.
Save n-miyo/da556a60c43e6301356fe9f2cd56f841 to your computer and use it in GitHub Desktop.
// ==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