-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoptions.js
32 lines (29 loc) · 1.09 KB
/
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
28
29
30
31
document.addEventListener('DOMContentLoaded', () => {
const configForm = document.getElementById('configForm');
const saveButton = document.getElementById('saveButton');
// Load saved configuration from chrome storage
chrome.storage.local.get('config', (data) => {
if (data.config) {
const selectedRadio = configForm.querySelector(`input[value="${data.config}"]`);
if (selectedRadio) {
selectedRadio.checked = true;
}
}
else {
const selectedRadio = configForm.querySelector(`input[value="plain"]`);
if (selectedRadio) {
selectedRadio.checked = true;
}
}
});
// Save configuration to chrome storage
saveButton.addEventListener('click', () => {
const selectedConfig = configForm.config.value;
chrome.storage.local.set({ config: selectedConfig }, () => {
document.getElementById("sib_saved").innerText = "Tone saved!";
setTimeout(() => {
window.close();
}, "600");
});
});
});