summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimonBrazell <simon@brazell.com.au>2020-02-25 23:41:01 +1100
committerSimonBrazell <simon@brazell.com.au>2020-02-25 23:41:01 +1100
commitc0eff6677528af6e2efbdd5385a5b9404a5ed54d (patch)
tree97114b206c5388c1412207e275c29b6c5a0e9757
parentcfd51cb1ad7744a63f87868bbdbaf7c02f367fbb (diff)
downloadprivacy-redirect-c0eff6677528af6e2efbdd5385a5b9404a5ed54d.tar.gz
privacy-redirect-c0eff6677528af6e2efbdd5385a5b9404a5ed54d.tar.bz2
privacy-redirect-c0eff6677528af6e2efbdd5385a5b9404a5ed54d.zip
Fix OSM embed bbox & add default zoom (17)v1.1.13
-rw-r--r--background.js23
-rw-r--r--manifest.json2
2 files changed, 18 insertions, 7 deletions
diff --git a/background.js b/background.js
index 4bd2f52..00570de 100644
--- a/background.js
+++ b/background.js
@@ -87,7 +87,10 @@ function addressToLatLon(address, callback) {
if (xmlhttp.status === 200) {
const json = JSON.parse(xmlhttp.responseText)[0];
if (json) {
- callback(`${json.lat}%2C${json.lon}`, json.boundingbox.join('%2C'));
+ callback(
+ `${json.lat}%2C${json.lon}`,
+ `${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`
+ );
}
}
else {
@@ -139,6 +142,7 @@ function redirectInstagram(url) {
}
function redirectGoogleMaps(url) {
+ let redirect;
let mapCentre = '';
if (url.pathname.match(latLngZoomRegex)) {
const [, lat, lon, zoom] = url.pathname.match(latLngZoomRegex);
@@ -154,7 +158,7 @@ function redirectGoogleMaps(url) {
marker = coords;
bbox = boundingbox;
});
- return `${osmInstance}/export/embed.html?bbox=${bbox}&layer=mapnik&marker=${marker}`;
+ redirect = `${osmInstance}/export/embed.html?bbox=${bbox}&layer=mapnik&marker=${marker}`;
} else if (url.pathname.includes('/dir')) {
const travelMode = travelModes[url.searchParams.get('travelmode')] || travelModes['driving'];
let origin;
@@ -165,17 +169,24 @@ function redirectGoogleMaps(url) {
addressToLatLon(url.searchParams.get('destination'), coords => {
destination = coords;
});
- return `${osmInstance}/directions?engine=${travelMode}&route=${origin}%3B${destination}${mapCentre}`;
+ redirect = `${osmInstance}/directions?engine=${travelMode}&route=${origin}%3B${destination}${mapCentre}`;
} else if (url.pathname.includes('data=')) {
const [mlat, mlon] = url.pathname.match(dataLatLngRegex);
- return `${osmInstance}/?mlat=${mlat.replace('!3d', '')}&mlon=${mlon.replace('!4d', '')}${mapCentre}`;
+ redirect = `${osmInstance}/?mlat=${mlat.replace('!3d', '')}&mlon=${mlon.replace('!4d', '')}${mapCentre}`;
} else if (url.search.includes('ll=')) {
const [mlat, mlon] = url.searchParams.get('ll').split(',');
- return `${osmInstance}/?mlat=${mlat}&mlon=${mlon}${mapCentre}`;
+ redirect = `${osmInstance}/?mlat=${mlat}&mlon=${mlon}${mapCentre}`;
} else {
const query = url.searchParams.get('q') || url.searchParams.get('query') || url.pathname.split('/')[3];
- return `${osmInstance}/${query ? 'search?query=' + query : ''}${mapCentre || '#'}`;
+ redirect = `${osmInstance}/${query ? 'search?query=' + query : ''}${mapCentre || '#'}`;
}
+ // Set default zoom if mapCentre not present
+ if (!mapCentre) {
+ const redirectUrl = new URL(redirect);
+ redirectUrl.searchParams.set('zoom', '17');
+ redirect = redirectUrl.href;
+ }
+ return redirect;
}
browser.webRequest.onBeforeRequest.addListener(
diff --git a/manifest.json b/manifest.json
index 6ce4602..a8a9780 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"name": "Privacy Redirect",
"description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.",
- "version": "1.1.12",
+ "version": "1.1.13",
"manifest_version": 2,
"background": {
"scripts": [