blob: 5806d4cf0d4c16c5f8b41a4f52a7de648bba8bbe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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']
);
|