1
0
mirror of https://github.com/lencx/ChatGPT.git synced 2024-10-01 01:06:13 -04:00

feat: auto continue

This commit is contained in:
lencx 2023-07-05 18:28:16 +08:00
parent beafad8174
commit 94d27f0d24
2 changed files with 32 additions and 2 deletions

32
scripts/chat.js vendored
View File

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

View File

@ -6,7 +6,7 @@
"scripts": [
{
"name": "chat.js",
"version": "0.1.1"
"version": "0.1.2"
},
{
"name": "cmd.js",