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;
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server