parent
d96ecc3ff5
commit
3f01569099
|
@ -18,7 +18,7 @@ function redirectTwitter(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.sync.get(
|
browser.storage.sync.get(
|
||||||
['nitterInstance', 'disableNitter', 'removeTwitterSW'],
|
['nitterInstance', 'disableNitter', 'removeTwitterSW', 'redirectBypassFlag'],
|
||||||
(result) => {
|
(result) => {
|
||||||
if (!result.removeTwitterSW) {
|
if (!result.removeTwitterSW) {
|
||||||
disableNitter = result.disableNitter;
|
disableNitter = result.disableNitter;
|
||||||
|
@ -32,7 +32,11 @@ browser.storage.sync.get(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const url = new URL(window.location);
|
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);
|
const redirect = redirectTwitter(url);
|
||||||
console.info(
|
console.info(
|
||||||
'Redirecting', `"${url.href}"`, '=>', `"${redirect}"`
|
'Redirecting', `"${url.href}"`, '=>', `"${redirect}"`
|
||||||
|
|
|
@ -204,6 +204,10 @@ function redirectYouTube(url, initiator, type) {
|
||||||
// Don't redirect YouTube Player API.
|
// Don't redirect YouTube Player API.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (url.host.split('.')[0] === 'studio') {
|
||||||
|
// Avoid redirecting `studio.youtube.com`
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// Proxy video through the server if enabled by user
|
// Proxy video through the server if enabled by user
|
||||||
if (alwaysProxy) {
|
if (alwaysProxy) {
|
||||||
url.searchParams.append('local', true);
|
url.searchParams.append('local', true);
|
||||||
|
@ -224,6 +228,12 @@ function redirectTwitter(url, initiator) {
|
||||||
if (disableNitter || isWhitelisted(initiator)) {
|
if (disableNitter || isWhitelisted(initiator)) {
|
||||||
return null;
|
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') {
|
if (url.host.split('.')[0] === 'pbs') {
|
||||||
return `${nitterInstance}/pic/${encodeURIComponent(url.href)}`;
|
return `${nitterInstance}/pic/${encodeURIComponent(url.href)}`;
|
||||||
} else if (url.host.split('.')[0] === 'video') {
|
} else if (url.host.split('.')[0] === 'video') {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Privacy Redirect",
|
"name": "Privacy Redirect",
|
||||||
"description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.",
|
"description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.",
|
||||||
"version": "1.1.31",
|
"version": "1.1.32",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
|
|
Loading…
Reference in New Issue