-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
33 lines (29 loc) · 906 Bytes
/
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
var blockedPages;
var redirectPage;
chrome.storage.managed.get('RestrictionsEnabled', (data) => {
if (data.RestrictionsEnabled) {
chrome.action.setPopup({popup: 'popup.html'});
} else {
chrome.action.setPopup({popup: 'popup_idle.html'});
}
});
chrome.storage.managed.get('BlockedPages', (data) => {
blockedPages = data.BlockedPages;
}
);
chrome.storage.managed.get('RedirectEnabled', (data) => {
if (data.RedirectEnabled) {
chrome.storage.managed.get('RedirectTo', (data) => {
redirectPage = data.RedirectTo;
});
} else {
redirectPage = "/block.html";
}
});
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if (blockedPages.contains(details.url))
return {cancel: true, redirectUrl: redirectPage};
},
["blocking"]
);