From d49e6d65e78b0fbe47493ae867437817d78e703d Mon Sep 17 00:00:00 2001 From: mic Date: Sun, 20 Apr 2025 22:15:10 +0200 Subject: [PATCH] a "do_reply" from the compose window is changed in a "substitute text". see #353 --- api_webchat/messagesArea.js | 5 ++++- js/mzta-chatgpt.js | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api_webchat/messagesArea.js b/api_webchat/messagesArea.js index 56148817..186c0ec2 100644 --- a/api_webchat/messagesArea.js +++ b/api_webchat/messagesArea.js @@ -232,6 +232,9 @@ class MessagesArea extends HTMLElement { const fullTextHTMLAtAssignment = this.fullTextHTML.trim().replace(/^"|"$/g, '').replace(/^

"/, '

').replace(/"<\/p>$/, '

'); // strip quotation marks //console.log(">>>>>>>>>>>> fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment); actionButton.addEventListener('click', async () => { + if(promptData.mailMessageId == -1) { // we are using the reply from the compose window! + promptData.action = "2"; // replace text + } switch(promptData.action) { case "1": // do reply // console.log("[ThunderAI] (do reply) fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment); @@ -239,7 +242,7 @@ class MessagesArea extends HTMLElement { browser.runtime.sendMessage({command: "chatgpt_close", window_id: (await browser.windows.getCurrent()).id}); break; case "2": // replace text - // console.log("[ThunderAI] (replace text) fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment); + console.log("[ThunderAI] (replace text) fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment); await browser.runtime.sendMessage({command: "chatgpt_replaceSelectedText", text: fullTextHTMLAtAssignment, tabId: promptData.tabId, mailMessageId: promptData.mailMessageId}); browser.runtime.sendMessage({command: "chatgpt_close", window_id: (await browser.windows.getCurrent()).id}); break; diff --git a/js/mzta-chatgpt.js b/js/mzta-chatgpt.js index 9325e146..9bfc2f5e 100644 --- a/js/mzta-chatgpt.js +++ b/js/mzta-chatgpt.js @@ -647,6 +647,9 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => { current_message = message; current_tabId = message.tabId; current_mailMessageId = message.mailMessageId; + if(current_mailMessageId == -1) { // we are using the reply from the compose window! + current_action = '2'; // replace text + } run(); break; case "chatgpt_alive":