-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
21 lines (19 loc) · 799 Bytes
/
Copy pathpopup.js
File metadata and controls
21 lines (19 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
document.addEventListener("DOMContentLoaded", () => {
const toggleButton = document.getElementById("toggleButton");
// Actualizar el estado del botón al abrir el popup
chrome.storage.local.get("adBlockEnabled", (data) => {
toggleButton.textContent = data.adBlockEnabled
? "Desactivar Bloqueo de Anuncios"
: "Activar Bloqueo de Anuncios";
});
// Alternar estado al hacer clic en el botón
toggleButton.addEventListener("click", () => {
chrome.storage.local.get("adBlockEnabled", (data) => {
const isEnabled = !data.adBlockEnabled;
chrome.runtime.sendMessage({ action: "toggleAdBlock", enabled: isEnabled });
toggleButton.textContent = isEnabled
? "Desactivar Bloqueo de Anuncios"
: "Activar Bloqueo de Anuncios";
});
});
});