-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
55 lines (50 loc) · 1.83 KB
/
options.js
File metadata and controls
55 lines (50 loc) · 1.83 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
// options.js
// Browser API polyfill - ensure browser API is available
if (typeof browser === 'undefined' && typeof chrome !== 'undefined') {
var browser = chrome;
}
document.addEventListener('DOMContentLoaded', function() {
const enablePopLinks = document.getElementById('enablePopLinks');
const showAnimations = document.getElementById('showAnimations');
const modalWidth = document.getElementById('modalWidth');
const saveBtn = document.getElementById('saveBtn');
const statusDiv = document.getElementById('status');
// Load saved options
browser.storage.sync.get({
popLinksEnabled: true,
animationsEnabled: true,
modalWidth: '85'
}).then(function(items) {
enablePopLinks.checked = items.popLinksEnabled;
showAnimations.checked = items.animationsEnabled;
// Set default to 85 if no value is stored
modalWidth.value = items.modalWidth || '85';
}).catch(function(error) {
console.error('Error loading options:', error);
});
// Save options
saveBtn.addEventListener('click', function() {
browser.storage.sync.set({
popLinksEnabled: enablePopLinks.checked,
animationsEnabled: showAnimations.checked,
modalWidth: modalWidth.value
}).then(function() {
// Show success message
statusDiv.textContent = 'Settings saved successfully!';
statusDiv.className = 'status success';
statusDiv.style.display = 'block';
// Hide message after 3 seconds
setTimeout(function() {
statusDiv.style.display = 'none';
}, 3000);
}).catch(function(error) {
console.error('Error saving options:', error);
statusDiv.textContent = 'Error saving settings';
statusDiv.className = 'status error';
statusDiv.style.display = 'block';
setTimeout(function() {
statusDiv.style.display = 'none';
}, 3000);
});
});
});