Auto Continue Generating [ChatGPT] (only the necessary code)

Auto Continue generating in ChatGPT

目前为 2024-02-04 提交的版本。查看 最新版本

// ==UserScript==
// @name           Auto Continue Generating [ChatGPT] (only the necessary code)
// @namespace      Auto Continue Generating [ChatGPT] (only the necessary code)
// @version        1.0
// @author         Nameniok
// @description    Auto Continue generating in ChatGPT
// @run-at         document-idle
// @match          https://chat.openai.com/*
// @license        MIT
// ==/UserScript==

let Observer;
(async () => {
    Observer = new MutationObserver(mutations =>
        mutations.forEach(mutation => {
            if (mutation.attributeName == 'style' && mutation.target.style.opacity == '1') {
                document.querySelectorAll('button').forEach(button => {
                    if (button.textContent.includes('Continue generating')) {
                        button.click();
                    }
                });
            }
        })
    );
    continueObserver.observe(document.querySelector('main'), { attributes: true, subtree: true });
})();