-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
27 lines (24 loc) · 918 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
const blockList = [
"https://es.pornhub.com",
"https://www.pornhub.com",
"https://xvideos.com",
"https://redtube.com",
"https://es.redtube.com",
"https://chaturbate.com",
"https://xhamster.com"
];
chrome.runtime.onInstalled.addListener(function() {
chrome.webNavigation.onCompleted.addListener(redirectIfNecessary);
});
chrome.webNaviggation.onCompleted.addListener(redirectIfNecessary);
browser.runtime.onInstalled.addListener(function() {
browser.webNavigation.onCompleted.addListener(redirectIfNecessary);
});
browser.webNavigation.onCompleted.addListener(redirectIfNecessary);
function redirectIfNecessary(details) {
// Check if the URL matches the desired page
if (blockList.find(blocked => details.url.includes(blocked)) != undefined) {
// Redirect to another page
chrome.tabs.update(details.tabId, {url: "https://fcanfran.github.io/marato-blocker/"});
}
}