// ==UserScript== // @name ChatGPT Disable Autofocus // @description Completely block all programmatic autofocus on chatgpt.com // @match https://chatgpt.com/* // @run-at document-start // @version 0.0.1.20250512172001 // @namespace https://greasyfork.org/users/1435046 // @downloadURL none // ==/UserScript== (function() { 'use strict'; function removeAutofocus(el) { if (el.hasAttribute('autofocus')) { el.removeAttribute('autofocus'); } } // 1. Observe new elements and remove any autofocus attributes immediately const observer = new MutationObserver(mutations => { for (const { addedNodes } of mutations) { for (const node of addedNodes) { if (node.nodeType === 1) { removeAutofocus(node); node.querySelectorAll('[autofocus]').forEach(removeAutofocus); } } } }); observer.observe(document.documentElement, { childList: true, subtree: true }); // 2. Once initial DOM is ready, strip any remaining autofocus attributes document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('[autofocus]').forEach(removeAutofocus); observer.disconnect(); }, { once: true }); })();