-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
22 lines (19 loc) · 818 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
document.addEventListener("DOMContentLoaded", () => {
const adCountElem = document.getElementById("adCount");
const errorCountElem = document.getElementById("errorCount");
const resetButton = document.getElementById("reset");
const updateStats = () => {
chrome.runtime.sendMessage({ action: "getStats" }, (data) => {
if (chrome.runtime.lastError) {
console.error("Error retrieving stats:", chrome.runtime.lastError);
return;
}
adCountElem.textContent = data.adBlockCount || 0;
errorCountElem.textContent = data.errorCount || 0;
});
};
resetButton.addEventListener("click", () => {
chrome.storage.local.set({ adBlockCount: 0, errorCount: 0 }, updateStats);
});
updateStats();
});