Add ChatGPT web permission handling as optional in onboarding and popup. See #293
This commit is contained in:
parent
2243af07d1
commit
e0736c4a6c
8 changed files with 133 additions and 3 deletions
|
|
@ -1278,5 +1278,21 @@
|
||||||
"CORS_give_allurls_perm": {
|
"CORS_give_allurls_perm": {
|
||||||
"message": "Give \"all URLs\" permission",
|
"message": "Give \"all URLs\" permission",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
},
|
||||||
|
"ask_chatgptweb_permission_1": {
|
||||||
|
"message": "To use the ChatGPT Web Integration, you need to grant the required permission.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"ask_chatgptweb_permission_2_popup": {
|
||||||
|
"message": "Click here to open a new tab and follow the instructions.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"ask_chatgptweb_permission_2": {
|
||||||
|
"message": "Click here to proceed.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"ask_chatgptweb_permission_ok": {
|
||||||
|
"message": "Permission granted. You can close this tab and return to the main window.",
|
||||||
|
"description": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,13 +31,13 @@
|
||||||
"activeTab",
|
"activeTab",
|
||||||
"accountsRead",
|
"accountsRead",
|
||||||
"downloads",
|
"downloads",
|
||||||
"messagesTagsList",
|
"messagesTagsList"
|
||||||
"https://*.chatgpt.com/*"
|
|
||||||
],
|
],
|
||||||
"optional_permissions": [
|
"optional_permissions": [
|
||||||
"messagesTags",
|
"messagesTags",
|
||||||
"messagesUpdate",
|
"messagesUpdate",
|
||||||
"messagesMove",
|
"messagesMove",
|
||||||
|
"https://*.chatgpt.com/*",
|
||||||
"<all_urls>"
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
|
|
|
||||||
|
|
@ -181,3 +181,39 @@ h2 {
|
||||||
.section .button:active {
|
.section .button:active {
|
||||||
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 {
|
||||||
|
display: none;
|
||||||
|
background-color: red;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin: 10px 0;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s ease, transform 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chatgpt_web_permission:hover {
|
||||||
|
background-color: darkred;
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
#chatgpt_web_permission_ok {
|
||||||
|
display: none;
|
||||||
|
background-color: green;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin: 10px 0;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#chatgpt_web_permission_ok:hover {
|
||||||
|
background-color: darkgreen;
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<div id="chatgpt_web_permission">__MSG_ask_chatgptweb_permission_1__
|
||||||
|
<br>__MSG_ask_chatgptweb_permission_2__
|
||||||
|
</div>
|
||||||
|
<div id="chatgpt_web_permission_ok">__MSG_ask_chatgptweb_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>
|
||||||
|
|
@ -82,5 +86,7 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="onboarding.js" type="module"></script>
|
||||||
|
<script src="../../js/mzta-i18n.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
46
pages/onboarding/onboarding.js
Normal file
46
pages/onboarding/onboarding.js
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* ThunderAI [https://micz.it/thunderbird-addon-thunderai/]
|
||||||
|
* Copyright (C) 2024 - 2025 Mic (m@micz.it)
|
||||||
|
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { taLogger } from '../../js/mzta-logger.js';
|
||||||
|
|
||||||
|
let taLog = null;
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
let prefs = await browser.storage.sync.get({do_debug: false, connection_type: 'chatgpt_web'});
|
||||||
|
taLog = new taLogger("mzta-popup",prefs.do_debug);
|
||||||
|
i18n.updateDocument();
|
||||||
|
if(prefs.connection_type === 'chatgpt_web'){
|
||||||
|
let permission_chatgpt = await messenger.permissions.contains({ origins: ["https://*.chatgpt.com/*"] });
|
||||||
|
if(permission_chatgpt === false){
|
||||||
|
document.getElementById("chatgpt_web_permission").style.display = "block";
|
||||||
|
document.getElementById("chatgpt_web_permission").addEventListener("click", async () => {
|
||||||
|
let granted = await messenger.permissions.request({ origins: ["https://*.chatgpt.com/*"] });
|
||||||
|
if(granted){
|
||||||
|
document.getElementById("chatgpt_web_permission").style.display = "none";
|
||||||
|
document.getElementById("chatgpt_web_permission_ok").style.display = "block";
|
||||||
|
taLog.log("ChatGPT web permission granted");
|
||||||
|
}else{
|
||||||
|
taLog.log("ChatGPT web permission denied");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.getElementById("chatgpt_web_permission_ok").addEventListener("click", async () => {
|
||||||
|
await messenger.tabs.remove((await messenger.tabs.getCurrent()).id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, { once: true });
|
||||||
|
|
@ -68,7 +68,19 @@ body {
|
||||||
background-color: #cfe9ff;
|
background-color: #cfe9ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ask_chatgpt_web_perm{
|
||||||
|
display: none;
|
||||||
|
max-width: 20em;
|
||||||
|
background-color: red;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
|
|
||||||
body{
|
body{
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div id="ask_chatgpt_web_perm">__MSG_ask_chatgptweb_permission_1__
|
||||||
|
<br>__MSG_ask_chatgptweb_permission_2_popup__
|
||||||
|
</div>
|
||||||
<div id="mzta_search_banner">
|
<div id="mzta_search_banner">
|
||||||
<div id="_spacer_div"> </div>
|
<div id="_spacer_div"> </div>
|
||||||
<div id="mzta_sending_prompt"><img src="mzta-loading.svg" title="__MSG_SendingPrompt__"></div>
|
<div id="mzta_sending_prompt"><img src="mzta-loading.svg" title="__MSG_SendingPrompt__"></div>
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,17 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
get_calendar_event = prefs.get_calendar_event;
|
get_calendar_event = prefs.get_calendar_event;
|
||||||
searchPrompt(active_prompts, tabId, tabType);
|
searchPrompt(active_prompts, tabId, tabType);
|
||||||
i18n.updateDocument();
|
i18n.updateDocument();
|
||||||
|
|
||||||
|
if(prefs.connection_type === 'chatgpt_web'){
|
||||||
|
let permission_chatgpt = await browser.permissions.contains({ origins: ["https://*.chatgpt.com/*"] });
|
||||||
|
if(permission_chatgpt === false){
|
||||||
|
document.getElementById("mzta_search_banner").style.display = "none";
|
||||||
|
document.getElementById("ask_chatgpt_web_perm").style.display = "block";
|
||||||
|
document.getElementById('ask_chatgpt_web_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){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue