-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
23 lines (19 loc) · 1022 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
browser.runtime.onInstalled.addListener(function() {
console.log("Search Engine Blocker extension installed.");
const defaultBlockedWebsites = ['amazon', 'temu', 'aliexpress'];
// Set the default list of blocked websites in storage
browser.storage.local.set({blockedWebsites: defaultBlockedWebsites}, function() {
console.log("Default blocked websites list has been set.");
});
});
// Listening for changes in storage
browser.storage.onChanged.addListener(function(changes, namespace) {
if (namespace === 'sync' && changes.blockedWebsites) {
console.log('Blocked websites updated:', changes.blockedWebsites.newValue);
// You may want to update your content scripts or other parts of the extension
// Send a message to content scripts to update their behavior
browser.tabs.query({ active: true, currentWindow: true }, function(tabs) {
browser.tabs.sendMessage(tabs[0].id, { action: 'updateBlockedWebsites', blockedWebsites: changes.blockedWebsites.newValue });
});
}
});