Whatever
// Listening for the extension to trigger (e.g., via a custom command or button) async function forwardConversation(tabId, msgs) { let body = await exportConversationAsH… (citește mai mult)
// Listening for the extension to trigger (e.g., via a custom command or button) async function forwardConversation(tabId, msgs) {
let body = await exportConversationAsHtml(msgs); let displayedMsgs = await browser.messageDisplay.getDisplayedMessages(tabId); let identityId = undefined;
if (displayedMsgs.length) {
let accountId = displayedMsgs[0].folder.accountId;
let account = await browser.accounts.get(accountId);
identityId = account.identities[0]?.id;
}
await browser.compose.beginNew({
identityId,
isPlainText: false,
body,
});
}
async function exportConversationAsHtml(msgs) {
let hr = `let html = `Forwarded Conversation:
` + hr; let promises = msgs.map(msg => exportMsgAsHtml(msg)); let messagesHtml = await Promise.all(promises); html += `` + messagesHtml.join(hr) + ``; return html;
}
async function exportMsgAsHtml(msg) {
// Simple fallback to extract text content safelyreturn `
Subject: ${msg.subject}
${msg.body || ""}
}