diff --git a/assets/remove-twitter-sw.js b/assets/remove-twitter-sw.js index d13de3e..b897a18 100644 --- a/assets/remove-twitter-sw.js +++ b/assets/remove-twitter-sw.js @@ -18,7 +18,7 @@ function redirectTwitter(url) { } browser.storage.sync.get( - ['nitterInstance', 'disableNitter', 'removeTwitterSW'], + ['nitterInstance', 'disableNitter', 'removeTwitterSW', 'redirectBypassFlag'], (result) => { if (!result.removeTwitterSW) { disableNitter = result.disableNitter; @@ -32,7 +32,11 @@ browser.storage.sync.get( } }); const url = new URL(window.location); - if (!disableNitter && url.host !== nitterInstance) { + const redirectBypassFlag = result.redirectBypassFlag; + browser.storage.sync.set({ + redirectBypassFlag: false + }); + if (!redirectBypassFlag && !disableNitter && url.host !== nitterInstance) { const redirect = redirectTwitter(url); console.info( 'Redirecting', `"${url.href}"`, '=>', `"${redirect}"` diff --git a/background.js b/background.js index c4783e3..1a64639 100644 --- a/background.js +++ b/background.js @@ -204,6 +204,10 @@ function redirectYouTube(url, initiator, type) { // Don't redirect YouTube Player API. return null; } + if (url.host.split('.')[0] === 'studio') { + // Avoid redirecting `studio.youtube.com` + return null; + } // Proxy video through the server if enabled by user if (alwaysProxy) { url.searchParams.append('local', true); @@ -224,6 +228,12 @@ function redirectTwitter(url, initiator) { if (disableNitter || isWhitelisted(initiator)) { return null; } + if (initiator && (initiator.origin === nitterInstance || twitterDomains.includes(initiator.host))) { + browser.storage.sync.set({ + redirectBypassFlag: true + }); + return null; + } if (url.host.split('.')[0] === 'pbs') { return `${nitterInstance}/pic/${encodeURIComponent(url.href)}`; } else if (url.host.split('.')[0] === 'video') { diff --git a/manifest.json b/manifest.json index 3127beb..a0a927a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Privacy Redirect", "description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.", - "version": "1.1.31", + "version": "1.1.32", "manifest_version": 2, "background": { "scripts": [