diff options
author | Vincent Ambo <mail@tazj.in> | 2021-01-20T15·17+0300 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-01-20T15·36+0000 |
commit | ea9982d9eab50ee724eb1e5bae000911b219472f (patch) | |
tree | f8e84a743a3cd3424bb116b6d68ab1232ea872c6 /users/tazjin | |
parent | de64ebbbaa808ee9d6162de991d15300f3b12044 (diff) |
feat(tazjin/nittredir): Add Chrome extension to redirect to Nitter r/2136
There is another extension for this already, but it hooks in after the page has already started loading - doing it on the URL change handler is much faster. Change-Id: I442552cbd8bb040df999a1624cafd436f4a7b875 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2430 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin')
-rw-r--r-- | users/tazjin/nittredir/background.js | 10 | ||||
-rw-r--r-- | users/tazjin/nittredir/manifest.json | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/users/tazjin/nittredir/background.js b/users/tazjin/nittredir/background.js new file mode 100644 index 000000000000..8d07f8528520 --- /dev/null +++ b/users/tazjin/nittredir/background.js @@ -0,0 +1,10 @@ +/** + * Register a URL change handler that redirects twitter.com links to nitter.net + */ + +chrome.webRequest.onBeforeRequest.addListener(function(details) { + let url = new URL(details.url); + return { + redirectUrl: ('https://nitter.net' + url.pathname) + }; +}, {urls: ['*://twitter.com/*'], types: ['main_frame']}, ['blocking']); diff --git a/users/tazjin/nittredir/manifest.json b/users/tazjin/nittredir/manifest.json new file mode 100644 index 000000000000..4efe1a6cc245 --- /dev/null +++ b/users/tazjin/nittredir/manifest.json @@ -0,0 +1,15 @@ +{ + "manifest_version": 2, + "name": "nittredir", + "version": "1.0", + "description": "Redirect twitter.com to nitter.net", + "background": { + "scripts": ["background.js"], + "persistent": true + }, + "permissions": [ + "webRequest", + "webRequestBlocking", + "*://twitter.com/*" + ] +} |