chatgpt win dimension checked against screen dimensions. fixes #16

This commit is contained in:
mic 2024-04-04 23:50:50 +02:00
parent ddd0475076
commit b5e987f961

View file

@ -74,6 +74,7 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => {
async function openChatGPT(promptText,action,curr_tabId){
let prefs = await browser.storage.sync.get(prefs_default);
prefs = checkScreenDimensions(prefs);
return browser.windows.create({
url: "https://chat.openai.com",
type: "popup",
@ -93,3 +94,13 @@ async function openChatGPT(promptText,action,curr_tabId){
});
});
}
function checkScreenDimensions(prefs){
let width = window.screen.width;
let height = window.screen.height;
if(prefs.chatgpt_win_height > height) prefs.chatgpt_win_height = height - 50;
if(prefs.chatgpt_win_width > width) prefs.chatgpt_win_width = width - 50;
return prefs;
}