import type { Browser } from 'webextension-polyfill'; declare const browser: Browser; browser.webRequest.onBeforeRequest.addListener( (requestDetails) => { const url = new URL(requestDetails.url); if (url.searchParams.has('open-tab')) { url.searchParams.delete('open-tab'); (async () => { const oldTab = await browser.tabs.get(requestDetails.tabId) console.warn(url.href); await browser.windows.create({ type: 'popup', width: 768, height: 512, url: [url.href] }); await browser.tabs.remove(oldTab.id!) })() return { cancel: true }; } }, { urls: ['http://127.0.0.1/*', 'http://localhost/*'] }, ['blocking'] );