-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
30 lines (26 loc) · 827 Bytes
/
sw.js
File metadata and controls
30 lines (26 loc) · 827 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
/**
* Handle messages from the extension
*/
function onMessage(message) {
message.type = "Move-Group-Window";
const tabId = message.tabId;
const groupId = message.groupId;
chrome.windows.create({ focused: true }, function (newWindow) {
chrome.tabGroups.move(groupId, { index: 0, windowId: newWindow.id }, function () {
chrome.tabs.update(tabId, { active: true }, function () {
chrome.tabs.remove(newWindow.tabs[0].id);
});
});
});
}
/**
* Handle extension installation
*/
function onInstalled(details) {
chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true });
if (details && details.reason === "install") {
chrome.tabs.create({ url: "guide.html" });
}
}
chrome.runtime.onInstalled.addListener(onInstalled);
chrome.runtime.onMessage.addListener(onMessage);