asking for the correct permission when using the Anthropic API. Fixes #389

This commit is contained in:
mic 2025-05-23 23:24:39 +02:00
parent e279412203
commit 5efdf91570
11 changed files with 65 additions and 25 deletions

View file

@ -1032,16 +1032,16 @@
"GetTask_info_default": { "GetTask_info_default": {
"message": "Auf dieser Seite kannst du den Standard-Prompt anpassen, der verwendet wird, um eine Aufgabe aus dem ausgewählten Text zu erstellen." "message": "Auf dieser Seite kannst du den Standard-Prompt anpassen, der verwendet wird, um eine Aufgabe aus dem ausgewählten Text zu erstellen."
}, },
"ask_chatgptweb_permission_2": { "ask_integration_permission_2": {
"message": "Klicke hier, um fortzufahren." "message": "Klicke hier, um fortzufahren."
}, },
"ask_chatgptweb_permission_1": { "ask_chatgptweb_permission_1": {
"message": "Um die ChatGPT-Web-Integration zu nutzen, musst du die erforderliche Berechtigung erteilen." "message": "Um die ChatGPT-Web-Integration zu nutzen, musst du die erforderliche Berechtigung erteilen."
}, },
"ask_chatgptweb_permission_2_popup": { "ask_integration_permission_2_popup": {
"message": "Klicke hier, um einen neuen Tab zu öffnen und den Anweisungen zu folgen." "message": "Klicke hier, um einen neuen Tab zu öffnen und den Anweisungen zu folgen."
}, },
"ask_chatgptweb_permission_ok": { "ask_integration_permission_ok": {
"message": "Berechtigung erteilt. Du kannst hier klicken, um diesen Tab zu schließen und zum Hauptfenster zurückzukehren." "message": "Berechtigung erteilt. Du kannst hier klicken, um diesen Tab zu schließen und zum Hauptfenster zurückzukehren."
}, },
"AccountSelector_AutoTags": { "AccountSelector_AutoTags": {

View file

@ -1348,18 +1348,22 @@
"description": "" "description": ""
}, },
"ask_chatgptweb_permission_1": { "ask_chatgptweb_permission_1": {
"message": "To use the ChatGPT Web Integration, you need to grant the required permission.", "message": "To use the ChatGPT Web integration, you need to grant the required permission.",
"description": "" "description": ""
}, },
"ask_chatgptweb_permission_2_popup": { "ask_anthropic_api_permission_1": {
"message": "To use the Anthropic 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.", "message": "Click here to open a new tab and follow the instructions.",
"description": "" "description": ""
}, },
"ask_chatgptweb_permission_2": { "ask_integration_permission_2": {
"message": "Click here to proceed.", "message": "Click here to proceed.",
"description": "" "description": ""
}, },
"ask_chatgptweb_permission_ok": { "ask_integration_permission_ok": {
"message": "Permission granted. You can click here to close this tab and return to the main window.", "message": "Permission granted. You can click here to close this tab and return to the main window.",
"description": "" "description": ""
}, },

View file

