summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--background.js39
-rw-r--r--manifest.json2
-rw-r--r--pages/options/options.html2
3 files changed, 34 insertions, 9 deletions
diff --git a/background.js b/background.js
index 166f694..f27541d 100644
--- a/background.js
+++ b/background.js
@@ -20,8 +20,18 @@ const twitterDomains = [
'video.twimg.com',
];
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)/;
+const instagramDomains = [
+ "instagram.com",
+ "www.instagram.com",
+ "help.instagram.com",
+ "about.instagram.com",
+];
+const instagramReservedPaths = /\/(p|favicon.ico|developer|legal|about|explore|support|press|api|privacy|safety|admin|help|terms|contact|blog|igtv)/;
+const bibliogramBypassPaths = /\/(accounts\/|embeds?.js)/;
+const bibliogramInstances = [
+ 'https://bibliogram.art',
+ 'https://bibliogram.snopyta.org'
+];
const osmDefault = 'https://openstreetmap.org';
const googleMapsRegex = /https?:\/\/(((www|maps)\.)?(google).*(\/maps)|maps\.(google).*)/;
const mapCentreRegex = /@(-?\d[0-9.]*),(-?\d[0-9.]*),(\d{1,2})[.z]/;
@@ -186,14 +196,19 @@ function redirectTwitter(url) {
}
}
-function redirectInstagram(url, initiator) {
+function redirectInstagram(url, initiator, type) {
if (disableBibliogram) {
return null;
}
- if (initiator && (initiator.origin === bibliogramInstance || initiator.host.match(instagramRegex))) {
+ // Do not redirect Bibliogram view on Instagram links
+ if (initiator && (initiator.origin === bibliogramInstance || instagramDomains.includes(initiator.host))) {
return null;
}
- if (url.pathname === '/' || url.pathname.match(instagramPathsRegex)) {
+ // Do not redirect /accounts, /embeds.js, or anything other than main_frame
+ if (url.pathname.match(bibliogramBypassPaths) || type !== 'main_frame') {
+ return null;
+ }
+ if (url.pathname === '/' || url.pathname.match(instagramReservedPaths)) {
return `${bibliogramInstance}${url.pathname}${url.search}`;
} else {
// Redirect user profile requests to '/u/...'
@@ -300,9 +315,9 @@ browser.webRequest.onBeforeRequest.addListener(
redirect = {
redirectUrl: redirectTwitter(url)
};
- } else if (url.host.match(instagramRegex)) {
+ } else if (instagramDomains.includes(url.host)) {
redirect = {
- redirectUrl: redirectInstagram(url, initiator)
+ redirectUrl: redirectInstagram(url, initiator, details.type)
};
} else if (url.href.match(googleMapsRegex)) {
redirect = {
@@ -322,3 +337,13 @@ browser.webRequest.onBeforeRequest.addListener(
},
['blocking']
);
+
+browser.runtime.onInstalled.addListener(
+ details => {
+ if (details.reason === 'install') {
+ browser.storage.sync.set({
+ bibliogramInstance: bibliogramInstances[~~(bibliogramInstances.length * Math.random())]
+ });
+ }
+ }
+);
diff --git a/manifest.json b/manifest.json
index eda653a..4e424c5 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.20",
+ "version": "1.1.21",
"manifest_version": 2,
"background": {
"scripts": [
diff --git a/pages/options/options.html b/pages/options/options.html
index 0a963b7..6054587 100644
--- a/pages/options/options.html
+++ b/pages/options/options.html
@@ -74,7 +74,7 @@
<datalist id="bibliogram-instance-list">
<option value="https://bibliogram.art">
<option value="https://bibliogram.snopyta.org">
- <option value="https://bibliogram.dsrev.ru">
+ <option value="https://bibliogram.pussthecat.org">
</datalist>
<h1>OpenStreetMap Instance</h1>
<input id="osm-instance" list="osm-instance-list" type="url" placeholder="https://openstreetmap.org">