From 94d27f0d24989ea254d1e02deedd48942da7650f Mon Sep 17 00:00:00 2001 From: lencx Date: Wed, 5 Jul 2023 18:28:16 +0800 Subject: [PATCH] feat: auto continue --- scripts/chat.js | 32 +++++++++++++++++++++++++++++++- scripts/manifest.json | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/scripts/chat.js b/scripts/chat.js index 9e1643d..20cbadf 100644 --- a/scripts/chat.js +++ b/scripts/chat.js @@ -1,6 +1,6 @@ /** * @name chat.js - * @version 0.1.1 + * @version 0.1.2 * @url https://github.com/lencx/ChatGPT/tree/main/scripts/chat.js */ @@ -26,6 +26,7 @@ function chatInit() { document.addEventListener('visibilitychange', focusOnInput); gpt4Mobile(); + autoContinue(); } function observeMutations(mutationsList) { @@ -148,6 +149,35 @@ function chatInit() { }; } + function autoContinue() { + // Create an instance of the observer + const observer = new MutationObserver((mutationsList, observer) => { + for (let mutation of mutationsList) { + if (mutation.type === 'childList') { + const btn = [...mutation.target.querySelectorAll('button.btn')].find((btn) => + btn.innerText.includes('Continue generating'), + ); + + if (btn) { + console.log("Found the button of 'Continue generating'"); + setTimeout(() => { + console.log('Clicked it to continue generating after 1 second'); + btn.click(); + }, 1000); + return; + } + } + } + }); + + // Start observing the dom change of the form + observer.observe(document.forms[0], { + attributes: false, + childList: true, + subtree: true, + }); + } + init(); } diff --git a/scripts/manifest.json b/scripts/manifest.json index 15fe16b..a90313d 100644 --- a/scripts/manifest.json +++ b/scripts/manifest.json @@ -6,7 +6,7 @@ "scripts": [ { "name": "chat.js", - "version": "0.1.1" + "version": "0.1.2" }, { "name": "cmd.js",