forked from corollari/aws-color-region-navbar-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
25 lines (24 loc) · 728 Bytes
/
popup.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
function updateColor(region) {
return function (event) {
const color = event.target.value;
chrome.storage.local.set({
[region]: color
})
}
}
document.querySelectorAll('input').forEach(input => {
const cell = input.parentElement.parentElement;
const region = cell.firstElementChild.innerText;
input.addEventListener('change', updateColor(region));
if(window.browser !== undefined){
// On Firefox
// Workaround for a bug in their color picker
input.type="text";
}
chrome.storage.local.get(region, (results) => {
let color = results[region];
if (color !== undefined) {
input.value = color;
}
});
})