// 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'] );