aboutsummaryrefslogtreecommitdiffstats
path: root/examples/imgur-redirect.ts
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-02-24 01:09:00 +0100
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-02-24 01:09:00 +0100
commit54a41f2431c3d60f5845a15447f13413299e41f2 (patch)
treef9395bb35ae4223a8ee944299ce430168de4d657 /examples/imgur-redirect.ts
downloadhttptool-54a41f2431c3d60f5845a15447f13413299e41f2.tar.gz
httptool-54a41f2431c3d60f5845a15447f13413299e41f2.tar.bz2
httptool-54a41f2431c3d60f5845a15447f13413299e41f2.tar.lz
httptool-54a41f2431c3d60f5845a15447f13413299e41f2.zip

feat: da extension

Diffstat (limited to 'examples/imgur-redirect.ts')
-rw-r--r--examples/imgur-redirect.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/imgur-redirect.ts b/examples/imgur-redirect.ts
new file mode 100644
index 0000000..97d7c81
--- /dev/null
+++ b/examples/imgur-redirect.ts
@@ -0,0 +1,15 @@
+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 = 'imgur.010032.xyz';
+ return {
+ redirectUrl: url.href,
+ };
+ },
+ { urls: ['https://imgur.com/*', 'https://www.imgur.com/*'] },
+ ['blocking']
+);