@ -987,10 +987,10 @@
"prefs_OptionText_chatgpt_web_custom_data_info": { "prefs_OptionText_chatgpt_web_custom_data_info": {
"message": "Cela doit être dans le format suivant :" "message": "Cela doit être dans le format suivant :"
}, },
"ask_chatgptweb_permission_2_popup": { "ask_integration_permission_2_popup": {
"message": "Cliquez ici pour ouvrir un nouvel onglet et suivre les instructions." "message": "Cliquez ici pour ouvrir un nouvel onglet et suivre les instructions."
}, },
"ask_chatgptweb_permission_2": { "ask_integration_permission_2": {
"message": "Cliquez ici pour continuer." "message": "Cliquez ici pour continuer."
}, },
"prefs_OptionText_Project_No_temporary_chat_warn": { "prefs_OptionText_Project_No_temporary_chat_warn": {
@ -1035,7 +1035,7 @@
"AccountSelector_Spamfilter": { "AccountSelector_Spamfilter": {
"message": "Choisissez les comptes pour lesquels le filtre anti-spam est activé" "message": "Choisissez les comptes pour lesquels le filtre anti-spam est activé"
}, },
"ask_chatgptweb_permission_ok": { "ask_integration_permission_ok": {
"message": "Autorisation accordée. Vous pouvez cliquer ici pour fermer cet onglet et revenir à la fenêtre principale." "message": "Autorisation accordée. Vous pouvez cliquer ici pour fermer cet onglet et revenir à la fenêtre principale."
}, },
"prefs_OptionText_add_tags_auto_Info2": { "prefs_OptionText_add_tags_auto_Info2": {

View file

@ -996,7 +996,7 @@
"ask_chatgptweb_permission_1": { "ask_chatgptweb_permission_1": {
"message": "Per utilizzare l'integrazione con ChatGPT Web, devi concedere l'autorizzazione richiesta." "message": "Per utilizzare l'integrazione con ChatGPT Web, devi concedere l'autorizzazione richiesta."
}, },
"ask_chatgptweb_permission_2_popup": { "ask_integration_permission_2_popup": {
"message": "Clicca qui per aprire una nuova scheda e seguire le istruzioni." "message": "Clicca qui per aprire una nuova scheda e seguire le istruzioni."
}, },
"GetTask_info_default": { "GetTask_info_default": {
@ -1035,10 +1035,10 @@
"no_valid_data_received": { "no_valid_data_received": {
"message": "Nessun dato valido ricevuto dall'IA." "message": "Nessun dato valido ricevuto dall'IA."
}, },
"ask_chatgptweb_permission_2": { "ask_integration_permission_2": {
"message": "Clicca qui per procedere." "message": "Clicca qui per procedere."
}, },
"ask_chatgptweb_permission_ok": { "ask_integration_permission_ok": {
"message": "Autorizzazione concessa. Puoi cliccare qui per chiudere questa scheda e tornare alla finestra principale." "message": "Autorizzazione concessa. Puoi cliccare qui per chiudere questa scheda e tornare alla finestra principale."
}, },
"prompt_proofread_this": { "prompt_proofread_this": {

View file

@ -38,6 +38,7 @@
"messagesUpdate", "messagesUpdate",
"messagesMove", "messagesMove",
"https://*.chatgpt.com/*", "https://*.chatgpt.com/*",
"https://*.anthropic.com/*",
"<all_urls>" "<all_urls>"
], ],
"background": { "background": {

View file

@ -182,7 +182,7 @@ h2 {
box-shadow: inset 5px 2px 5px rgba(0, 0, 0, 0.3); box-shadow: inset 5px 2px 5px rgba(0, 0, 0, 0.3);
} }
#chatgpt_web_permission { #chatgpt_web_permission, #anthropic_api_permission {
display: none; display: none;
background-color: red; background-color: red;
color: white; color: white;
@ -196,12 +196,12 @@ h2 {
transition: background-color 0.3s ease, transform 0.3s ease; transition: background-color 0.3s ease, transform 0.3s ease;
} }
#chatgpt_web_permission:hover { #chatgpt_web_permission:hover, #anthropic_api_permission:hover {
background-color: darkred; background-color: darkred;
transform: scale(1.05); transform: scale(1.05);
} }
#chatgpt_web_permission_ok { #integration_permission_ok {
display: none; display: none;
background-color: green; background-color: green;
color: white; color: white;
@ -213,7 +213,7 @@ h2 {
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
} }
#chatgpt_web_permission_ok:hover { #integration_permission_ok:hover {
background-color: darkgreen; background-color: darkgreen;
transform: scale(1.05); transform: scale(1.05);
} }

View file

@ -15,9 +15,12 @@
<body> <body>
<div class="content"> <div class="content">
<div id="chatgpt_web_permission">__MSG_ask_chatgptweb_permission_1__ <div id="chatgpt_web_permission">__MSG_ask_chatgptweb_permission_1__
<br>__MSG_ask_chatgptweb_permission_2__ <br>__MSG_ask_integration_permission_2__
</div> </div>
<div id="chatgpt_web_permission_ok">__MSG_ask_chatgptweb_permission_ok__</div> <div id="anthropic_api_permission">__MSG_ask_anthropic_api_permission_1__
<br>__MSG_ask_integration_permission_2__
</div>
<div id="integration_permission_ok">__MSG_ask_integration_permission_ok__</div>
<div class="section header"> <div class="section header">
<h1><img src="../../images/icon.png" class="title-icon"/>ThunderAI</h1> <h1><img src="../../images/icon.png" class="title-icon"/>ThunderAI</h1>
<p> <p>

View file

@ -32,13 +32,32 @@ document.addEventListener('DOMContentLoaded', async () => {
let granted = await messenger.permissions.request({ origins: ["https://*.chatgpt.com/*"] }); let granted = await messenger.permissions.request({ origins: ["https://*.chatgpt.com/*"] });
if(granted){ if(granted){
document.getElementById("chatgpt_web_permission").style.display = "none"; document.getElementById("chatgpt_web_permission").style.display = "none";
document.getElementById("chatgpt_web_permission_ok").style.display = "block"; document.getElementById("integration_permission_ok").style.display = "block";
taLog.log("ChatGPT web permission granted"); taLog.log("ChatGPT Web permission granted");
}else{ }else{
taLog.log("ChatGPT web permission denied"); taLog.log("ChatGPT Web permission denied");
} }
}); });
document.getElementById("chatgpt_web_permission_ok").addEventListener("click", async () => { document.getElementById("integration_permission_ok").addEventListener("click", async () => {
await messenger.tabs.remove((await messenger.tabs.getCurrent()).id);
});
}
}
if(prefs.connection_type === 'anthropic_api'){
let permission_chatgpt = await messenger.permissions.contains({ origins: ["https://*.anthropic.com/*"] });
if(permission_chatgpt === false){
document.getElementById("anthropic_api_permission").style.display = "block";
document.getElementById("anthropic_api_permission").addEventListener("click", async () => {
let granted = await messenger.permissions.request({ origins: ["https://*.anthropic.com/*"] });
if(granted){
document.getElementById("anthropic_api_permission").style.display = "none";
document.getElementById("integration_permission_ok").style.display = "block";
taLog.log("Anthropic API permission granted");
}else{
taLog.log("Anthropic API web permission denied");
}
});
document.getElementById("integration_permission_ok").addEventListener("click", async () => {
await messenger.tabs.remove((await messenger.tabs.getCurrent()).id); await messenger.tabs.remove((await messenger.tabs.getCurrent()).id);
}); });
} }

