-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup_extension_injection.js
42 lines (37 loc) · 1.25 KB
/
popup_extension_injection.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function() {
// register new on window resize event function,
// never overwrite old function
function popupExtensionAddResizeEvent(func) {
let oldResize = window.onresize;
window.onresize = function () {
func();
if (typeof oldResize === 'function') {
oldResize();
}
};
}
// save window size on window resize event
function popupExtensionSaveWindowSize() {
let storage = chrome.storage.local;
let storageKey = "_settings_v0.1_";
storage.get(storageKey, function(result) {
let mappings = result[storageKey];
// only save the popup window
if (mappings == null || mappings[window.location.host] == null) {
return
} else {
mappings[window.location.host] = {
"height": window.innerHeight,
"width": window.innerWidth
};
}
// save settings
let obj = Object();
obj[storageKey] = mappings;
storage.set(obj);
});
}
// register onclick handler
popupExtensionAddResizeEvent(popupExtensionSaveWindowSize);
// todo: hide scroll bar on popup
})();