Skip to content

Commit

Permalink
Store view data popup position
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoudkooi committed Aug 12, 2024
1 parent a010c1a commit 8a83f84
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
27 changes: 26 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8a83f84

Please sign in to comment.