From 485666b68a1159132fa395e76b43bd8547484cf4 Mon Sep 17 00:00:00 2001 From: mic Date: Fri, 5 Apr 2024 00:02:45 +0200 Subject: [PATCH] Default signature name added. related to #14. Fixes #2. --- _locales/en/messages.json | 5 +++++ _locales/it/messages.json | 6 ++++++ messageMenu/mzta-msgmenu.js | 11 ++++++++++- options/mzta-options.html | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 5a15b53f..a9e743d5 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -94,6 +94,11 @@ "description": "" }, + "prefs_OptionText_default_sign_name": { + "message": "Default signature name", + "description": "" + }, + "prefsInfoTitle": { "message": "Important Information", "description": "" diff --git a/_locales/it/messages.json b/_locales/it/messages.json index d6841de7..a9f6e655 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -94,6 +94,12 @@ "description": "" }, + "prefs_OptionText_default_sign_name": { + "message": "Nome predefinito della firma", + "description": "" + }, + + "prefsInfoTitle": { "message": "Informazioni Importanti", "description": "" diff --git a/messageMenu/mzta-msgmenu.js b/messageMenu/mzta-msgmenu.js index efd1606d..b99ef588 100644 --- a/messageMenu/mzta-msgmenu.js +++ b/messageMenu/mzta-msgmenu.js @@ -36,7 +36,7 @@ const addAction = (curr_prompt, promptsContainer) => { } //open chatgpt window //console.log("Click menu item..."); - var fullPrompt = curr_prompt.text + " " + browser.i18n.getMessage("prompt_lang") + browser.i18n.getMessage("prompt_translate_lang") + " \"" + msg_text.text + "\" "; + var fullPrompt = curr_prompt.text + " " + await getDefaultSignature() + " " + browser.i18n.getMessage("prompt_lang") + browser.i18n.getMessage("prompt_translate_lang") + " \"" + msg_text.text + "\" "; const tabs = await browser.tabs.query({ active: true, currentWindow: true }); browser.runtime.sendMessage({command: "chatgpt_open", prompt: fullPrompt, action: curr_prompt.action, tabId: tabs[0].id}); }; @@ -44,6 +44,15 @@ const addAction = (curr_prompt, promptsContainer) => { promptsContainer.appendChild(promptDiv); }; +async function getDefaultSignature(){ + let prefs = await browser.storage.sync.get({default_sign_name: ''}); + if(prefs.default_sign_name===''){ + return ''; + }else{ + return "Sign the message as " + prefs.default_sign_name + "."; + } +} + async function checkCompose(){ return await browser.windows.getCurrent().then((currWindow) => { //console.log("currWindow.type: "+currWindow.type); diff --git a/options/mzta-options.html b/options/mzta-options.html index 32634998..a0cf2309 100644 --- a/options/mzta-options.html +++ b/options/mzta-options.html @@ -11,7 +11,7 @@
__MSG_prefs_OptionText_chatgpt_win_width__

- +

__MSG_prefsInfoTitle__

__MSG_prefsInfoDesc_1__