-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackground.js
39 lines (37 loc) · 993 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
28
29
30
31
32
33
34
35
36
37
38
39
chrome.action.onClicked.addListener(async (tab) => {
// Check if side panel API is available.
const hasSidePanel = 'sidePanel' in chrome;
const openAsPopup = () => {
chrome.windows.create({
url: 'popup.html',
type: 'popup',
width: 400,
height: 600
});
};
if (tab.url.includes('multipass.wizzair.com')) {
if (hasSidePanel) {
await chrome.sidePanel.open({ windowId: tab.windowId });
await chrome.sidePanel.setOptions({
enabled: true,
path: 'popup.html'
});
} else {
openAsPopup();
}
} else {
chrome.tabs.create({
url: "https://multipass.wizzair.com/w6/subscriptions/spa/private-page/wallets"
}, async (newTab) => {
if (hasSidePanel) {
await chrome.sidePanel.open({ windowId: newTab.windowId });
await chrome.sidePanel.setOptions({
enabled: true,
path: 'popup.html'
});
} else {
openAsPopup();
}
});
}
});