Added the reply type option. related to #14

This commit is contained in:
mic 2024-04-05 12:00:32 +02:00
parent fcabeae80e
commit 5caa6a6d89
5 changed files with 49 additions and 4 deletions

View file

@ -104,6 +104,21 @@
"description": "" "description": ""
}, },
"prefs_OptionText_reply_all": {
"message": "Reply to All",
"description": ""
},
"prefs_OptionText_reply_sender": {
"message": "Reply to Sender",
"description": ""
},
"prefs_OptionText_reply_type": {
"message": "Reply type",
"description": ""
},
"prefsInfoTitle": { "prefsInfoTitle": {
"message": "Important Information", "message": "Important Information",
"description": "" "description": ""

View file

@ -104,6 +104,21 @@
"description": "" "description": ""
}, },
"prefs_OptionText_reply_all": {
"message": "Rispondi a tutti",
"description": ""
},
"prefs_OptionText_reply_sender": {
"message": "Rispondi al mittente",
"description": ""
},
"prefs_OptionText_reply_type": {
"message": "Modalità di riposta",
"description": ""
},
"prefsInfoTitle": { "prefsInfoTitle": {
"message": "Informazioni Importanti", "message": "Informazioni Importanti",
"description": "" "description": ""

View file

@ -24,7 +24,7 @@ for (let messageTab of messageTabs) {
} }
messenger.runtime.onMessage.addListener((message, sender, sendResponse) => { messenger.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
// Check what type of message we have received and invoke the appropriate // Check what type of message we have received and invoke the appropriate
// handler function. // handler function.
if (message && message.hasOwnProperty("command")){ if (message && message.hasOwnProperty("command")){
@ -55,8 +55,15 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => {
}); });
const paragraphsHtmlString = paragraphs.map(p => p.outerHTML).join(""); const paragraphsHtmlString = paragraphs.map(p => p.outerHTML).join("");
//console.log('paragraphsHtmlString: ' + paragraphsHtmlString); //console.log('paragraphsHtmlString: ' + paragraphsHtmlString);
let prefs = await browser.storage.sync.get({reply_type: 'reply_all'});
console.log('reply_type: ' + prefs.reply_type);
let replyType = 'replyToAll';
if(prefs.reply_type === 'reply_sender'){
replyType = 'replyToSender';
}
console.log('replyType: ' + replyType);
browser.messageDisplay.getDisplayedMessage(message.tabId).then((mailMessage) => { browser.messageDisplay.getDisplayedMessage(message.tabId).then((mailMessage) => {
browser.compose.beginReply(mailMessage.id, "replyToAll", { browser.compose.beginReply(mailMessage.id, replyType, {
type: "reply", type: "reply",
body: paragraphsHtmlString, body: paragraphsHtmlString,
isPlainText: false, isPlainText: false,

View file

@ -12,7 +12,13 @@
<input type="number" id="chatgpt_win_width" name="chatgpt_win_width" class="option-input" /> __MSG_prefs_OptionText_chatgpt_win_width__</label><br/> <input type="number" id="chatgpt_win_width" name="chatgpt_win_width" class="option-input" /> __MSG_prefs_OptionText_chatgpt_win_width__</label><br/>
<br/> <br/>
<label><input type="text" id="default_sign_name" name="default_sign_name" class="option-input" /> __MSG_prefs_OptionText_default_sign_name__</label><br/> <label><input type="text" id="default_sign_name" name="default_sign_name" class="option-input" /> __MSG_prefs_OptionText_default_sign_name__</label><br/>
<label><input type="text" id="default_chatgpt_lang" name="default_chatgpt_lang" class="option-input" /> __MSG_prefs_OptionText_default_chatgpt_lang__</label> <label><input type="text" id="default_chatgpt_lang" name="default_chatgpt_lang" class="option-input" /> __MSG_prefs_OptionText_default_chatgpt_lang__</label><br/>
<label>
<select id="reply_type" name="reply_type" class="option-input">
<option value="reply_all">__MSG_prefs_OptionText_reply_all__</option>
<option value="reply_sender">__MSG_prefs_OptionText_reply_sender__</option>
</select> __MSG_prefs_OptionText_reply_type__
</label><br/>
</div> </div>
<div id="miczDescription"> <div id="miczDescription">
<h1>__MSG_prefsInfoTitle__</h1> <h1>__MSG_prefsInfoTitle__</h1>

View file

@ -47,7 +47,9 @@ function restoreOptions() {
break; break;
default: default:
if (element.tagName === 'SELECT') { if (element.tagName === 'SELECT') {
element.value = result[element.id] || ''; let default_select_value = '';
if(element.id == 'reply_type') default_select_value = 'reply_all';
element.value = result[element.id] || default_select_value;
if (element.value === '') { if (element.value === '') {
element.selectedIndex = -1; element.selectedIndex = -1;
} }