-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
28 lines (23 loc) · 840 Bytes
/
background.js
File metadata and controls
28 lines (23 loc) · 840 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
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status !== "complete" || !tab.url) return;
chrome.storage.sync.get("allSites", (data) => {
let blockedSites = data.allSites || [];
if (!Array.isArray(blockedSites) || blockedSites.length === 0) {
console.log("Список пуст, ничего не блокируем");
return;
}
const url = tab.url.toLowerCase();
const shouldBlock = blockedSites.some(site =>
site && typeof site === "string" && url.includes(site.toLowerCase())
);
if (shouldBlock) {
console.log("БЛОКИРУЕМ САЙТ:", url);
chrome.scripting.executeScript({
target: { tabId: tabId },
files: ["content.js"]
});
} else {
console.log("Сайт разрешён:", url);
}
});
});