Fixed 'View on ...' links for Invidious & Bibliogram

This commit is contained in:
SimonBrazell 2020-03-31 17:39:57 +11:00
parent 9a5a3779b4
commit c3e0094527
2 changed files with 9 additions and 7 deletions

View File

@ -173,13 +173,10 @@ function redirectYouTube(url, initiator, type) {
} }
} }
function redirectTwitter(url, initiator) { function redirectTwitter(url) {
if (disableNitter) { if (disableNitter) {
return null; return null;
} }
if (initiator && (initiator.origin === nitterInstance || twitterDomains.includes(initiator.host))) {
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') {
@ -288,7 +285,12 @@ function redirectGoogleMaps(url) {
browser.webRequest.onBeforeRequest.addListener( browser.webRequest.onBeforeRequest.addListener(
details => { details => {
const url = new URL(details.url); const url = new URL(details.url);
let initiator = details.initiator && new URL(details.initiator); let initiator;
if (details.initiator) {
initiator = new URL(details.initiator);
} else if (details.originUrl) {
initiator = new URL(details.originUrl);
}
let redirect; let redirect;
if (youtubeDomains.includes(url.host)) { if (youtubeDomains.includes(url.host)) {
redirect = { redirect = {
@ -296,7 +298,7 @@ browser.webRequest.onBeforeRequest.addListener(
}; };
} else if (twitterDomains.includes(url.host)) { } else if (twitterDomains.includes(url.host)) {
redirect = { redirect = {
redirectUrl: redirectTwitter(url, initiator) redirectUrl: redirectTwitter(url)
}; };
} else if (url.host.match(instagramRegex)) { } else if (url.host.match(instagramRegex)) {
redirect = { redirect = {

View File

@ -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.18", "version": "1.1.19",
"manifest_version": 2, "manifest_version": 2,
"background": { "background": {
"scripts": [ "scripts": [