diff --git a/CHANGELOG.md b/CHANGELOG.md index 0774cca..787a594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # CHANGELOG.md +## 8.2.0.1 (2024-08-12) +Fixes / changes: + - The position and size of the View Data popup is now stored, so that it opens at the same position and size as it was closed. + + ## 8.2.0.0 (2024-08-12) Features: - Tabs opened by SN Utils will now open next to the current tab, instead of at the end. diff --git a/background.js b/background.js index 0d4ca92..cb0c151 100644 --- a/background.js +++ b/background.js @@ -695,7 +695,32 @@ function viewData(message, cookieStoreId) { 'height': 900 } if (cookieStoreId) createObj.cookieStoreId = cookieStoreId; //only FireFox - chrome.windows.create(createObj); + + chrome.storage.local.get(['popupSize'], (result) => { + let popupSize = result.popupSize || {}; + createObj = { ...createObj, ...popupSize }; //merge the objects + chrome.windows.create(createObj, (newWindow) => { + + if (chrome.runtime.lastError) { + // Clear local storage if there was an error with bounds + chrome.storage.local.remove(['popupSize'], () => { + console.log('Local storage cleared due to window creation error.'); + }); + } + + chrome.windows.onBoundsChanged.addListener(window => { + if (window.id === newWindow.id && window.type === 'popup') { //save size and position of popup at close + let popupSize = { + left: window.left, + top: window.top, + width: window.width, + height: window.height + }; + chrome.storage.local.set({ popupSize: popupSize }); + }; + }); + }); + }); } else chrome.tabs.create(createObj); diff --git a/manifest.json b/manifest.json index de83ec9..00deb7e 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "short_name": "SN Utils", "description": "Productivity tools for ServiceNow. (Personal work, not affiliated to ServiceNow)", "author": "Arnoud Kooi / arnoudkooi.com", - "version": "8.2.0.0", + "version": "8.2.0.1", "manifest_version": 3, "permissions": [ "activeTab",