diff options
Diffstat (limited to 'examples/breeze-wiki.ts')
-rw-r--r-- | examples/breeze-wiki.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/breeze-wiki.ts b/examples/breeze-wiki.ts new file mode 100644 index 0000000..7e0d5d6 --- /dev/null +++ b/examples/breeze-wiki.ts @@ -0,0 +1,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'] +); |