correctly replying and substituting text

This commit is contained in:
mic 2024-07-21 23:47:05 +02:00
parent 6d9bb7cf7c
commit 26aa9b0092

View file

@ -154,7 +154,17 @@ class MessagesArea extends HTMLElement {
actionButton.textContent = 'Use this answer';
//actionButton.textContent = browser.i18n.getMessage("chatgpt_win_get_answer");
actionButton.addEventListener('click', () => {
alert('action: ' + promptData.action);
switch(promptData.action) {
case "1": // do reply
browser.runtime.sendMessage({command: "chatgpt_replyMessage", text: this.fullTextHTML, tabId: promptData.tabId, mailMessageId: promptData.mailMessageId});
browser.runtime.sendMessage({command: "chatgpt_close"});
break;
case "2": // replace text
browser.runtime.sendMessage({command: "chatgpt_replaceSelectedText", text: this.fullTextHTML, tabId: promptData.tabId, mailMessageId: promptData.mailMessageId});
//console.log(response);
browser.runtime.sendMessage({command: "chatgpt_close"});
break;
}
});
actionButtons.appendChild(actionButton);
this.messages.appendChild(actionButtons);