check if the user is logged in, otherwise show a message. fixes #7
This commit is contained in:
parent
a97217ba64
commit
ddd0475076
3 changed files with 26 additions and 10 deletions
|
|
@ -74,6 +74,11 @@
|
|||
"description": ""
|
||||
},
|
||||
|
||||
"chatgpt_user_not_logged_in": {
|
||||
"message": "You are not logged in to ChatGPT. Please log in with your credentials, close the ChatGPT window, and then repeat the action you attempted. You will remain logged in afterwards.",
|
||||
"description": ""
|
||||
},
|
||||
|
||||
"prefs_OptionText_chatgpt_win_text": {
|
||||
"message": "ChatGPT window dimensions",
|
||||
"description": ""
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@
|
|||
"description": ""
|
||||
},
|
||||
|
||||
"chatgpt_user_not_logged_in": {
|
||||
"message": "Non sei connesso a ChatGPT. Effettua l'accesso con le tue credenziali, chiudi la finestra di ChatGPT e poi ripeti l'azione che avevi tentato. Rimarrai connesso in seguito.",
|
||||
"description": ""
|
||||
},
|
||||
|
||||
"prefs_OptionText_chatgpt_win_text": {
|
||||
"message": "Dimensioni della finestra di ChatGPT",
|
||||
"description": ""
|
||||
|
|
|
|||
|
|
@ -146,20 +146,26 @@ function operation_done(){
|
|||
chatpgt_scrollToBottom();
|
||||
}
|
||||
|
||||
|
||||
function checkLoggedIn(){
|
||||
return !window.location.href.startsWith('https://chat.openai.com/auth/');
|
||||
}
|
||||
|
||||
// Nello script di contenuto
|
||||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.command === "chatgpt_send") {
|
||||
addCustomDiv(message.action,message.tabId);
|
||||
//console.log(message.prompt);
|
||||
(async () => {
|
||||
//await chatgpt.isLoaded();
|
||||
await chatgpt_sendMsg(message.prompt,'click');
|
||||
await chatgpt_isIdle();
|
||||
// console.log(response);
|
||||
operation_done();
|
||||
})();
|
||||
if(!checkLoggedIn()){
|
||||
// User not logged in
|
||||
alert(browser.i18n.getMessage("chatgpt_user_not_logged_in"));
|
||||
}else{
|
||||
addCustomDiv(message.action,message.tabId);
|
||||
(async () => {
|
||||
//await chatgpt.isLoaded();
|
||||
await chatgpt_sendMsg(message.prompt,'click');
|
||||
await chatgpt_isIdle();
|
||||
// console.log(response);
|
||||
operation_done();
|
||||
})();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue