ChatGPT Monitor

Monitor whether the answer is complete, if not, automatically send a continue command.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         ChatGPT Monitor
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Monitor whether the answer is complete, if not, automatically send a continue command.
// @author       CyberSexy
// @match        https://chat.openai.com/*
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @run-at       document-end
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('loadMonitor', function() {
        const element = document.querySelector('.text-2xl');
        console.log("MyScript1: " + element);
        // 这个地方用来判断是否正在返回数据,利用text-2xl的这个类。这个类只在获取数据时候出现。
        if (!element) {
            // Get the last element with class name "markdown"
            var latest = document.getElementsByClassName('markdown')[document.getElementsByClassName('markdown').length - 1];

            // Store the latest element's content in a variable
            var dataZ = latest.innerHTML;
            //console.log("MyScriptFull: " + dataZ);
            // Remove <p> tags from the content
            dataZ = dataZ.replace(/<\/?p>/g, '');
            // Check if the content ends with ".", ";" or "。"or"</pre>"
            // 你根据情况判断是否还要加,例如有的时候是问号。
            var endsWithPunctuation = /[.;!!。]$/.test(dataZ) || dataZ.endsWith("</pre>");

            console.log("MyScript2: " + endsWithPunctuation);

            //Extract the last 20 characters
            var last20 = dataZ.substr(dataZ.length - 20, 20);
            console.log("MyScript3: " + last20);

            if (!endsWithPunctuation) {
                var input=document.querySelector('textarea');
                input.value="继续";
                input.dispatchEvent(new Event("input", { bubbles: true }));
                input.form.dispatchEvent(new Event("submit", { bubbles: true }));
            };
        }
    }
                           )

    setInterval(function() {
        window.dispatchEvent(new Event('loadMonitor'));
    }, 5000);

})();