diff --git a/_locales/en/messages.json b/_locales/en/messages.json index ad7acde8..51583825 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1387,6 +1387,10 @@ "message": "To use the Claude API integration, you need to grant the required permission.", "description": "" }, + "ask_openai_api_permission_1": { + "message": "To use the OpenAI API integration, you need to grant the required permission.", + "description": "" + }, "ask_integration_permission_2_popup": { "message": "Click here to open a new tab and follow the instructions.", "description": "" @@ -1685,4 +1689,4 @@ "message": "Deselect All", "description": "" } -} \ No newline at end of file +} diff --git a/_locales/it/messages.json b/_locales/it/messages.json index 880e5f38..7f775e72 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -1083,6 +1083,9 @@ "ask_anthropic_api_permission_1": { "message": "Per utilizzare l'integrazione con l'API di Claude, è necessario concedere l'autorizzazione richiesta." }, + "ask_openai_api_permission_1": { + "message": "Per utilizzare l'integrazione con l'API di OpenAI, è necessario concedere l'autorizzazione richiesta." + }, "Anthropic_Version_Info": { "message": "OBBLIGATORIO. Non modificare questo valore a meno che tu non sappia esattamente cosa stai facendo. Maggiori informazioni su:" }, diff --git a/pages/onboarding/onboarding.css b/pages/onboarding/onboarding.css index 489cdabe..7b4a397d 100644 --- a/pages/onboarding/onboarding.css +++ b/pages/onboarding/onboarding.css @@ -182,7 +182,7 @@ h2 { box-shadow: inset 5px 2px 5px rgba(0, 0, 0, 0.3); } -#chatgpt_web_permission, #anthropic_api_permission { +#chatgpt_web_permission, #anthropic_api_permission, #openai_api_permission { display: none; background-color: red; color: white; @@ -196,7 +196,7 @@ h2 { transition: background-color 0.3s ease, transform 0.3s ease; } -#chatgpt_web_permission:hover, #anthropic_api_permission:hover { +#chatgpt_web_permission:hover, #anthropic_api_permission:hover, #openai_api_permission:hover { background-color: darkred; transform: scale(1.05); } diff --git a/pages/onboarding/onboarding.html b/pages/onboarding/onboarding.html index 5d005741..904a6610 100644 --- a/pages/onboarding/onboarding.html +++ b/pages/onboarding/onboarding.html @@ -17,6 +17,9 @@
__MSG_ask_chatgptweb_permission_1__
__MSG_ask_integration_permission_2__
+
__MSG_ask_openai_api_permission_1__ +
__MSG_ask_integration_permission_2__ +
__MSG_ask_anthropic_api_permission_1__
__MSG_ask_integration_permission_2__
diff --git a/pages/onboarding/onboarding.js b/pages/onboarding/onboarding.js index 490dbe85..747aedad 100644 --- a/pages/onboarding/onboarding.js +++ b/pages/onboarding/onboarding.js @@ -66,4 +66,23 @@ document.addEventListener('DOMContentLoaded', async () => { }); } } + if(prefs.connection_type === 'chatgpt_api'){ + let permission_openai = await messenger.permissions.contains({ origins: ["https://*.openai.com/*"] }); + if(permission_openai === false){ + document.getElementById("openai_api_permission").style.display = "block"; + document.getElementById("openai_api_permission").addEventListener("click", async () => { + let granted = await messenger.permissions.request({ origins: ["https://*.openai.com/*"] }); + if(granted){ + document.getElementById("openai_api_permission").style.display = "none"; + document.getElementById("integration_permission_ok").style.display = "block"; + taLog.log("OpenAI API permission granted"); + }else{ + taLog.log("OpenAI API permission denied"); + } + }); + document.getElementById("integration_permission_ok").addEventListener("click", async () => { + await messenger.tabs.remove((await messenger.tabs.getCurrent()).id); + }); + } + } }, { once: true }); diff --git a/popup/mzta-popup.css b/popup/mzta-popup.css index 7aae2583..2ff9569e 100644 --- a/popup/mzta-popup.css +++ b/popup/mzta-popup.css @@ -68,7 +68,7 @@ body { background-color: #cfe9ff; } - #ask_chatgpt_web_perm, #ask_anthropic_api_perm{ + #ask_chatgpt_web_perm, #ask_anthropic_api_perm, #ask_openai_api_perm{ display: none; max-width: 20em; background-color: red; @@ -117,4 +117,4 @@ body { .special_prompt{ background-color: #353542; } - } \ No newline at end of file + } diff --git a/popup/mzta-popup.html b/popup/mzta-popup.html index a6190e12..1abeead3 100644 --- a/popup/mzta-popup.html +++ b/popup/mzta-popup.html @@ -14,6 +14,9 @@
__MSG_ask_anthropic_api_permission_1__
__MSG_ask_integration_permission_2_popup__
+
__MSG_ask_openai_api_permission_1__ +
__MSG_ask_integration_permission_2_popup__ +
 
@@ -24,4 +27,4 @@ - \ No newline at end of file + diff --git a/popup/mzta-popup.js b/popup/mzta-popup.js index 1dc920b0..d73aaf14 100644 --- a/popup/mzta-popup.js +++ b/popup/mzta-popup.js @@ -95,6 +95,16 @@ document.addEventListener('DOMContentLoaded', async () => { }); } } + if(prefs.connection_type === 'chatgpt_api'){ + let permission_openai = await browser.permissions.contains({ origins: ["https://*.openai.com/*"] }); + if(permission_openai === false){ + document.getElementById("mzta_search_banner").style.display = "none"; + document.getElementById("ask_openai_api_perm").style.display = "block"; + document.getElementById('ask_openai_api_perm').addEventListener('click', async () => { + await browser.tabs.create({ url: "../pages/onboarding/onboarding.html" }); + }); + } + } }, { once: true }); async function searchPrompt(allPrompts, tabId, tabType){ @@ -431,4 +441,4 @@ function ensurePromptGetTaskFirst(arr, do_add_tags, do_get_calendar_event) { } return arr; -} \ No newline at end of file +}