From b0406f2ae48a40e8484d8429ee82cc8e02891bad Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 11 Sep 2024 20:19:55 +0200 Subject: [PATCH] fixed a change in cahtgpt web interface. see #133 --- js/mzta-chatgpt.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/js/mzta-chatgpt.js b/js/mzta-chatgpt.js index 1b8dcaee..0a175d6d 100644 --- a/js/mzta-chatgpt.js +++ b/js/mzta-chatgpt.js @@ -31,17 +31,30 @@ let selectionChangeTimeout = null; let isDragging = false; async function chatgpt_sendMsg(msg, method ='') { // return -1 send button not found, -2 textarea not found - const textArea = document.querySelector('form textarea'); - let sendButton = document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode // post-GPT-4o; + let textArea = document.getElementById('prompt-textarea') + let old_textArea = false; + if(!textArea){ + textArea = document.querySelector('form textarea'); + old_textArea = true; + } + let sendButton = 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; || document.querySelector('[data-testid="send-button"]'); // pre-GPT-4o //check if the textarea has been found if(!textArea) { + console.error("[ThunderAI] Textarea not found!"); return -2; } - textArea.value = msg; - textArea.dispatchEvent(new Event('input', { bubbles: true })); // enable send button + if(old_textArea){ + textArea.value = msg; + textArea.dispatchEvent(new Event('input', { bubbles: true })); // enable send button + } else { // from sept 2024 + textArea.innerText = msg; + textArea.dispatchEvent(new Event('input', { bubbles: true })); + } //check if the sendbutton has been found if (!sendButton) { + console.error("[ThunderAI] Send button not found!"); return -1; } const delaySend = setInterval(() => {