Fix #60 & complete #30 - YT studio & Nitter "View on..." links

This commit is contained in:
SimonBrazell 2020-06-03 22:01:27 +10:00
parent d96ecc3ff5
commit 3f01569099
3 changed files with 17 additions and 3 deletions

View File

@ -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}"`

View File

@ -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') {

View File

@ -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": [