ChatGPT Monitor

Monitor ChatGPT's response on chat.openai.com/chat and add "continue" if no period is detected

目前為 2023-01-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         ChatGPT Monitor
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Monitor ChatGPT's response on chat.openai.com/chat and add "continue" if no period is detected
// @author       Your Name
// @match        https://chat.openai.com/chat
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    var targetNode = document.getElementById("__next");
    var config = { childList: true };
    var callback = function(mutationsList) {
        for(var mutation of mutationsList) {
            if (mutation.addedNodes.length > 0) {
                var lastNode = mutation.addedNodes[mutation.addedNodes.length - 1];
                if (lastNode.classList.contains("text-md") && lastNode.classList.contains("text-white") && lastNode.classList.contains("bg-blue-500") && lastNode.classList.contains("p-2")) {
                    var text = lastNode.innerText;
                    if (text.endsWith(".") || text.endsWith("。")) {
                        console.log("Period detected, no need to add 'continue'");
                    } else {
                        console.log("No period detected, adding 'continue'");
                        var inputNode = document.querySelector("#__next > div.overflow-hidden.w-full.h-full.relative > div.flex.h-full.flex-1.flex-col.md\\:pl-[260px] > main > div.flex-1.overflow-hidden > div > div > div > div:nth-child(4) > div > div.relative.flex.w-[calc(100%-50px)].flex-col.gap-1.md\\:gap-3.lg\\:w-[calc(100%-115px)] > div.flex.flex-grow.flex-col.gap-3 > div > div");
                        inputNode.value = "continue";
                        inputNode.dispatchEvent(new Event("input", { bubbles: true }));
                        inputNode.form.dispatchEvent(new Event("submit", { bubbles: true }));
                    }
                }
            }
        }
    };
    var observer = new MutationObserver(callback);
    observer.observe(targetNode, config);
})();