-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
24 lines (20 loc) · 911 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.getElementById("saveBtn").addEventListener("click", () => {
const interval = parseInt(document.getElementById("intervalInput").value);
const enabled = document.getElementById("toggleQuotes").checked;
chrome.storage.sync.set({ interval, enabled }, () => {
document.getElementById("status").textContent = "Settings saved!";
setTimeout(() => {
document.getElementById("status").textContent = "";
}, 2000);
if (enabled) {
chrome.alarms.create("showQuote", { periodInMinutes: interval });
} else {
chrome.alarms.clear("showQuote");
}
});
});
// Load settings on popup open
chrome.storage.sync.get(["interval", "enabled"], (data) => {
document.getElementById("intervalInput").value = data.interval || 5;
document.getElementById("toggleQuotes").checked = data.enabled !== false;
});