-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
33 lines (30 loc) · 930 Bytes
/
background.js
File metadata and controls
33 lines (30 loc) · 930 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
28
29
30
31
32
33
const isVkPage = url => /vk\.com/.test(url);
chrome.tabs.onActivated.addListener(function tabUpdateListener(_, status) {
chrome.tabs.query({
'active': true,
'lastFocusedWindow': true
}, tabs => {
updateIcon(isVkPage(tabs[0].url));
});
});
const COLOR_ICON = window.chrome.extension.getURL('/favicons/48x48.png');
const GRAY_ICON = window.chrome.extension.getURL('/favicons/48x48_gray.png');
function updateIcon(isVkPage) {
chrome.browserAction.setIcon({
path: isVkPage ? COLOR_ICON : GRAY_ICON
});
};
chrome.runtime.onMessage.addListener(evt => {
switch (evt.name) {
case 'download':
chrome.downloads.download({
url: evt.value.url,
filename: evt.value.filename,
conflictAction: "overwrite",
saveAs: false
})
break;
default:
break;
}
});