-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
41 lines (36 loc) · 1.17 KB
/
Copy pathpopup.js
File metadata and controls
41 lines (36 loc) · 1.17 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
/**
* Popup script - Handle extension settings
*/
// Load current settings
document.addEventListener('DOMContentLoaded', () => {
const checkbox = document.getElementById('enabledCheckbox');
const status = document.getElementById('status');
const optionsLink = document.getElementById('optionsLink');
// Load saved setting
chrome.storage.sync.get(['enabled'], (result) => {
const isEnabled = result.enabled !== false; // Default to true
checkbox.checked = isEnabled;
updateStatus(isEnabled);
});
// Save setting when changed
checkbox.addEventListener('change', () => {
const isEnabled = checkbox.checked;
chrome.storage.sync.set({ enabled: isEnabled }, () => {
updateStatus(isEnabled);
});
});
// Open options page when link is clicked
optionsLink.addEventListener('click', (e) => {
e.preventDefault();
chrome.runtime.openOptionsPage();
});
function updateStatus(isEnabled) {
if (isEnabled) {
status.textContent = '✓ Protection Active';
status.className = 'status enabled';
} else {
status.textContent = '✗ Protection Disabled';
status.className = 'status disabled';
}
}
});