-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
24 lines (21 loc) · 935 Bytes
/
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
document.addEventListener('DOMContentLoaded', function() {
const statusElement = document.getElementById('status');
const toggleButton = document.getElementById('toggleFilter');
chrome.storage.sync.get('filterEnabled', function(data) {
const isEnabled = data.filterEnabled !== false; // Default to true if not set
updateStatus(isEnabled);
});
toggleButton.addEventListener('click', function() {
chrome.storage.sync.get('filterEnabled', function(data) {
const currentState = data.filterEnabled !== false;
const newState = !currentState;
chrome.storage.sync.set({filterEnabled: newState}, function() {
updateStatus(newState);
});
});
});
function updateStatus(isEnabled) {
statusElement.textContent = isEnabled ? 'Active' : 'Inactive';
toggleButton.textContent = isEnabled ? 'Disable Filter' : 'Enable Filter';
}
});