Asking for the *.openai.com API optional permission. see #529
This commit is contained in:
parent
f2e6412d12
commit
30b10dcda0
8 changed files with 49 additions and 7 deletions
|
|
@ -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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@
|
|||
<div id="chatgpt_web_permission">__MSG_ask_chatgptweb_permission_1__
|
||||
<br>__MSG_ask_integration_permission_2__
|
||||
</div>
|
||||
<div id="openai_api_permission">__MSG_ask_openai_api_permission_1__
|
||||
<br>__MSG_ask_integration_permission_2__
|
||||
</div>
|
||||
<div id="anthropic_api_permission">__MSG_ask_anthropic_api_permission_1__
|
||||
<br>__MSG_ask_integration_permission_2__
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@
|
|||
<div id="ask_anthropic_api_perm">__MSG_ask_anthropic_api_permission_1__
|
||||
<br>__MSG_ask_integration_permission_2_popup__
|
||||
</div>
|
||||
<div id="ask_openai_api_perm">__MSG_ask_openai_api_permission_1__
|
||||
<br>__MSG_ask_integration_permission_2_popup__
|
||||
</div>
|
||||
<div id="mzta_search_banner">
|
||||
<div id="_spacer_div"> </div>
|
||||
<div id="mzta_sending_prompt"><img src="mzta-loading.svg" title="__MSG_SendingPrompt__"></div>
|
||||
|
|
@ -24,4 +27,4 @@
|
|||
<script src="mzta-popup.js" type="module"></script>
|
||||
<script src="../js/mzta-i18n.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue