From 4fdd7d3dc20e4c16f39633559f2a84b0db69d479 Mon Sep 17 00:00:00 2001 From: mic Date: Tue, 30 Jul 2024 21:48:43 +0200 Subject: [PATCH] asking for custom text using the javascript prompt() function. fixes #96. To be improved. --- api_webchat/controller.js | 6 ++++++ mzta-background.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api_webchat/controller.js b/api_webchat/controller.js index 61e71e05..6591b779 100644 --- a/api_webchat/controller.js +++ b/api_webchat/controller.js @@ -89,6 +89,12 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => { //console.log(">>>>>>>>>>>>> controller.js onMessage: " + JSON.stringify(message)); if (message.command === "chatgpt_send") { //send the received prompt to the chatgpt api + if(message.do_custom_text) { + let userInput = prompt(browser.i18n.getMessage("chatgpt_win_custom_text")); + if(userInput !== null) { + message.prompt += " " + userInput; + } + } promptData = message; messageInput._setMessageInputValue(message.prompt); messageInput._handleNewChatMessage(); diff --git a/mzta-background.js b/mzta-background.js index 569901db..ff9dab2e 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -245,7 +245,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ let mailMessageId = -1; if(mailMessage) mailMessageId = mailMessage.id; - browser.tabs.sendMessage(createdTab2.id, { command: "chatgpt_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId}); + browser.tabs.sendMessage(createdTab2.id, { command: "chatgpt_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId, do_custom_text: do_custom_text}); break; // chatgpt_api } }