From da955b4a2648853aea5625340ff63ead494944d1 Mon Sep 17 00:00:00 2001 From: mic Date: Mon, 6 May 2024 23:15:08 +0200 Subject: [PATCH] added a btn to open the manage prompts tab --- _locales/en/messages.json | 5 +++++ _locales/it/messages.json | 5 +++++ options/mzta-options.html | 3 +++ options/mzta-options.js | 12 ++++++++++++ 4 files changed, 25 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 5eaa8883..04276dbb 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -164,6 +164,11 @@ "description": "" }, + "prefs_OptionText_btnManagePrompts": { + "message": "Manage your prompts", + "description": "" + }, + "prefsInfoTitle": { "message": "Important Information", "description": "" diff --git a/_locales/it/messages.json b/_locales/it/messages.json index 1c189353..8f4dd146 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -164,6 +164,11 @@ "description": "" }, + "prefs_OptionText_btnManagePrompts": { + "message": "Gestisci i tuoi prompts", + "description": "" + }, + "prefsInfoTitle": { "message": "Informazioni Importanti", "description": "" diff --git a/options/mzta-options.html b/options/mzta-options.html index 4d8e79a3..b7fab2ef 100644 --- a/options/mzta-options.html +++ b/options/mzta-options.html @@ -71,6 +71,9 @@ +
+ +

__MSG_prefsInfoTitle__

__MSG_prefsInfoDesc_1__
diff --git a/options/mzta-options.js b/options/mzta-options.js index 1d443b30..394b0ca6 100644 --- a/options/mzta-options.js +++ b/options/mzta-options.js @@ -93,4 +93,16 @@ document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll(".option-input").forEach(element => { element.addEventListener("change", saveOptions); }); + document.getElementById('btnManagePrompts').addEventListener('click', () => { + // check if the tab is already there + browser.tabs.query({url: browser.runtime.getURL('../customprompts/mzta-custom-prompts.html')}).then((tabs) => { + if (tabs.length > 0) { + // if the tab is already there, focus it + browser.tabs.update(tabs[0].id, {active: true}); + } else { + // if the tab is not there, create it + browser.tabs.create({url: browser.runtime.getURL('../customprompts/mzta-custom-prompts.html')}); + } + }) + }); }, { once: true });