jameschets
jameschets
PD🧩 Plasmo Developers
Created by jameschets on 7/16/2024 in #👟framework
Get tab id in side panel for both Chrome and Firefox?
I've been getting the tab id by running this code in the side panel when it's loaded:
const tabIdRes = await chrome.tabs.query({
active: true,
currentWindow: true
});
const tabIdRes = await chrome.tabs.query({
active: true,
currentWindow: true
});
This works for Chrome but I also need to support Firefox. This works on Firefox:
await browser.tabs.query
await browser.tabs.query
AI suggested I create this pollyfil, which I think would work. However is there a solution built into Plasmo?
if (typeof browser === "undefined") {
var browser = chrome;
}

export default browser;
if (typeof browser === "undefined") {
var browser = chrome;
}

export default browser;
1 replies