diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d5918bd9..cdd3ad4d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -619,6 +619,10 @@ "message": "Recipients", "description": "" }, + "placeholder_cc_list": { + "message": "CC list", + "description": "" + }, "placeholder_author": { "message": "Author", "description": "" diff --git a/js/mzta-menus.js b/js/mzta-menus.js index 16b39fea..62c3502e 100644 --- a/js/mzta-menus.js +++ b/js/mzta-menus.js @@ -113,33 +113,44 @@ export class mzta_Menus { } } - // let mail_subject = await getMailSubject(tabs[0]); - // console.log(">>>>>>>>>>>>>>> mail_subject: " + mail_subject); - let fullPrompt = ''; if(!placeholdersUtils.hasPlaceholder(curr_prompt.text)){ // no placeholders, do as usual fullPrompt = curr_prompt.text + (String(curr_prompt.need_signature) == "1" ? " " + await this.getDefaultSignature():"") + " " + chatgpt_lang + " \"" + (selection_text=='' ? body_text : selection_text) + "\" "; }else{ - let mail_subject = await getMailSubject(tabs[0]); // we have at least a placeholder, do the magic! let currPHs = await placeholdersUtils.extractPlaceholders(curr_prompt.text); // console.log(">>>>>>>>>> currPHs: " + JSON.stringify(currPHs)); let finalSubs = {}; + let curr_messages = await browser.mailTabs.getSelectedMessages(); + let curr_message = curr_messages.messages[0]; for(let currPH of currPHs){ switch(currPH.id){ case 'mail_body': finalSubs['mail_body'] = body_text; break; - case 'html_body': console.log(">>>>>>>>>> html_body: " + msg_text.html); + case 'html_body': finalSubs['html_body'] = msg_text.html; break; case 'mail_subject': + let mail_subject = await getMailSubject(tabs[0]); finalSubs['mail_subject'] = mail_subject; break; case 'selected_text': finalSubs['selected_text'] = selection_text; break; + case 'author': + finalSubs['author'] = curr_message.author; + break; + case 'recipients': + finalSubs['recipients'] = curr_message.recipients.join(", "); + break; + case 'cc_list': + finalSubs['cc_list'] = curr_message.ccList.join(", "); + break; + case 'junk_score': + finalSubs['junk_score'] = curr_message.junkScore; + break; default: // TODO Manage custom placeholders https://github.com/micz/ThunderAI/issues/156 break; } diff --git a/js/mzta-placeholders.js b/js/mzta-placeholders.js index 48d2aa0f..60851f37 100644 --- a/js/mzta-placeholders.js +++ b/js/mzta-placeholders.js @@ -69,21 +69,28 @@ const defaultPlaceholders = [ is_default: "1", }, { - id: 'junk_score', //TODO + id: 'junk_score', name: "__MSG_placeholder_junk_score__", text: "", type: 1, is_default: "1", }, { - id: 'recipients', //TODO + id: 'recipients', name: "__MSG_placeholder_recipients__", text: "", type: 0, is_default: "1", }, { - id: 'author', //TODO + id: 'cc_list', + name: "__MSG_placeholder_cc_list__", + text: "", + type: 0, + is_default: "1", + }, + { + id: 'author', name: "__MSG_placeholder_author__", text: "", type: 0,