View file

@ -68,7 +68,7 @@ body {
background-color: #cfe9ff; background-color: #cfe9ff;
} }
#ask_chatgpt_web_perm{ #ask_chatgpt_web_perm, #ask_anthropic_api_perm{
display: none; display: none;
max-width: 20em; max-width: 20em;
background-color: red; background-color: red;

View file

@ -9,7 +9,10 @@
<body> <body>
<div id="ask_chatgpt_web_perm">__MSG_ask_chatgptweb_permission_1__ <div id="ask_chatgpt_web_perm">__MSG_ask_chatgptweb_permission_1__
<br>__MSG_ask_chatgptweb_permission_2_popup__ <br>__MSG_ask_integration_permission_2_popup__
</div>
<div id="ask_anthropic_api_perm">__MSG_ask_anthropic_api_permission_1__
<br>__MSG_ask_integration_permission_2_popup__
</div> </div>
<div id="mzta_search_banner"> <div id="mzta_search_banner">
<div id="_spacer_div">&nbsp;</div> <div id="_spacer_div">&nbsp;</div>

View file

@ -66,6 +66,16 @@ document.addEventListener('DOMContentLoaded', async () => {
}); });
} }
} }
if(prefs.connection_type === 'anthropic_api'){
let permission_anthropic = await browser.permissions.contains({ origins: ["https://*.anthropic.com/*"] });
if(permission_anthropic === false){
document.getElementById("mzta_search_banner").style.display = "none";
document.getElementById("ask_anthropic_api_perm").style.display = "block";
document.getElementById('ask_anthropic_api_perm').addEventListener('click', async () => {
await browser.tabs.create({ url: "../pages/onboarding/onboarding.html" });
});
}
}
}, { once: true }); }, { once: true });
async function searchPrompt(allPrompts, tabId, tabType){ async function searchPrompt(allPrompts, tabId, tabType){