-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
22 lines (20 loc) · 918 Bytes
/
options.js
File metadata and controls
22 lines (20 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Load current settings
browser.storage.local.get('saveMethod').then((result) => {
const method = result.saveMethod || 'editor';
document.getElementById(method + 'Option').checked = true;
document.querySelector(`[onclick="selectOption('${method}')"]`).classList.add('selected');
});
function selectOption(method) {
// Update UI
document.querySelectorAll('.option').forEach(opt => opt.classList.remove('selected'));
document.querySelector(`[onclick="selectOption('${method}')"]`).classList.add('selected');
document.getElementById(method + 'Option').checked = true;
}
function saveOptions() {
const selected = document.querySelector('input[name="saveMethod"]:checked').value;
browser.storage.local.set({ saveMethod: selected }).then(() => {
const status = document.getElementById('status');
status.style.display = 'block';
setTimeout(() => status.style.display = 'none', 2000);
});
}