Added new mail_typed_text data placeholder. fixes #196
This commit is contained in:
parent
e7ef1f985a
commit
241c8d67f6
3 changed files with 30 additions and 1 deletions
|
|
@ -39,7 +39,7 @@ switch (message.command) {
|
|||
return Promise.resolve(true);
|
||||
break;
|
||||
|
||||
case "getText":
|
||||
case "getText": {
|
||||
let t = '';
|
||||
const children = window.document.body.childNodes;
|
||||
for (const node of children) {
|
||||
|
|
@ -51,6 +51,7 @@ switch (message.command) {
|
|||
t += node.textContent;
|
||||
}
|
||||
return Promise.resolve(t);
|
||||
}
|
||||
|
||||
case "getTextOnly":
|
||||
return Promise.resolve(window.document.body.innerText);
|
||||
|
|
@ -58,6 +59,21 @@ switch (message.command) {
|
|||
case "getFullHtml":
|
||||
return Promise.resolve(window.document.body.innerHTML);
|
||||
|
||||
case "getOnlyTypedText": {
|
||||
// TODO: add support for moz-cite-prefix
|
||||
let t = '';
|
||||
const children = window.document.body.childNodes;
|
||||
for (const node of children) {
|
||||
if (node instanceof Element) {
|
||||
if (node.classList.contains('moz-cite-prefix')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
t += node.textContent;
|
||||
}
|
||||
return Promise.resolve(t);
|
||||
}
|
||||
|
||||
case 'sendAlert':
|
||||
//console.log(">>>>>> message.curr_tab_type: " + JSON.stringify(message.curr_tab_type));
|
||||
if(message.curr_tab_type == 'mail'){ // workaround for Thunderbird bug not showing the alert
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export class mzta_Menus {
|
|||
selection: await browser.tabs.sendMessage(tabs[0].id, { command: "getSelectedText" }),
|
||||
text: await browser.tabs.sendMessage(tabs[0].id, { command: "getTextOnly" }),
|
||||
html: await browser.tabs.sendMessage(tabs[0].id, { command: "getFullHtml" }),
|
||||
only_typed_text: await browser.tabs.sendMessage(tabs[0].id, { command: "getOnlyTypedText" })
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -99,8 +100,10 @@ export class mzta_Menus {
|
|||
|
||||
let body_text = '';
|
||||
let selection_text = '';
|
||||
let only_typed_text = '';
|
||||
selection_text = msg_text.selection.replace(/\s+/g, ' ').trim();
|
||||
body_text = msg_text.text.replace(/\s+/g, ' ').trim();
|
||||
only_typed_text = msg_text.only_typed_text.replace(/\s+/g, ' ').trim();
|
||||
//open chatgpt window
|
||||
//console.log("Click menu item...");
|
||||
let chatgpt_lang = '';
|
||||
|
|
@ -150,6 +153,9 @@ export class mzta_Menus {
|
|||
case 'mail_html_body':
|
||||
finalSubs['mail_html_body'] = msg_text.html;
|
||||
break;
|
||||
case 'mail_typed_text':
|
||||
finalSubs['mail_typed_text'] = only_typed_text;
|
||||
break;
|
||||
case 'mail_subject':
|
||||
let mail_subject = await getMailSubject(tabs[0]);
|
||||
finalSubs['mail_subject'] = mail_subject;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,13 @@ const defaultPlaceholders = [
|
|||
type: 0,
|
||||
is_default: "1",
|
||||
},
|
||||
{
|
||||
id: 'mail_typed_text',
|
||||
name: "__MSG_placeholder_mail_typed_text__",
|
||||
default_value: "",
|
||||
type: 2,
|
||||
is_default: "1",
|
||||
},
|
||||
{
|
||||
id: 'mail_subject',
|
||||
name: "__MSG_placeholder_mail_subject__",
|
||||
|
|
|
|||
Loading…
Reference in a new issue