mirror of
https://github.com/SimonBrazell/privacy-redirect
synced 2025-01-09 15:24:54 +01:00
Add support for Bibliogram redirects
This commit is contained in:
parent
e272de67af
commit
ed3941ff72
@ -3,11 +3,14 @@
|
||||
- [Chrome Extension](https://chrome.google.com/webstore/detail/privacy-redirect/pmcmeagblkinmogikoikkdjiligflglb)
|
||||
- [Firefox Add-on](https://addons.mozilla.org/en-US/firefox/addon/privacy-redirect/)
|
||||
|
||||
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).
|
||||
A simple browser extension that redirects Twitter, Youtube & Instagram requests to privacy friendly alternatives - [Nitter](https://github.com/zedeus/nitter), [Invidious](https://github.com/omarroth/invidious) & [Bibliogram](https://github.com/cloudrac3r/bibliogram).
|
||||
|
||||
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`.
|
||||
Listens for and redirects requests made to the following:
|
||||
- **Twitter -** `twitter.com`, `www.twitter.com`, `mobile.twitter.com`
|
||||
- **Youtube -** `youtube.com`, `www.youtube.com`, `youtube-nocookie.com`, `www.youtube-nocookie.com`, `m.youtube.com`
|
||||
- **Instagram -** `instagram.com`, `www.instagram.com`, `help.instagram.com`, `about.instagram.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.
|
||||
Allows for setting custom [Nitter](https://github.com/zedeus/nitter/wiki/Instances), [Invidious](https://github.com/omarroth/invidious/wiki/Invidious-Instances) & [Bibliogram](https://github.com/cloudrac3r/bibliogram/wiki/Instances) instances and toggling redirects on & off.
|
||||
|
||||
## Build
|
||||
|
||||
|
@ -1,23 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
const nitterDefault = 'https://nitter.net';
|
||||
const twitterRegex = /((www|mobile)\.)?twitter\.com/;
|
||||
const invidiousDefault = 'https://invidio.us';
|
||||
const youtubeRegex = /((www|m)\.)?youtube(-nocookie)?\.com/;
|
||||
const twitterRegex = /((www|mobile)\.)?twitter\.com/;
|
||||
const pathRegex = /^https?:\/\/[^\/]+([\S\s]*)/;
|
||||
const bibliogramDefault = 'https://bibliogram.art';
|
||||
const instagramRegex = /((www|about|help)\.)?instagram\.com/;
|
||||
const instagramPathsRegex = /(\/a|\/admin|\/api|\/favicon.ico|\/static|\/imageproxy|\/p|\/u|\/developer|\/about|\/legal|\/explore|\/director)/;
|
||||
|
||||
let nitterInstance;
|
||||
let invidiousInstance;
|
||||
let bibliogramInstance;
|
||||
let disableNitter;
|
||||
let disableInvidious;
|
||||
let disableBibliogram;
|
||||
|
||||
chrome.storage.sync.get(
|
||||
['disableNitter', 'disableInvidious', 'nitterInstance', 'invidiousInstance'],
|
||||
[
|
||||
'nitterInstance',
|
||||
'invidiousInstance',
|
||||
'bibliogramInstance',
|
||||
'disableNitter',
|
||||
'disableInvidious',
|
||||
'disableBibliogram'
|
||||
],
|
||||
result => {
|
||||
disableNitter = result.disableNitter;
|
||||
disableInvidious = result.disableInvidious;
|
||||
disableBibliogram = result.disableBibliogram;
|
||||
nitterInstance = result.nitterInstance || nitterDefault;
|
||||
invidiousInstance = result.invidiousInstance || invidiousDefault;
|
||||
bibliogramInstance = result.bibliogramInstance || bibliogramDefault;
|
||||
}
|
||||
);
|
||||
|
||||
@ -28,32 +41,56 @@ chrome.storage.onChanged.addListener(changes => {
|
||||
if ('invidiousInstance' in changes) {
|
||||
invidiousInstance = changes.invidiousInstance.newValue || invidiousDefault;
|
||||
}
|
||||
if ('bibliogramInstance' in changes) {
|
||||
bibliogramInstance = changes.bibliogramInstance.newValue || bibliogramDefault;
|
||||
}
|
||||
if ('disableNitter' in changes) {
|
||||
disableNitter = changes.disableNitter.newValue;
|
||||
}
|
||||
if ('disableInvidious' in changes) {
|
||||
disableInvidious = changes.disableInvidious.newValue;
|
||||
}
|
||||
if ('disableBibliogram' in changes) {
|
||||
disableBibliogram = changes.disableBibliogram.newValue;
|
||||
}
|
||||
});
|
||||
|
||||
function redirectBibliogram(url) {
|
||||
if (url.pathname === '/' || url.pathname.match(instagramPathsRegex)) {
|
||||
return bibliogramInstance + url.pathname;
|
||||
} else {
|
||||
// Redirect user profile requests to '/u/...'
|
||||
return `${bibliogramInstance}/u${url.pathname}`;
|
||||
}
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
details => {
|
||||
const url = new URL(details.url);
|
||||
let redirect;
|
||||
if (details.url.match(youtubeRegex)) {
|
||||
if (url.host.match(youtubeRegex)) {
|
||||
if (!disableInvidious) {
|
||||
redirect = {
|
||||
redirectUrl: invidiousInstance + details.url.match(pathRegex)[1]
|
||||
redirectUrl: invidiousInstance + url.pathname
|
||||
};
|
||||
}
|
||||
} else if (details.url.match(twitterRegex)) {
|
||||
} else if (url.host.match(twitterRegex)) {
|
||||
if (!disableNitter) {
|
||||
redirect = {
|
||||
redirectUrl: nitterInstance + details.url.match(pathRegex)[1]
|
||||
redirectUrl: nitterInstance + url.pathname
|
||||
};
|
||||
}
|
||||
} else if (url.host.match(instagramRegex)) {
|
||||
if (!disableBibliogram) {
|
||||
redirect = {
|
||||
redirectUrl: redirectBibliogram(url)
|
||||
};
|
||||
}
|
||||
}
|
||||
if (redirect) {
|
||||
console.log('Redirecting', `"${details.url}"`, '=>', `"${redirect.redirectUrl}"`);
|
||||
console.log(
|
||||
'Redirecting', `"${url.host}"`, '=>', `"${redirect.redirectUrl}"`
|
||||
);
|
||||
console.log('Details', details);
|
||||
}
|
||||
return redirect;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Privacy Redirect",
|
||||
"description": "Redirects Twitter & Youtube requests to privacy friendly alternatives (Nitter & Invidious).",
|
||||
"version": "1.1.3",
|
||||
"description": "Redirects Twitter, Youtube & Instagram requests to privacy friendly alternatives - Nitter, Invidious, & Bibliogram.",
|
||||
"version": "1.1.4",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"scripts": [
|
||||
|
@ -29,11 +29,22 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="options settings_block">
|
||||
<div class="onoffswitch switch" aria-label="Toggle Bibliogram redirects">
|
||||
<h1>Bibliogram Redirects</h1>
|
||||
<input aria-hidden="true" id="disableBibliogram" type="checkbox" checked>
|
||||
<label for="disableBibliogram" class="checkbox-label">
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="options settings_block">
|
||||
<h1>Nitter Instance</h1>
|
||||
<input id="nitterInstance" type="url" placeholder="https://nitter.net">
|
||||
<h1>Invidious Instance</h1>
|
||||
<input id="invidiousInstance" type="url" placeholder="https://invidio.us">
|
||||
<h1>Bibliogram Instance</h1>
|
||||
<input id="bibliogramInstance" type="url" placeholder="https://bibliogram.art">
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
|
@ -1,26 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
let disableNitter = document.querySelector('#disableNitter');
|
||||
let disableInvidious = document.querySelector('#disableInvidious');
|
||||
let nitterInstance = document.querySelector('#nitterInstance');
|
||||
let invidiousInstance = document.querySelector('#invidiousInstance');
|
||||
let bibliogramInstance = document.querySelector('#bibliogramInstance');
|
||||
let disableNitter = document.querySelector('#disableNitter');
|
||||
let disableInvidious = document.querySelector('#disableInvidious');
|
||||
let disableBibliogram = document.querySelector('#disableBibliogram');
|
||||
|
||||
chrome.storage.sync.get(
|
||||
['disableNitter', 'disableInvidious', 'nitterInstance', 'invidiousInstance'],
|
||||
[
|
||||
'nitterInstance',
|
||||
'invidiousInstance',
|
||||
'bibliogramInstance',
|
||||
'disableNitter',
|
||||
'disableInvidious',
|
||||
'disableBibliogram'
|
||||
],
|
||||
result => {
|
||||
disableNitter.checked = !result.disableNitter;
|
||||
disableInvidious.checked = !result.disableInvidious;
|
||||
nitterInstance.value = result.nitterInstance || '';
|
||||
invidiousInstance.value = result.invidiousInstance || '';
|
||||
bibliogramInstance.value = result.bibliogramInstance || '';
|
||||
disableNitter.checked = !result.disableNitter;
|
||||
disableInvidious.checked = !result.disableInvidious;
|
||||
disableBibliogram.checked = !result.disableBibliogram;
|
||||
}
|
||||
);
|
||||
|
||||
document.querySelector('#save').addEventListener('click', () => {
|
||||
chrome.storage.sync.set({
|
||||
nitterInstance: nitterInstance.value,
|
||||
invidiousInstance: invidiousInstance.value,
|
||||
bibliogramInstance: bibliogramInstance.value,
|
||||
disableNitter: !disableNitter.checked,
|
||||
disableInvidious: !disableInvidious.checked,
|
||||
nitterInstance: nitterInstance.value,
|
||||
invidiousInstance: invidiousInstance.value
|
||||
disableBibliogram: !disableBibliogram.checked
|
||||
});
|
||||
window.close();
|
||||
});
|
@ -14,7 +14,7 @@
|
||||
<img src="../../images/logo.png" alt="Privacy Redirect logo">
|
||||
</div>
|
||||
<small>
|
||||
<span>Version</span>: 1.1.3</span>
|
||||
<span>Version</span>: 1.1.4</span>
|
||||
</small>
|
||||
</header>
|
||||
|
||||
@ -36,11 +36,22 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="options settings_block">
|
||||
<div class="onoffswitch switch" aria-label="Toggle Bibliogram redirects">
|
||||
<h1>Bibliogram Redirects</h1>
|
||||
<input aria-hidden="true" id="disableBibliogram" type="checkbox" checked>
|
||||
<label for="disableBibliogram" class="checkbox-label">
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="options settings_block">
|
||||
<h1>Nitter Instance</h1>
|
||||
<input id="nitterInstance" type="url" placeholder="https://nitter.net">
|
||||
<h1>Invidious Instance</h1>
|
||||
<input id="invidiousInstance" type="url" placeholder="https://invidio.us">
|
||||
<h1>Bibliogram Instance</h1>
|
||||
<input id="bibliogramInstance" type="url" placeholder="https://bibliogram.art">
|
||||
</section>
|
||||
|
||||
<script src="./popup.js"></script>
|
||||
|
@ -1,17 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
let disableNitter = document.querySelector('#disableNitter');
|
||||
let disableInvidious = document.querySelector('#disableInvidious');
|
||||
let nitterInstance = document.querySelector('#nitterInstance');
|
||||
let invidiousInstance = document.querySelector('#invidiousInstance');
|
||||
let bibliogramInstance = document.querySelector('#bibliogramInstance');
|
||||
let disableNitter = document.querySelector('#disableNitter');
|
||||
let disableInvidious = document.querySelector('#disableInvidious');
|
||||
let disableBibliogram = document.querySelector('#disableBibliogram');
|
||||
|
||||
chrome.storage.sync.get(
|
||||
['disableNitter', 'disableInvidious', 'nitterInstance', 'invidiousInstance'],
|
||||
[
|
||||
'nitterInstance',
|
||||
'invidiousInstance',
|
||||
'bibliogramInstance',
|
||||
'disableNitter',
|
||||
'disableInvidious',
|
||||
'disableBibliogram'
|
||||
],
|
||||
result => {
|
||||
disableNitter.checked = !result.disableNitter;
|
||||
disableInvidious.checked = !result.disableInvidious;
|
||||
nitterInstance.value = result.nitterInstance || '';
|
||||
invidiousInstance.value = result.invidiousInstance || '';
|
||||
bibliogramInstance.value = result.bibliogramInstance || '';
|
||||
disableNitter.checked = !result.disableNitter;
|
||||
disableInvidious.checked = !result.disableInvidious;
|
||||
disableBibliogram.checked = !result.disableBibliogram;
|
||||
}
|
||||
);
|
||||
|
||||
@ -42,6 +53,12 @@ let invidiousInstanceChange = debounce(() => {
|
||||
|
||||
invidiousInstance.addEventListener('input', invidiousInstanceChange);
|
||||
|
||||
let bibliogramInstanceChange = debounce(() => {
|
||||
chrome.storage.sync.set({ bibliogramInstance: bibliogramInstance.value });
|
||||
}, 500);
|
||||
|
||||
bibliogramInstance.addEventListener('input', bibliogramInstanceChange);
|
||||
|
||||
disableNitter.addEventListener('change', event => {
|
||||
chrome.storage.sync.set({ disableNitter: !event.target.checked });
|
||||
});
|
||||
@ -49,3 +66,7 @@ disableNitter.addEventListener('change', event => {
|
||||
disableInvidious.addEventListener('change', event => {
|
||||
chrome.storage.sync.set({ disableInvidious: !event.target.checked });
|
||||
});
|
||||
|
||||
disableBibliogram.addEventListener('change', event => {
|
||||
chrome.storage.sync.set({ disableBibliogram: !event.target.checked });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user