-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
22 lines (19 loc) · 743 Bytes
/
background.js
File metadata and controls
22 lines (19 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
chrome.sidePanel
.setPanelBehavior({ openPanelOnActionClick: true })
.catch((error) => console.error(error));
chrome.runtime.onSuspend.addListener(() => {
chrome.storage.local.get(["startTime", "isRunning", "logs"], (data) => {
if (data.isRunning && data.startTime) {
const durationMs = Date.now() - data.startTime;
const hours = durationMs / 3600000;
const today = new Date().toISOString().split('T')[0];
const logs = data.logs || [];
logs.push({ id: Date.now(), date: today, hours: hours });
chrome.storage.local.set({
logs: logs,
isRunning: false,
startTime: null
});
}
});
});