forked from Sulagna-Dutta-Roy/GGExtensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
27 lines (24 loc) · 916 Bytes
/
options.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
document.addEventListener('DOMContentLoaded', () => {
restoreOptions();
document.getElementById('optionsForm').addEventListener('submit', saveOptions);
});
function saveOptions(event) {
event.preventDefault();
const fontSize = document.getElementById('fontSize').value;
const bgColor = document.getElementById('bgColor').value;
const contrast = document.getElementById('contrast').value;
chrome.storage.sync.set({
fontSize,
bgColor,
contrast
}, () => {
console.log('Options saved');
});
}
function restoreOptions() {
chrome.storage.sync.get(['fontSize', 'bgColor', 'contrast'], (items) => {
document.getElementById('fontSize').value = items.fontSize || 'medium';
document.getElementById('bgColor').value = items.bgColor || '#ffffff';
document.getElementById('contrast').value = items.contrast || 'normal';
});
}