-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
27 lines (24 loc) · 748 Bytes
/
background.js
File metadata and controls
27 lines (24 loc) · 748 Bytes
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
chrome.runtime.onInstalled.addListener((details) => {
// Show welcome page
if (details.reason === "install") {
chrome.runtime.openOptionsPage();
}
});
chrome.runtime.onMessage.addListener((message) => {
if (message.type === "STAGE_COMPLETED") {
const { names, stage } = message;
const nameList =
names.length === 1
? names[0]
: names.slice(0, -1).join(", ") +
" & " +
names[names.length - 1];
chrome.notifications.create({
type: "basic",
iconUrl: "icons/icon-48.png",
title: `${stage} Completed!`,
message: `${nameList}`,
priority: 2,
});
}
});