mirror of
https://github.com/SimonBrazell/privacy-redirect
synced 2025-01-10 15:56:18 +01:00
parent
3f01569099
commit
b21610202f
@ -20,6 +20,10 @@ function redirectTwitter(url) {
|
||||
browser.storage.sync.get(
|
||||
['nitterInstance', 'disableNitter', 'removeTwitterSW', 'redirectBypassFlag'],
|
||||
(result) => {
|
||||
const redirectBypassFlag = result.redirectBypassFlag;
|
||||
browser.storage.sync.set({
|
||||
redirectBypassFlag: false
|
||||
});
|
||||
if (!result.removeTwitterSW) {
|
||||
disableNitter = result.disableNitter;
|
||||
nitterInstance = result.nitterInstance || nitterDefault;
|
||||
@ -32,11 +36,7 @@ browser.storage.sync.get(
|
||||
}
|
||||
});
|
||||
const url = new URL(window.location);
|
||||
const redirectBypassFlag = result.redirectBypassFlag;
|
||||
browser.storage.sync.set({
|
||||
redirectBypassFlag: false
|
||||
});
|
||||
if (!redirectBypassFlag && !disableNitter && url.host !== nitterInstance) {
|
||||
if (!redirectBypassFlag && !disableNitter && url.host !== nitterInstance && !url.pathname.includes('/home')) {
|
||||
const redirect = redirectTwitter(url);
|
||||
console.info(
|
||||
'Redirecting', `"${url.href}"`, '=>', `"${redirect}"`
|
||||
|
@ -10,6 +10,7 @@ const youtubeDomains = [
|
||||
'www.youtube-nocookie.com',
|
||||
'youtu.be',
|
||||
's.ytimg.com',
|
||||
'music.youtube.com'
|
||||
];
|
||||
const nitterDefault = 'https://nitter.net';
|
||||
const twitterDomains = [
|
||||
@ -85,6 +86,7 @@ let onlyEmbeddedVideo;
|
||||
let videoQuality;
|
||||
let invidiousDarkMode;
|
||||
let whitelist;
|
||||
let redirectBypassFlag;
|
||||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
@ -161,6 +163,9 @@ browser.storage.onChanged.addListener(changes => {
|
||||
if ('whitelist' in changes) {
|
||||
whitelist = changes.whitelist.newValue.map(e => new RegExp(e));
|
||||
}
|
||||
if ('redirectBypassFlag' in changes) {
|
||||
redirectBypassFlag = changes.redirectBypassFlag.newValue;
|
||||
}
|
||||
});
|
||||
|
||||
function addressToLatLng(address, callback) {
|
||||
@ -193,6 +198,10 @@ function isWhitelisted(initiator) {
|
||||
return initiator && whitelist.some(regex => (regex.test(initiator.href)));
|
||||
}
|
||||
|
||||
function isFirefox() {
|
||||
return typeof InstallTrigger !== 'undefined';
|
||||
}
|
||||
|
||||
function redirectYouTube(url, initiator, type) {
|
||||
if (disableInvidious || isWhitelisted(initiator)) {
|
||||
return null;
|
||||
@ -208,16 +217,16 @@ function redirectYouTube(url, initiator, type) {
|
||||
// Avoid redirecting `studio.youtube.com`
|
||||
return null;
|
||||
}
|
||||
// Proxy video through the server if enabled by user
|
||||
if (onlyEmbeddedVideo && type !== 'sub_frame') {
|
||||
return null;
|
||||
}
|
||||
// Apply settings
|
||||
if (alwaysProxy) {
|
||||
url.searchParams.append('local', true);
|
||||
}
|
||||
if (videoQuality) {
|
||||
url.searchParams.append('quality', videoQuality);
|
||||
}
|
||||
if (onlyEmbeddedVideo && type !== 'sub_frame') {
|
||||
return null;
|
||||
}
|
||||
if (invidiousDarkMode) {
|
||||
url.searchParams.append('dark_mode', invidiousDarkMode);
|
||||
}
|
||||
@ -228,7 +237,10 @@ function redirectTwitter(url, initiator) {
|
||||
if (disableNitter || isWhitelisted(initiator)) {
|
||||
return null;
|
||||
}
|
||||
if (initiator && (initiator.origin === nitterInstance || twitterDomains.includes(initiator.host))) {
|
||||
if (url.pathname.includes('/home')) {
|
||||
return null;
|
||||
}
|
||||
if (isFirefox() && initiator && (initiator.origin === nitterInstance || twitterDomains.includes(initiator.host))) {
|
||||
browser.storage.sync.set({
|
||||
redirectBypassFlag: true
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Privacy Redirect",
|
||||
"description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.",
|
||||
"version": "1.1.32",
|
||||
"version": "1.1.33",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"scripts": [
|
||||
|
Loading…
Reference in New Issue
Block a user