mirror of
https://github.com/SimonBrazell/privacy-redirect
synced 2025-01-09 15:24:54 +01:00
Fix embedded video redirects
This commit is contained in:
parent
080ab9c45f
commit
e272de67af
@ -5,7 +5,7 @@
|
||||
|
||||
A simple browser extension that redirects Twitter & Youtube requests to privacy friendly alternatives - [Nitter](https://github.com/zedeus/nitter) & [Invidious](https://github.com/omarroth/invidious).
|
||||
|
||||
No unnecessary permissions required, only listens for and redirects requests made to twitter.com, www.twitter.com, mobile.twitter.com, youtube.com, www.youtube.com, youtube-nocookie.com, www.youtube-nocookie.com, and m.youtube.com, nothing else.
|
||||
Listens for and redirects requests made to `twitter.com`, `www.twitter.com`, `mobile.twitter.com`, `youtube.com`, `www.youtube.com`, `youtube-nocookie.com`, `www.youtube-nocookie.com`, and `m.youtube.com`.
|
||||
|
||||
Allows for setting custom [Nitter](https://github.com/zedeus/nitter/wiki/Instances) & [Invidious](https://github.com/omarroth/invidious/wiki/Invidious-Instances) instances and toggling redirects on & off.
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
const nitterDefault = 'https://nitter.net';
|
||||
const invidiousDefault = 'https://invidio.us';
|
||||
const youtubeRegex = /((www|m)\.)?youtube(-nocookie)?\.com/;
|
||||
const twitterRegex = /((www|mobile)\.)?twitter\.com/;
|
||||
const pathRegex = /^https?:\/\/[^\/]+([\S\s]*)/;
|
||||
|
||||
let nitterInstance;
|
||||
@ -12,7 +13,7 @@ let disableInvidious;
|
||||
|
||||
chrome.storage.sync.get(
|
||||
['disableNitter', 'disableInvidious', 'nitterInstance', 'invidiousInstance'],
|
||||
(result) => {
|
||||
result => {
|
||||
disableNitter = result.disableNitter;
|
||||
disableInvidious = result.disableInvidious;
|
||||
nitterInstance = result.nitterInstance || nitterDefault;
|
||||
@ -20,7 +21,7 @@ chrome.storage.sync.get(
|
||||
}
|
||||
);
|
||||
|
||||
chrome.storage.onChanged.addListener(function (changes) {
|
||||
chrome.storage.onChanged.addListener(changes => {
|
||||
if ('nitterInstance' in changes) {
|
||||
nitterInstance = changes.nitterInstance.newValue || nitterDefault;
|
||||
}
|
||||
@ -36,44 +37,30 @@ chrome.storage.onChanged.addListener(function (changes) {
|
||||
});
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function (details) {
|
||||
details => {
|
||||
let redirect;
|
||||
if (details.url.match(youtubeRegex)) {
|
||||
if (!disableInvidious) {
|
||||
return {
|
||||
redirectUrl:
|
||||
invidiousInstance + details.url.match(pathRegex)[1]
|
||||
redirect = {
|
||||
redirectUrl: invidiousInstance + details.url.match(pathRegex)[1]
|
||||
};
|
||||
}
|
||||
} else {
|
||||
} else if (details.url.match(twitterRegex)) {
|
||||
if (!disableNitter) {
|
||||
return {
|
||||
redirectUrl:
|
||||
nitterInstance + details.url.match(pathRegex)[1]
|
||||
redirect = {
|
||||
redirectUrl: nitterInstance + details.url.match(pathRegex)[1]
|
||||
};
|
||||
}
|
||||
}
|
||||
if (redirect) {
|
||||
console.log('Redirecting', `"${details.url}"`, '=>', `"${redirect.redirectUrl}"`);
|
||||
console.log('Details', details);
|
||||
}
|
||||
return redirect;
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
"*://twitter.com/*",
|
||||
"*://www.twitter.com/*",
|
||||
"*://mobile.twitter.com/*",
|
||||
"*://youtube.com/*",
|
||||
"*://www.youtube.com/*",
|
||||
"*://youtube-nocookie.com/*",
|
||||
"*://www.youtube-nocookie.com/*",
|
||||
"*://m.youtube.com/"
|
||||
],
|
||||
types: [
|
||||
"main_frame",
|
||||
"sub_frame",
|
||||
"stylesheet",
|
||||
"script",
|
||||
"image",
|
||||
"object",
|
||||
"xmlhttprequest",
|
||||
"other"
|
||||
]
|
||||
urls: ["<all_urls>"],
|
||||
types: ['main_frame', 'sub_frame',]
|
||||
},
|
||||
["blocking"]
|
||||
['blocking']
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Privacy Redirect",
|
||||
"description": "Redirects Twitter & Youtube requests to privacy friendly alternatives (Nitter & Invidious).",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"scripts": [
|
||||
@ -19,14 +19,7 @@
|
||||
"storage",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"*://twitter.com/*",
|
||||
"*://www.twitter.com/*",
|
||||
"*://mobile.twitter.com/*",
|
||||
"*://youtube.com/*",
|
||||
"*://www.youtube.com/*",
|
||||
"*://youtube-nocookie.com/*",
|
||||
"*://www.youtube-nocookie.com/*",
|
||||
"*://m.youtube.com/"
|
||||
"<all_urls>"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_popup": "pages/popup/popup.html",
|
||||
|
@ -7,7 +7,7 @@ let invidiousInstance = document.querySelector('#invidiousInstance');
|
||||
|
||||
chrome.storage.sync.get(
|
||||
['disableNitter', 'disableInvidious', 'nitterInstance', 'invidiousInstance'],
|
||||
(result) => {
|
||||
result => {
|
||||
disableNitter.checked = !result.disableNitter;
|
||||
disableInvidious.checked = !result.disableInvidious;
|
||||
nitterInstance.value = result.nitterInstance || '';
|
||||
|
@ -14,7 +14,7 @@
|
||||
<img src="../../images/logo.png" alt="Privacy Redirect logo">
|
||||
</div>
|
||||
<small>
|
||||
<span>Version</span>: 1.1.2</span>
|
||||
<span>Version</span>: 1.1.3</span>
|
||||
</small>
|
||||
</header>
|
||||
|
||||
|
@ -17,9 +17,9 @@ chrome.storage.sync.get(
|
||||
|
||||
function debounce(func, wait, immediate) {
|
||||
let timeout;
|
||||
return function () {
|
||||
return () => {
|
||||
let context = this, args = arguments;
|
||||
let later = function () {
|
||||
let later = () => {
|
||||
timeout = null;
|
||||
if (!immediate) func.apply(context, args);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user