forked from mubaidr/vite-vue3-browser-extension-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
31 lines (26 loc) · 978 Bytes
/
index.ts
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
chrome.runtime.onInstalled.addListener(async (opt) => {
// Check if reason is install or update. Eg: opt.reason === 'install' // If extension is installed.
// opt.reason === 'update' // If extension is updated.
if (opt.reason === 'install') {
await chrome.storage.local.clear()
chrome.tabs.create({
active: true,
// Open the setup page and append `?type=install` to the URL so frontend
// can know if we need to show the install page or update page.
url: chrome.runtime.getURL('./src/setup/index.html?type=install'),
})
}
if (opt.reason === 'update') {
chrome.tabs.create({
active: true,
url: chrome.runtime.getURL('./src/setup/index.html?type=update'),
})
}
})
console.log('hello world from background')
self.onerror = function (message, source, lineno, colno, error) {
console.info(
`Error: ${message}\nSource: ${source}\nLine: ${lineno}\nColumn: ${colno}\nError object: ${error}`
)
}
export {}