-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.js
More file actions
32 lines (27 loc) · 1.07 KB
/
background.js
File metadata and controls
32 lines (27 loc) · 1.07 KB
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
32
var activeTimers = []
chrome.storage.local.set({
"activeTimers": activeTimers
}, () => {});
chrome.runtime.onMessage.addListener(
function msgHandler(msg) {
let timeout = setTimeout(() => {
chrome.tabs.remove(msg.tabid, () => {});
activeTimers = activeTimers.filter((obj) => {
obj.timeoutid != timeout
});
chrome.storage.local.set({
"activeTimers": activeTimers
}, () => {});
}, msg.time);
let d = new Date();
let timerobj = {
tabid: msg.tabid,
timeoutid: timeout,
timestr: (new Date(d.getTime() + msg.time)).toString()
}
activeTimers.push(timerobj);
chrome.storage.local.set({
"activeTimers": activeTimers
}, () => {});
return true;
});