ChatGPT Monitor

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

目前为 2023-01-29 提交的版本。查看 最新版本

// ==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);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址