-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
25 lines (21 loc) · 753 Bytes
/
background.js
File metadata and controls
25 lines (21 loc) · 753 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
import { setupContextMenus, handleMenuClick } from './context-menus.js';
import { setupMessageListeners } from './messaging.js';
chrome.runtime.onInstalled.addListener(() => {
setupContextMenus();
});
// Handle commands
chrome.commands.onCommand.addListener((command) => {
if (command === 'open-side-panel') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs[0]) {
chrome.sidePanel.open({ tabId: tabs[0].id });
// Store the tabId for the side panel
chrome.storage.session.set({ sidePanelTabId: tabs[0].id });
}
});
}
});
// Setup message listeners
setupMessageListeners();
// Setup context menu click listener
chrome.contextMenus.onClicked.addListener(handleMenuClick);