Fix #30 - 'View on ...' links, & handle more maps embed cases
This commit is contained in:
parent
0a4c1c0411
commit
9a5a3779b4
|
@ -1,11 +1,11 @@
|
||||||
# ![nitter-redirect](images/icon32.png) Privacy Redirect
|
# ![nitter-redirect](images/icon32.png) Privacy Redirect
|
||||||
|
|
||||||
[![Buy me a coffee](images/buy-me-a-coffee.png)](https://www.buymeacoffee.com/SimonBrazell)
|
[![Donate](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/SimonBrazell/donate) [![Buy me a coffee](images/buy-me-a-coffee.png)](https://www.buymeacoffee.com/SimonBrazell)
|
||||||
|
|
||||||
- [Chrome Extension](https://chrome.google.com/webstore/detail/privacy-redirect/pmcmeagblkinmogikoikkdjiligflglb)
|
- [Chrome Extension](https://chrome.google.com/webstore/detail/privacy-redirect/pmcmeagblkinmogikoikkdjiligflglb)
|
||||||
- [Firefox Add-on](https://addons.mozilla.org/en-US/firefox/addon/privacy-redirect/)
|
- [Firefox Add-on](https://addons.mozilla.org/en-US/firefox/addon/privacy-redirect/)
|
||||||
|
|
||||||
A simple web extension that redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives - [Nitter](https://github.com/zedeus/nitter), [Invidious](https://github.com/omarroth/invidious), [Bibliogram](https://github.com/cloudrac3r/bibliogram) & [OpenStreetMap](https://www.openstreetmap.org/).
|
A web extension that redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives - [Nitter](https://github.com/zedeus/nitter), [Invidious](https://github.com/omarroth/invidious), [Bibliogram](https://github.com/cloudrac3r/bibliogram) & [OpenStreetMap](https://www.openstreetmap.org/).
|
||||||
|
|
||||||
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) & [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Tile_servers) instances and toggling all 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) & [OpenStreetMap](https://wiki.openstreetmap.org/wiki/Tile_servers) instances and toggling all redirects on & off.
|
||||||
|
|
||||||
|
|
|
@ -145,10 +145,13 @@ function addressToLatLng(address, callback) {
|
||||||
xmlhttp.send();
|
xmlhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirectYouTube(url, type) {
|
function redirectYouTube(url, initiator, type) {
|
||||||
if (disableInvidious) {
|
if (disableInvidious) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (initiator && (initiator.origin === invidiousInstance || youtubeDomains.includes(initiator.host))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (url.pathname.match(/iframe_api/)) {
|
if (url.pathname.match(/iframe_api/)) {
|
||||||
// Redirect requests for YouTube Player API to local files instead
|
// Redirect requests for YouTube Player API to local files instead
|
||||||
return browser.runtime.getURL('assets/iframe_api.js');
|
return browser.runtime.getURL('assets/iframe_api.js');
|
||||||
|
@ -170,10 +173,13 @@ function redirectYouTube(url, type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirectTwitter(url) {
|
function redirectTwitter(url, initiator) {
|
||||||
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') {
|
||||||
|
@ -183,10 +189,13 @@ function redirectTwitter(url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirectInstagram(url) {
|
function redirectInstagram(url, initiator) {
|
||||||
if (disableBibliogram) {
|
if (disableBibliogram) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (initiator && (initiator.origin === bibliogramInstance || initiator.host.match(instagramRegex))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (url.pathname === '/' || url.pathname.match(instagramPathsRegex)) {
|
if (url.pathname === '/' || url.pathname.match(instagramPathsRegex)) {
|
||||||
return `${bibliogramInstance}${url.pathname}${url.search}`;
|
return `${bibliogramInstance}${url.pathname}${url.search}`;
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,7 +226,19 @@ function redirectGoogleMaps(url) {
|
||||||
params = `${params}&layers=${layers[url.searchParams.get('layer')] || layers['none']}`;
|
params = `${params}&layers=${layers[url.searchParams.get('layer')] || layers['none']}`;
|
||||||
// Handle Google Maps Embed API
|
// Handle Google Maps Embed API
|
||||||
if (url.pathname.includes('/embed')) {
|
if (url.pathname.includes('/embed')) {
|
||||||
const query = url.searchParams.get('q') || url.searchParams.get('query');
|
let query = '';
|
||||||
|
if (url.searchParams.has('q')) {
|
||||||
|
query = url.searchParams.get('q');
|
||||||
|
} else if (url.searchParams.has('query')) {
|
||||||
|
query = url.searchParams.has('query');
|
||||||
|
} else if (url.searchParams.has('pb')) {
|
||||||
|
try {
|
||||||
|
query = url.searchParams.get('pb').split(/!2s(.*?)!/)[1];
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
// Unable to find map marker in URL.
|
||||||
|
}
|
||||||
|
}
|
||||||
let marker, bbox;
|
let marker, bbox;
|
||||||
addressToLatLng(query, (coords, boundingbox) => {
|
addressToLatLng(query, (coords, boundingbox) => {
|
||||||
marker = coords;
|
marker = coords;
|
||||||
|
@ -267,18 +288,19 @@ 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 redirect;
|
let redirect;
|
||||||
if (youtubeDomains.includes(url.host)) {
|
if (youtubeDomains.includes(url.host)) {
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectYouTube(url, details.type)
|
redirectUrl: redirectYouTube(url, initiator, details.type)
|
||||||
};
|
};
|
||||||
} else if (twitterDomains.includes(url.host)) {
|
} else if (twitterDomains.includes(url.host)) {
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectTwitter(url)
|
redirectUrl: redirectTwitter(url, initiator)
|
||||||
};
|
};
|
||||||
} else if (url.host.match(instagramRegex)) {
|
} else if (url.host.match(instagramRegex)) {
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectInstagram(url)
|
redirectUrl: redirectInstagram(url, initiator)
|
||||||
};
|
};
|
||||||
} else if (url.href.match(googleMapsRegex)) {
|
} else if (url.href.match(googleMapsRegex)) {
|
||||||
redirect = {
|
redirect = {
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 4.9 KiB |
|
@ -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.17",
|
"version": "1.1.18",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
|
|
Loading…
Reference in New Issue