diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 73eb7d95..5a15b53f 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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": "" diff --git a/_locales/it/messages.json b/_locales/it/messages.json index b5c7c5c0..d6841de7 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -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": "" diff --git a/js/mzta-chatgpt.js b/js/mzta-chatgpt.js index f70bc071..17b4720a 100644 --- a/js/mzta-chatgpt.js +++ b/js/mzta-chatgpt.js @@ -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(); + })(); + } } });