Added Change Instance btn to address-bar
This commit is contained in:
parent
4c1290acb2
commit
398b122ec6
|
@ -14,7 +14,24 @@
|
||||||
"48": "assets/images/icon48.png",
|
"48": "assets/images/icon48.png",
|
||||||
"128": "assets/images/icon128.png"
|
"128": "assets/images/icon128.png"
|
||||||
},
|
},
|
||||||
"permissions": ["storage", "webRequest", "webRequestBlocking", "<all_urls>"],
|
"permissions": [
|
||||||
|
"storage",
|
||||||
|
"webRequest",
|
||||||
|
"webRequestBlocking",
|
||||||
|
"<all_urls>"
|
||||||
|
],
|
||||||
|
"page_action": {
|
||||||
|
"show_matches": [
|
||||||
|
"<all_urls>"
|
||||||
|
],
|
||||||
|
"default_title": "Change Instance",
|
||||||
|
"default_icon": {
|
||||||
|
"16": "assets/images/icon16.png",
|
||||||
|
"32": "assets/images/icon32.png",
|
||||||
|
"48": "assets/images/icon48.png",
|
||||||
|
"128": "assets/images/icon128.png"
|
||||||
|
}
|
||||||
|
},
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_title": "Privacy Redirect",
|
"default_title": "Privacy Redirect",
|
||||||
"default_popup": "pages/popup/popup.html",
|
"default_popup": "pages/popup/popup.html",
|
||||||
|
@ -34,7 +51,9 @@
|
||||||
"*://pbs.twimg.com/*",
|
"*://pbs.twimg.com/*",
|
||||||
"*://video.twimg.com/*"
|
"*://video.twimg.com/*"
|
||||||
],
|
],
|
||||||
"js": ["assets/javascripts/remove-twitter-sw.js"],
|
"js": [
|
||||||
|
"assets/javascripts/remove-twitter-sw.js"
|
||||||
|
],
|
||||||
"run_at": "document_start"
|
"run_at": "document_start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -63,7 +82,9 @@
|
||||||
"*://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion/*",
|
"*://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion/*",
|
||||||
"*://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion/*"
|
"*://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion/*"
|
||||||
],
|
],
|
||||||
"js": ["assets/javascripts/persist-invidious-prefs.js"],
|
"js": [
|
||||||
|
"assets/javascripts/persist-invidious-prefs.js"
|
||||||
|
],
|
||||||
"run_at": "document_start"
|
"run_at": "document_start"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -71,7 +92,9 @@
|
||||||
"page": "pages/options/options.html",
|
"page": "pages/options/options.html",
|
||||||
"open_in_tab": false
|
"open_in_tab": false
|
||||||
},
|
},
|
||||||
"web_accessible_resources": ["assets/javascripts/helpers/*"],
|
"web_accessible_resources": [
|
||||||
|
"assets/javascripts/helpers/*"
|
||||||
|
],
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "{b7f9d2cd-d772-4302-8c3f-eb941af36f76}",
|
"id": "{b7f9d2cd-d772-4302-8c3f-eb941af36f76}",
|
||||||
|
|
|
@ -299,8 +299,7 @@ function redirectYouTube(url, initiator, type) {
|
||||||
url.searchParams.append("autoplay", 1);
|
url.searchParams.append("autoplay", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${
|
return `${invidiousInstance || commonHelper.getRandomInstance(invidiousRandomPool)
|
||||||
invidiousInstance || commonHelper.getRandomInstance(invidiousRandomPool)
|
|
||||||
}${url.pathname.replace("/shorts", "")}${url.search}`;
|
}${url.pathname.replace("/shorts", "")}${url.search}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,16 +323,13 @@ function redirectTwitter(url, initiator) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
||||||
return `${
|
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
||||||
nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
|
||||||
}/pic/${encodeURIComponent(url.href)}`;
|
}/pic/${encodeURIComponent(url.href)}`;
|
||||||
} else if (url.pathname.split("/").includes("tweets")) {
|
} else if (url.pathname.split("/").includes("tweets")) {
|
||||||
return `${
|
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
||||||
nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
|
||||||
}${url.pathname.replace("/tweets", "")}${url.search}`;
|
}${url.pathname.replace("/tweets", "")}${url.search}`;
|
||||||
} else {
|
} else {
|
||||||
return `${
|
return `${nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
||||||
nitterInstance || commonHelper.getRandomInstance(nitterRandomPool)
|
|
||||||
}${url.pathname}${url.search}`;
|
}${url.pathname}${url.search}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,13 +355,11 @@ function redirectInstagram(url, initiator, type) {
|
||||||
url.pathname === "/" ||
|
url.pathname === "/" ||
|
||||||
instagramReservedPaths.includes(url.pathname.split("/")[1])
|
instagramReservedPaths.includes(url.pathname.split("/")[1])
|
||||||
) {
|
) {
|
||||||
return `${
|
return `${bibliogramInstance || commonHelper.getRandomInstance(bibliogramRandomPool)
|
||||||
bibliogramInstance || commonHelper.getRandomInstance(bibliogramRandomPool)
|
|
||||||
}${url.pathname}${url.search}`;
|
}${url.pathname}${url.search}`;
|
||||||
} else {
|
} else {
|
||||||
// Likely a user profile, redirect to '/u/...'
|
// Likely a user profile, redirect to '/u/...'
|
||||||
return `${
|
return `${bibliogramInstance || commonHelper.getRandomInstance(bibliogramRandomPool)
|
||||||
bibliogramInstance || commonHelper.getRandomInstance(bibliogramRandomPool)
|
|
||||||
}/u${url.pathname}${url.search}`;
|
}/u${url.pathname}${url.search}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,8 +386,7 @@ function redirectGoogleMaps(url, initiator) {
|
||||||
params = "&zoom=17";
|
params = "&zoom=17";
|
||||||
}
|
}
|
||||||
// Set map layer
|
// Set map layer
|
||||||
params = `${params}&layers=${
|
params = `${params}&layers=${layers[url.searchParams.get("layer")] || layers["none"]
|
||||||
layers[url.searchParams.get("layer")] || layers["none"]
|
|
||||||
}`;
|
}`;
|
||||||
// Handle Google Maps Embed API
|
// Handle Google Maps Embed API
|
||||||
if (url.pathname.split("/").includes("embed")) {
|
if (url.pathname.split("/").includes("embed")) {
|
||||||
|
@ -460,8 +453,7 @@ function redirectGoogleMaps(url, initiator) {
|
||||||
} else if (url.pathname.match(placeRegex)) {
|
} else if (url.pathname.match(placeRegex)) {
|
||||||
query = url.pathname.match(placeRegex)[1];
|
query = url.pathname.match(placeRegex)[1];
|
||||||
}
|
}
|
||||||
redirect = `${osmInstance}/${query ? "search?query=" + query : ""}${
|
redirect = `${osmInstance}/${query ? "search?query=" + query : ""}${mapCentre || "#"
|
||||||
mapCentre || "#"
|
|
||||||
}${params}`;
|
}${params}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,6 +533,8 @@ function redirectGoogleTranslate(url, initiator) {
|
||||||
return `${simplyTranslateInstance}/${url.search}`;
|
return `${simplyTranslateInstance}/${url.search}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldDomain = '';
|
||||||
|
|
||||||
function redirectWikipedia(url, initiator) {
|
function redirectWikipedia(url, initiator) {
|
||||||
if (disableWikipedia || isException(url, initiator)) {
|
if (disableWikipedia || isException(url, initiator)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -577,6 +571,8 @@ function redirectWikipedia(url, initiator) {
|
||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
browser.webRequest.onBeforeRequest.addListener(
|
browser.webRequest.onBeforeRequest.addListener(
|
||||||
(details) => {
|
(details) => {
|
||||||
const url = new URL(details.url);
|
const url = new URL(details.url);
|
||||||
|
@ -588,34 +584,42 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||||
}
|
}
|
||||||
let redirect;
|
let redirect;
|
||||||
if (youtubeDomains.includes(url.host)) {
|
if (youtubeDomains.includes(url.host)) {
|
||||||
|
oldDomain = 'https://youtube.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectYouTube(url, initiator, details.type),
|
redirectUrl: redirectYouTube(url, initiator, details.type),
|
||||||
};
|
};
|
||||||
} else if (twitterDomains.includes(url.host)) {
|
} else if (twitterDomains.includes(url.host)) {
|
||||||
|
oldDomain = 'https://twitter.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectTwitter(url, initiator),
|
redirectUrl: redirectTwitter(url, initiator),
|
||||||
};
|
};
|
||||||
} else if (instagramDomains.includes(url.host)) {
|
} else if (instagramDomains.includes(url.host)) {
|
||||||
|
oldDomain = 'https://instagram.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectInstagram(url, initiator, details.type),
|
redirectUrl: redirectInstagram(url, initiator, details.type),
|
||||||
};
|
};
|
||||||
} else if (url.href.match(googleMapsRegex)) {
|
} else if (url.href.match(googleMapsRegex)) {
|
||||||
|
oldDomain = 'https://maps.google.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectGoogleMaps(url, initiator),
|
redirectUrl: redirectGoogleMaps(url, initiator),
|
||||||
};
|
};
|
||||||
} else if (redditDomains.includes(url.host)) {
|
} else if (redditDomains.includes(url.host)) {
|
||||||
|
oldDomain = 'https://reddit.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectReddit(url, initiator, details.type),
|
redirectUrl: redirectReddit(url, initiator, details.type),
|
||||||
};
|
};
|
||||||
} else if (url.href.match(googleSearchRegex)) {
|
} else if (url.href.match(googleSearchRegex)) {
|
||||||
|
oldDomain = 'https://google.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectSearchEngine(url, initiator),
|
redirectUrl: redirectSearchEngine(url, initiator),
|
||||||
};
|
};
|
||||||
} else if (googleTranslateDomains.includes(url.host)) {
|
} else if (googleTranslateDomains.includes(url.host)) {
|
||||||
|
oldDomain = 'https://translate.google.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectGoogleTranslate(url, initiator),
|
redirectUrl: redirectGoogleTranslate(url, initiator),
|
||||||
};
|
};
|
||||||
} else if (url.host.match(wikipediaRegex)) {
|
} else if (url.host.match(wikipediaRegex)) {
|
||||||
|
oldDomain = 'https://wikipedia.com/';
|
||||||
redirect = {
|
redirect = {
|
||||||
redirectUrl: redirectWikipedia(url, initiator),
|
redirectUrl: redirectWikipedia(url, initiator),
|
||||||
};
|
};
|
||||||
|
@ -637,6 +641,8 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||||
["blocking"]
|
["blocking"]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
browser.runtime.onInstalled.addListener((details) => {
|
browser.runtime.onInstalled.addListener((details) => {
|
||||||
browser.storage.sync.get(
|
browser.storage.sync.get(
|
||||||
["disableSearchEngine", "disableSimplyTranslate", "disableWikipedia"],
|
["disableSearchEngine", "disableSimplyTranslate", "disableWikipedia"],
|
||||||
|
@ -680,3 +686,14 @@ browser.runtime.onInstalled.addListener((details) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function openPage() {
|
||||||
|
if (oldDomain != '') {
|
||||||
|
browser.tabs.update({
|
||||||
|
url: oldDomain
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
browser.pageAction.onClicked.addListener(openPage);
|
Loading…
Reference in New Issue