iframe and Firefox fixes
This commit is contained in:
@@ -3,21 +3,24 @@ declare const browser: any;
|
||||
|
||||
// Detect browser type
|
||||
const isFirefox = typeof browser !== "undefined" && typeof browser.runtime !== "undefined";
|
||||
const browserAPI = isFirefox ? browser : chrome;
|
||||
|
||||
// Open side panel/sidebar when extension icon is clicked
|
||||
browserAPI.action.onClicked.addListener((tab: chrome.tabs.Tab) => {
|
||||
if (isFirefox) {
|
||||
// Firefox: Toggle the sidebar
|
||||
if (typeof browser !== "undefined" && browser.sidebarAction) {
|
||||
browser.sidebarAction.toggle();
|
||||
}
|
||||
} else {
|
||||
// Chrome: Open the side panel
|
||||
if (isFirefox) {
|
||||
// Firefox MV2: Use browserAction
|
||||
if (browser.browserAction) {
|
||||
browser.browserAction.onClicked.addListener(() => {
|
||||
if (browser.sidebarAction) {
|
||||
browser.sidebarAction.toggle();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Chrome MV3: Use action API
|
||||
chrome.action.onClicked.addListener((tab: chrome.tabs.Tab) => {
|
||||
if (tab.id && chrome.sidePanel) {
|
||||
chrome.sidePanel.open({ tabId: tab.id });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export {};
|
||||
|
||||
Reference in New Issue
Block a user