published version in webstore
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
// Let Chrome open the panel when the toolbar icon is clicked
|
||||
// Guard: some Chromium variants may not expose sidePanel
|
||||
const hasSidePanel = !!chrome.sidePanel?.setOptions;
|
||||
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
chrome.sidePanel?.setPanelBehavior?.({ openPanelOnActionClick: true });
|
||||
if (hasSidePanel) chrome.sidePanel.setPanelBehavior?.({ openPanelOnActionClick: true });
|
||||
});
|
||||
|
||||
// If you still want to ensure the correct path on click, setOptions ONLY:
|
||||
@@ -19,7 +22,8 @@ chrome.action.onClicked.addListener(async () => {
|
||||
try { await chrome.scripting.executeScript({ target: { tabId: tab.id }, files: ['content.js'] }); } catch {}
|
||||
}
|
||||
|
||||
await chrome.sidePanel.setOptions({ tabId: tab.id, path: "panel.html" }); // Chrome opens it
|
||||
await chrome.sidePanel.setOptions({ tabId: tab.id, path: "panel.html" });
|
||||
try { await chrome.sidePanel.open({ tabId: tab.id }); } catch {}
|
||||
});
|
||||
|
||||
// Keyboard shortcut: we do open() here (this is a user gesture)
|
||||
|
||||
Reference in New Issue
Block a user