-
Notifications
You must be signed in to change notification settings - Fork 0
/
bg.js
41 lines (31 loc) · 1.47 KB
/
bg.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
41
if (config.get('currVersion') < 10000) {
// Because we introduced lastVersion in 9001
if (config.get('currVersion') == 10000)
config.set('lastVersion', 10000);
config.set('currVersion', 10000);
config.set('currDisplayVersion', "1.0.0");
}
if (isPasswordGood() !== PASSWORD_STATUS.okay) {
showOptionsPage();
}
chrome.tabs.onUpdated.addListener(function (tabid, changeinfo, tab) {
if (config.get('showPageActionButton')) {
chrome.tabs.sendMessage(tab.id, {type: "get sources for top window"}, function (response) {
if (response.globalAllowAll)
chrome.browserAction.setIcon({path: "img/disabled.png", tabId: tab.id});
else if (response.pageSourcesAllowedLength > 0)
chrome.browserAction.setIcon({path: "img/allowed.png", tabId: tab.id});
else
chrome.browserAction.setIcon({path: "img/forbidden.png", tabId: tab.id});
if (response.pageSourcesTempAllowedLength > 0)
chrome.browserAction.setIcon({path: "img/temp.png", tabId: tab.id});
// show badge
const tabBlockedCount = response.pageSourcesForbiddenLength;
chrome.browserAction.setBadgeBackgroundColor({ color: [51, 0, 51, 230] });
chrome.browserAction.setBadgeText({text: tabBlockedCount + '', tabId: tab.id});
});
}
else {
chrome.browserAction.hide(tab.id);
}
});