feat(tazjin/nittredir): Add Chrome extension to redirect to Nitter
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
This commit is contained in:
parent
de64ebbbaa
commit
ea9982d9ea
2 changed files with 25 additions and 0 deletions
10
users/tazjin/nittredir/background.js
Normal file
10
users/tazjin/nittredir/background.js
Normal file
|
|
@ -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']);
|
||||
Loading…
Add table
Add a link
Reference in a new issue