Firefox: Fix ChatGPT Chatbox

Re-enabled the ChatGPT chatbox under Firefox

目前为 2024-09-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         Firefox: Fix ChatGPT Chatbox
// @namespace    https://gf.qytechs.cn/en/users/1337417-mevanlc
// @version      0.2
// @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 _log(msg) { console.log(`Enable ChatGPT Chatbox: ${msg}`); }

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

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

    function userscript() {
        let parent = _getParent();
        if (!parent) {
            _log(`chatbox parent not found, setting poll timer`);
            setTimeout(userscript, 150);
        } else {
            _gotParent(parent);
        }
    }

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

})();

QingJ © 2025

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