implemented the reply to action
This commit is contained in:
parent
2c5ed3108b
commit
1e283cb2aa
2 changed files with 11 additions and 2 deletions
|
|
@ -107,15 +107,16 @@ function addCustomDiv(prompt_action,tabId) {
|
|||
break;
|
||||
case 1: // do reply
|
||||
pulsante.innerHTML = browser.i18n.getMessage("chatgpt_win_get_answer");
|
||||
pulsante.onclick = async function() { // TODO
|
||||
pulsante.onclick = async function() {
|
||||
const response = await chatgpt_getFromDOM('last');
|
||||
browser.runtime.sendMessage({command: "chatgpt_replyMessage", text: response, tabId: tabId});
|
||||
//console.log(response);
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
};
|
||||
break;
|
||||
case 2: // replace text
|
||||
pulsante.innerHTML = browser.i18n.getMessage("chatgpt_win_get_answer");
|
||||
pulsante.onclick = async function() { // TODO
|
||||
pulsante.onclick = async function() {
|
||||
const response = await chatgpt_getFromDOM('last');
|
||||
//console.log('replace text: '+tabId)
|
||||
browser.runtime.sendMessage({command: "chatgpt_replaceSelectedText", text: response, tabId: tabId});
|
||||
|
|
|
|||
|
|
@ -44,6 +44,14 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||
//console.log('chatgpt_replaceSelectedText: [' + message.tabId +'] ' + message.text)
|
||||
browser.tabs.sendMessage(message.tabId, { command: "replaceSelectedText", text: message.text });
|
||||
return true;
|
||||
case 'chatgpt_replyMessage':
|
||||
browser.messageDisplay.getDisplayedMessage(message.tabId).then((mailMessage) => {
|
||||
browser.compose.beginReply(mailMessage.id, {
|
||||
type: "reply",
|
||||
body: message.text
|
||||
})
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue