Skip to content

Instantly share code, notes, and snippets.

@rf5860
Last active December 28, 2023 10:40
Show Gist options
  • Save rf5860/7d316de285d8516a84a3c0ad278be54e to your computer and use it in GitHub Desktop.
Save rf5860/7d316de285d8516a84a3c0ad278be54e to your computer and use it in GitHub Desktop.
BetterGPT Undraggable Inputs
// ==UserScript==
// @name BetterGPT Undraggable Inputs
// @description Fixes input behavior on BetterGPT
// @version 0.4
// @namespace https://bettergpt.chat/
// @author rjf89
// @updateURL https://gist.githubusercontent.com/rf5860/ebd6185356900255e7f50241fff4811e/raw/e17b04152cf26ea652986051d35be264bd53d040/VoiceLines%2520to%2520Clipboard.js
// @downloadURL https://gist.githubusercontent.com/rf5860/ebd6185356900255e7f50241fff4811e/raw/e17b04152cf26ea652986051d35be264bd53d040/VoiceLines%2520to%2520Clipboard.js
// @match https://bettergpt.chat/
// @grant none
// ==/UserScript==
(function() {
'use strict';
var events = ['mousedown', 'mouseup', 'click'];
var as = [...document.querySelectorAll('a:has(input[class^="focus"])')];
events.forEach(e => as.forEach(i => i.removeEventListener(e, e => e.stopPropagation(), true)));
// Create a MutationObserver instance to monitor DOM changes
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach(function(node) {
if (node.nodeName === 'A') {
var inputs = node.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
inputs[i].addEventListener('mousedown', function(event) {
event.stopPropagation();
}, true);
inputs[i].addEventListener('mouseup', function(event) {
event.stopPropagation();
}, true);
inputs[i].addEventListener('click', function(event) {
event.stopPropagation();
}, true);
}
}
});
}
});
});
// Start observing the document with the configured parameters
observer.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment