From 4b630bee78e5fc663e7af8312582c584a2c25a55 Mon Sep 17 00:00:00 2001 From: mic Date: Fri, 3 May 2024 23:54:49 +0200 Subject: [PATCH 1/7] added the need_custom_text attribute. related to #32 --- js/mzta-prompts.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/js/mzta-prompts.js b/js/mzta-prompts.js index 03c5f31f..bbd08da6 100644 --- a/js/mzta-prompts.js +++ b/js/mzta-prompts.js @@ -28,21 +28,25 @@ 1: do reply 2: substitute text - Only if text selected (attribute need_selected): + Only if text selected (need_selected attribute): 0: no selection needed (use all the message body) 1: need a selection - Signature + Signature (need_signature attribute): 0: No signature needed 1: Signature needed + + Custom Text (need_custom_text attribute): + 0: No custom text needed + 1: Custom text needed */ export const defaultPrompts = [ - { id: 'prompt_reply', name: "__MSG_prompt_reply__", text: "Reply to the following email.", type: 1, action: 1, need_selected: 0, need_signature: 1 }, - { id: 'prompt_rewrite_polite', name: "__MSG_prompt_rewrite_polite__", text: "Rewrite the following text to be more polite. Reply with only the re-written text and with no extra comments or other text.", type: 2, action: 2, need_selected: 1, need_signature: 0 }, - { id: 'prompt_rewrite_formal', name: "__MSG_prompt_rewrite_formal__", text: "Rewrite the following text to be more formal. Reply with only the re-written text and with no extra comments or other text.", type: 2, action: 2, need_selected: 1, need_signature: 0 }, - { id: 'prompt_classify', name: "__MSG_prompt_classify__", text: "Classify the following text in terms of Politeness, Warmth, Formality, Assertiveness, Offensiveness giving a percentage for each category. Reply with only the category and score with no extra comments or other text.", type: 0, action: 0, need_selected: 0, need_signature: 0 }, - { id: 'prompt_summarize_this', name: "__MSG_prompt_summarize_this__", text: "Summarize the following email into a bullet point list.", type: 0, action: 0, need_selected: 0, need_signature: 0 }, - { id: 'prompt_translate_this', name: "__MSG_prompt_translate_this__", text: "Translate the following email in ", type: 0, action: 0, need_selected: 0, need_signature: 0 }, - { id: 'prompt_this', name: "__MSG_prompt_this__", text: "Reply with only the needed text and with no extra comments or other text.", type: 2, action: 2, need_selected: 1, need_signature: 0 }, + { id: 'prompt_reply', name: "__MSG_prompt_reply__", text: "Reply to the following email.", type: 1, action: 1, need_selected: 0, need_signature: 1, need_custom_text: 1 }, // need_custom_text set to 1 only for testing + { id: 'prompt_rewrite_polite', name: "__MSG_prompt_rewrite_polite__", text: "Rewrite the following text to be more polite. Reply with only the re-written text and with no extra comments or other text.", type: 2, action: 2, need_selected: 1, need_signature: 0, need_custom_text: 0 }, + { id: 'prompt_rewrite_formal', name: "__MSG_prompt_rewrite_formal__", text: "Rewrite the following text to be more formal. Reply with only the re-written text and with no extra comments or other text.", type: 2, action: 2, need_selected: 1, need_signature: 0, need_custom_text: 0 }, + { id: 'prompt_classify', name: "__MSG_prompt_classify__", text: "Classify the following text in terms of Politeness, Warmth, Formality, Assertiveness, Offensiveness giving a percentage for each category. Reply with only the category and score with no extra comments or other text.", type: 0, action: 0, need_selected: 0, need_signature: 0, need_custom_text: 0 }, + { id: 'prompt_summarize_this', name: "__MSG_prompt_summarize_this__", text: "Summarize the following email into a bullet point list.", type: 0, action: 0, need_selected: 0, need_signature: 0, need_custom_text: 0 }, + { id: 'prompt_translate_this', name: "__MSG_prompt_translate_this__", text: "Translate the following email in ", type: 0, action: 0, need_selected: 0, need_signature: 0, need_custom_text: 0 }, + { id: 'prompt_this', name: "__MSG_prompt_this__", text: "Reply with only the needed text and with no extra comments or other text.", type: 2, action: 2, need_selected: 1, need_signature: 0, need_custom_text: 0 }, ]; From c61268f1f2bd64d6866fd50218f9c898a6bc49c5 Mon Sep 17 00:00:00 2001 From: mic Date: Sat, 4 May 2024 00:00:31 +0200 Subject: [PATCH 2/7] prepending * to menutitle if custom prompt needed --- js/mzta-menus.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/mzta-menus.js b/js/mzta-menus.js index 4abdb395..708073c8 100644 --- a/js/mzta-menus.js +++ b/js/mzta-menus.js @@ -118,7 +118,7 @@ export class mzta_Menus { browser.menus.create({ id: id, - title: browser.i18n.getMessage(id), + title: this.getCustomTextAttribute(id) + browser.i18n.getMessage(id), contexts: this.getContexts(id), parentId: root }); @@ -151,6 +151,17 @@ export class mzta_Menus { } } - + + getCustomTextAttribute(id){ + const curr_prompt = defaultPrompts.find(p => p.id === id); + if (!curr_prompt) { + return ""; + } + if(curr_prompt.need_custom_text === 1){ + return "*"; + }else{ + return ""; + } + } } \ No newline at end of file From ee9704429dba1b1b7d251b055bd3f1e33a602831 Mon Sep 17 00:00:00 2001 From: mic Date: Sun, 5 May 2024 23:45:34 +0200 Subject: [PATCH 3/7] work in progress #32 --- js/mzta-chatgpt.js | 20 ++++++++++++++++++++ js/mzta-menus.js | 7 ++++--- mzta-background.js | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/js/mzta-chatgpt.js b/js/mzta-chatgpt.js index ecee2635..95a96785 100644 --- a/js/mzta-chatgpt.js +++ b/js/mzta-chatgpt.js @@ -120,6 +120,8 @@ function addCustomDiv(prompt_action,tabId) { style.innerHTML += "#mzta-btn_gpt35 {background-color: #007bff;border: none;color: white;padding: 2px 4px;text-align: center;text-decoration: none;display: none;font-size: 13px;margin-left: 4px;transition-duration: 0.4s;cursor: pointer;border-radius: 2px;}"; style.innerHTML += "#mzta-status-page{position:fixed;bottom:0;left:0;padding-left:5px;font-size:13px;font-style:italic;text-decoration:underline;color:#919191;}"; style.innerHTML += "#mzta-status-page:hover{color:#007bff;}"; + style.innerHTML += "#mzta-custom_text{position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);text-align: center;}"; + //display:none; // Add