blob: 7e0d5d617cc70b48eacb2ce46808360a54369f42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// This example redirects all fandom pages to breezewiki (or for minecraft.fandom.com, the minecraft wiki)
import type Browser from 'webextension-polyfill';
declare const browser: typeof Browser;
// ^ above 2 lines are optional, and only useful to allow the examples directory to not complain. The extension's monaco already defines the type of the browser global.
browser.webRequest.onBeforeRequest.addListener(
(requestDetails) => {
const url = new URL(requestDetails.url);
url.host =
url.hostname === 'minecraft.fandom.com'
? 'minecraft.wiki'
: url.hostname.replace('fandom.com', 'breezewiki.com');
return {
redirectUrl: url.href,
};
},
{ urls: ['https://fandom.com/*', 'https://*.fandom.com/*'] },
['blocking']
);
|