OpenAI Playground (ChatGPT) - Continue Button

press the [Continue] button instead of 'Add message > continue > Ctrl+Enter', configure panel optionally saves 'Temperature', 'Maximum Length' and 'Instructions'

Verze ze dne 26. 06. 2023. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         OpenAI Playground (ChatGPT) - Continue Button
// @namespace    https://greasyfork.org/en/users/10118-drhouse
// @version      2.1
// @description  press the [Continue] button instead of 'Add message > continue > Ctrl+Enter', configure panel optionally saves 'Temperature', 'Maximum Length' and 'Instructions'
// @include      https://platform.openai.com/playground?mode*
// @match        https://platform.openai.com/playground?mode*
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @require      https://greasyfork.org/scripts/439099-monkeyconfig-modern-reloaded/code/MonkeyConfig%20Modern%20Reloaded.js?version=1012538
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @author       drhouse
// @license      CC-BY-NC-SA-4.0
// @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
// ==/UserScript==
/* global jQuery, $ */
this.$ = this.jQuery = jQuery.noConflict(true);
(function($){

    setTimeout(function(){
        var cfg = new MonkeyConfig({
            title: 'Configure',
            menuCommand: true,
            params: {
                'Automatic Temperature': {
                    type: 'checkbox',
                    default: true
                },
                'Temperature': {
                    type: 'number',
                    default: '1'
                },
                'Automatic Maximum Length': {
                    type: 'checkbox',
                    default: true
                },
                'Maximum Length': {
                    type: 'number',
                    default: '2048'
                },
                'Automatic Instructions': {
                    type: 'checkbox',
                    default: true
                },
                chatGPT_instructions: {
                    type: 'text',
                    default: ''
                },

            },
            // onSave: setOptions
        })

        var path = "#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-footer > span > button.btn.btn-sm.btn-minimal.btn-neutral"
        $('<button id="continue" tabindex="0" class="btn btn-sm btn-filled btn-primary" type="button" data-testid="pg-submit-btn" aria-haspopup="true" aria-expanded="false"><span class="btn-label-wrap"><span class="btn-label-inner">Continue&zwj;</span></span></button>').insertAfter(path)

        var e = jQuery.Event("keypress");
        e.which = 9; 
        e.keyCode = 9;

        if (cfg.get('Automatic Temperature')) {
            $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-right > div.pg-right-content > div > div > div:nth-child(3) > div > div.css-1povu0j > input").val(Number(cfg.get('Temperature')))
            $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-right > div.pg-right-content > div > div > div:nth-child(3) > div > div.css-1povu0j > input").focus().trigger(e);    
        }
        
        if (cfg.get('Automatic Maximum Length')) {
            $("body > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > input:nth-child(2)").val(Number(cfg.get('Maximum Length')))
            $("body > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > input:nth-child(2)").focus().trigger(e);
        }

        // chat-pg-instructions
        $('#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div:nth-child(1) > div > div.text-input-header-wrapper.overflow-wrapper.text-input > textarea').focus()

        if (cfg.get('Automatic Instructions')) {
            $('#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div:nth-child(1) > div > div.text-input-header-wrapper.overflow-wrapper.text-input > textarea').text(cfg.get('chatGPT_instructions'))
        }

        $("button[id='continue']").click(function(){
            $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-panel-wrapper > div > div > div.chat-pg-message.add-message")[0].click()   
            setTimeout(function(){
                $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-panel-wrapper > div > div > div:nth-child(3) > div.text-input-with-focus > textarea").text('continue')
            }, 500); 
            setTimeout(function(){
                $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-footer > span > button:nth-child(1)")[0].click()
            }, 1000); 
        });


    }, 1000);
})(jQuery);