-
Notifications
You must be signed in to change notification settings - Fork 22
/
popup.js
29 lines (25 loc) · 1.05 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', () => {
const toggleAdBlockerInput = document.getElementById('toggle-adblocker');
const statusText = document.getElementById('status');
function toggleAdBlocker(enabled) {
chrome.runtime.sendMessage({ action: "toggleBlocking", enabled: enabled }, (response) => {
if (response.success) {
console.log('Ad blocker state updated:', enabled);
chrome.storage.local.set({ adBlockerEnabled: enabled });
updateUI(enabled);
}
});
}
function updateUI(enabled) {
toggleAdBlockerInput.checked = enabled;
statusText.textContent = enabled ? 'Blocker is ON' : 'Blocker is OFF';
}
toggleAdBlockerInput.addEventListener('change', () => {
const isEnabled = toggleAdBlockerInput.checked;
toggleAdBlocker(isEnabled);
});
chrome.storage.local.get('adBlockerEnabled', (data) => {
const adBlockerEnabled = data.adBlockerEnabled || false;
updateUI(adBlockerEnabled);
});
});