From 9d8e5e705ab03cb0cf32f94c91c2be2fcdfe2cf7 Mon Sep 17 00:00:00 2001 From: Mic Date: Fri, 29 Nov 2024 21:03:41 +0100 Subject: [PATCH] correctly handling the presence of the audio button. fixes #188 --- js/mzta-chatgpt.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/mzta-chatgpt.js b/js/mzta-chatgpt.js index 0fe96f1e..001dcdfa 100644 --- a/js/mzta-chatgpt.js +++ b/js/mzta-chatgpt.js @@ -37,9 +37,6 @@ async function chatgpt_sendMsg(msg, method ='') { // return -1 send button textArea = document.querySelector('form textarea'); 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 if(!textArea) { console.error("[ThunderAI] Textarea not found!"); @@ -52,6 +49,11 @@ async function chatgpt_sendMsg(msg, method ='') { // return -1 send button textArea.innerText = msg; 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 if (!sendButton) { console.error("[ThunderAI] Send button not found!");