-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
26 lines (22 loc) · 889 Bytes
/
background.js
File metadata and controls
26 lines (22 loc) · 889 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
'use strict';
(() => {
const isChrome = typeof chrome !== 'undefined' && !!chrome.sidePanel;
const isFirefox = !isChrome && typeof browser !== 'undefined' && !!browser.sidebarAction;
if (isChrome) {
const enableActionToggle = () => {
chrome.sidePanel
.setPanelBehavior({ openPanelOnActionClick: true })
.catch((error) => console.error('Failed to enable side-panel action toggle:', error));
};
chrome.runtime.onInstalled.addListener(enableActionToggle);
chrome.runtime.onStartup.addListener(enableActionToggle);
} else if (isFirefox) {
const toggleSidebar = () => {
browser.sidebarAction.toggle().catch((error) => console.error('Unable to toggle sidebar:', error));
};
try {
browser.action.onClicked.removeListener(toggleSidebar);
} catch (_) {}
browser.action.onClicked.addListener(toggleSidebar);
}
})();