-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackground.js
40 lines (39 loc) · 1.43 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
32
33
34
35
36
37
38
39
40
chrome.runtime.onInstalled.addListener(() => {
chrome.runtime.onMessage.addListener(
async (request, sender, sendResponse) => {
// registering a active client and showing it in the icon
if (request.action != undefined) {
if (request.action == "register") {
chrome.action.setBadgeText(
{ text: "ON", tabId: sender.tab.id },
(r) => {
//console.log(r);
}
);
}
return false;
}
if (request.schema != undefined) {
if (request.scheme == "light") {
chrome.action.setIcon({
path: {
128: "icon/icon128_light.png",
48: "icon/icon48_light.png",
16: "icon/icon16_light.png",
},
});
} else if (request.schema == "dark") {
chrome.action.setIcon({
path: {
128: "icon/icon128_dark.png",
48: "icon/icon48_dark.png",
16: "icon/icon16_dark.png",
},
});
}
return false;
}
return false;
}
);
});