correctly handling the presence of the audio button. fixes #188

This commit is contained in:
Mic 2024-11-29 21:03:41 +01:00
parent 3fda6115c0
commit 9d8e5e705a

View file

@ -37,9 +37,6 @@ async function chatgpt_sendMsg(msg, method ='') { // return -1 send button
textArea = document.querySelector('form textarea'); textArea = document.querySelector('form textarea');
old_textArea = true; old_textArea = true;
} }
let sendButton = document.querySelector('[data-testid="send-button"]') // pre-GPT-4o
|| document.querySelector('path[d*="M15.1918 8.90615C15.6381"]')?.parentNode.parentNode // from sept-2024;
|| document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode; // post-GPT-4o;
//check if the textarea has been found //check if the textarea has been found
if(!textArea) { if(!textArea) {
console.error("[ThunderAI] Textarea not found!"); console.error("[ThunderAI] Textarea not found!");
@ -52,6 +49,11 @@ async function chatgpt_sendMsg(msg, method ='') { // return -1 send button
textArea.innerText = msg; textArea.innerText = msg;
textArea.dispatchEvent(new Event('input', { bubbles: true })); textArea.dispatchEvent(new Event('input', { bubbles: true }));
} }
//wait for the button to change from the audio button to the send button (from nov-2024)
await new Promise(resolve => setTimeout(resolve, 1000));
let sendButton = document.querySelector('[data-testid="send-button"]') // pre-GPT-4o
|| document.querySelector('path[d*="M15.1918 8.90615C15.6381"]')?.parentNode.parentNode // from sept-2024;
|| document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode; // post-GPT-4o;
//check if the sendbutton has been found //check if the sendbutton has been found
if (!sendButton) { if (!sendButton) {
console.error("[ThunderAI] Send button not found!"); console.error("[ThunderAI] Send button not found!");