-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
31 lines (29 loc) · 1.09 KB
/
background.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
30
31
chrome.alarms.create("Timero Extension",{
periodInMinutes: 1/60
})
chrome.alarms.onAlarm.addListener((alarm) => {
if(alarm.name = "Time Extension") {
chrome.storage.local.get(["timer", "isRunning", "timeOption"], (result) => {
if(result.isRunning) {
let timer = result.timer + 1
let isRunning = true
if(timer === 60 * result.timeOption) {
this.registration.showNotification("Time Extension", {
body: `${result.timeOption} minutes has passed !`,
icon: "clock.png"
})
timer = 0
isRunning=false
}
chrome.storage.local.set({timer, isRunning})
}
})
}
})
chrome.storage.local.get(["timer", "isRunning", "timeOption"], (result) => {
chrome.storage.local.set({
timer: "timer" in result ? result.timer : 0,
timeOption: "timeOption" in result ? result.timeOption : 25,
isRunning: "isRunning" in result ? result.isRunning : false
})
})