Fanly ChatGPT

OpenAI ChatGPT自动点击"Continue generating"按钮,实现自动继续生成,并且添加“100字总结”按钮,对生成的内容实现快速总结,帮助编辑人员提高效率。

当前为 2023-08-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Fanly ChatGPT
// @description  OpenAI ChatGPT自动点击"Continue generating"按钮,实现自动继续生成,并且添加“100字总结”按钮,对生成的内容实现快速总结,帮助编辑人员提高效率。
// @namespace    http://tampermonkey.net/
// @version      0.1
// @author       Fanly
// @match        https://chat.openai.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=openai.com
// @grant        none
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    console.log('ChatGPT Auto Summarize and Continue')

    var auto_summarize_and_continue = function(){
        var buttons = document.querySelectorAll('button.btn-neutral');
        for (var i=buttons.length-1; i>=0; i--){
            if (buttons[i].innerText =='Continue generating') { // If it is the Continue generating button
                setTimeout((function(i){
                    return function(){
                        buttons[i].click();
                    }
                })(i),1000);
                break;
            }
            else if (buttons[i].innerText =='Regenerate') { // If it is the Regenerate button

                // Check if the 100字总结 button already exists
                var summaryButtonExists = false;
                for (var j=0; j<buttons.length; j++){
                    if (buttons[j].innerText =='100字总结') {
                        summaryButtonExists = true;
                        break;
                    }
                }

                // If it does not exist, create and add it
                if (!summaryButtonExists) {
                    var button = document.createElement("button");
                    button.className = "btn relative btn-neutral sumup";
                    button.innerText='100字总结';

                    button.onclick = function() {
                        var textarea = document.getElementById('prompt-textarea');

                        // Simulate user input instead of directly changing the value
                        var inputEvent = new InputEvent('input', {
                            bubbles: true,
                            cancelable: true,
                        });
                        textarea.value = '100字总结';
                        textarea.dispatchEvent(inputEvent);
                        textarea.focus(); // Focus the cursor in the textarea
                        var event = new KeyboardEvent('keydown',{'key':'Enter'});
                        textarea.dispatchEvent(event);
                    };

                    buttons[i].after(button);
                }
                break;
            }
        }
    }

    // Call the function every second
    setInterval(auto_summarize_and_continue,1000);
})();