forked from iMAboud/iMSteam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
32 lines (28 loc) · 871 Bytes
/
background.js
File metadata and controls
32 lines (28 loc) · 871 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
29
30
31
32
chrome.runtime.onInstalled.addListener((details) => {
if (details.reason === "install") {
async function getDefaultSites() {
try {
const response = await fetch('default_sites.json');
if (!response.ok) {
throw new Error("JSON file not found");
}
const data = await response.json();
return data.websites.map(website => ({
...website,
enabled: true
}));
} catch (error) {
console.error("Error Fetching Data", error);
return [];
}
}
chrome.storage.local.set({ sites: getDefaultSites()}, () => {
console.log('Default sites initialized');
});
}
});
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "openLink" && message.url) {
chrome.tabs.create({ url: message.url });
}
});