Firefox/ChatGPT: Fix Disabled Chat Box

Re-enabled the ChatGPT chatbox under Firefox

// ==UserScript==
// @name         Firefox/ChatGPT: Fix Disabled Chat Box
// @namespace    https://gf.qytechs.cn/en/users/1337417-mevanlc
// @version      0.3
// @description  Re-enabled the ChatGPT chatbox under Firefox
// @author       https://gf.qytechs.cn/en/users/1337417-mevanlc
// @match        https://chatgpt.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function userscriptMain() {
        let parent = getChatBoxParent();
        if (!parent) {
            ulog(`chatbox parent not found, setting poll timer`);
            setTimeout(userscriptMain, 150);
        } else {
            onGetChatBoxParent(parent);
        }
    }

    function getChatBoxParent() {
        const child = document.querySelector("#prompt-textarea");
        return child ? child.parentElement : null;
    }

    function onGetChatBoxParent(parent) {
        parent.classList.remove('default-browser');
        parent.classList.add('firefox');
        ulog('Chatbox enabled by changing classes.');
    }


    if (document.readyState !== 'loading') {
        ulog('document is already ready, calling userscript()');
        userscriptMain();
    } else {
        ulog('will run userscript() on DOMContentLoaded');
        document.addEventListener('DOMContentLoaded', userscriptMain);
    }

    function ulog(...args) {
        typeof args[0] === 'string' ?
          console.log(`${GM.info.script.name}: ${args[0]}`, ...args.slice(1))
          : console.log(GM.info.script.name, ...args);
    }

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址