-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
29 lines (25 loc) · 1.01 KB
/
popup.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
document.addEventListener('DOMContentLoaded', function() {
const toggleBtn = document.getElementById('toggleBtn');
const extensionState = document.getElementById('extensionState');
chrome.storage.sync.get('extensionEnabled', function(data) {
const enabled = data.extensionEnabled !== false; // Default to true if not set
if (enabled) {
toggleBtn.textContent = 'Toggle Off';
extensionState.textContent = 'State: Enabled';
} else {
toggleBtn.textContent = 'Toggle On';
extensionState.textContent = 'State: Disabled';
}
toggleBtn.addEventListener('click', function() {
const newEnabledState = !enabled;
chrome.storage.sync.set({ extensionEnabled: newEnabledState });
if (newEnabledState) {
toggleBtn.textContent = 'Toggle Off';
extensionState.textContent = 'State: Enabled';
} else {
toggleBtn.textContent = 'Toggle On';
extensionState.textContent = 'State: Disabled';
}
});
});
});