mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
fix: auto continue
This commit is contained in:
parent
94d27f0d24
commit
c499ba37bd
30
scripts/chat.js
vendored
30
scripts/chat.js
vendored
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @name chat.js
|
* @name chat.js
|
||||||
* @version 0.1.2
|
* @version 0.1.3
|
||||||
* @url https://github.com/lencx/ChatGPT/tree/main/scripts/chat.js
|
* @url https://github.com/lencx/ChatGPT/tree/main/scripts/chat.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -151,10 +151,10 @@ function chatInit() {
|
|||||||
|
|
||||||
function autoContinue() {
|
function autoContinue() {
|
||||||
// Create an instance of the observer
|
// Create an instance of the observer
|
||||||
const observer = new MutationObserver((mutationsList, observer) => {
|
const observer = new MutationObserver((mutationsList) => {
|
||||||
for (let mutation of mutationsList) {
|
for (let mutation of mutationsList) {
|
||||||
if (mutation.type === 'childList') {
|
if (mutation.type === 'childList') {
|
||||||
const btn = [...mutation.target.querySelectorAll('button.btn')].find((btn) =>
|
const btn = Array.from(mutation.target.querySelectorAll('button.btn')).find((btn) =>
|
||||||
btn.innerText.includes('Continue generating'),
|
btn.innerText.includes('Continue generating'),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -170,19 +170,21 @@ function chatInit() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start observing the dom change of the form
|
// Wait until the form exists
|
||||||
observer.observe(document.forms[0], {
|
const interval = setInterval(() => {
|
||||||
attributes: false,
|
if (document.forms[0]) {
|
||||||
childList: true,
|
// Start observing the dom change of the form
|
||||||
subtree: true,
|
observer.observe(document.forms[0], {
|
||||||
});
|
attributes: false,
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
});
|
||||||
|
clearInterval(interval); // Stop checking when the form exists
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
document.addEventListener('DOMContentLoaded', chatInit);
|
||||||
chatInit();
|
|
||||||
} else {
|
|
||||||
document.addEventListener('DOMContentLoaded', chatInit);
|
|
||||||
}
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"scripts": [
|
"scripts": [
|
||||||
{
|
{
|
||||||
"name": "chat.js",
|
"name": "chat.js",
|
||||||
"version": "0.1.2"
|
"version": "0.1.3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cmd.js",
|
"name": "cmd.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user