2020-08-27 07:22:46 +02:00
|
|
|
"use strict";
|
2019-10-07 13:59:31 +02:00
|
|
|
|
2022-02-04 16:48:24 +01:00
|
|
|
import youtubeHelper from "../../assets/javascripts/helpers/youtube/youtube.js";
|
2022-02-03 15:33:24 +01:00
|
|
|
import twitterHelper from "../../assets/javascripts/helpers/twitter.js";
|
2021-01-10 12:04:03 +01:00
|
|
|
import instagramHelper from "../../assets/javascripts/helpers/instagram.js";
|
|
|
|
import redditHelper from "../../assets/javascripts/helpers/reddit.js";
|
2022-02-02 19:22:34 +01:00
|
|
|
import searchHelper from "../../assets/javascripts/helpers/search.js";
|
2022-03-10 12:22:23 +01:00
|
|
|
import translateHelper from "../../assets/javascripts/helpers/translate/translate.js";
|
2022-02-03 11:41:23 +01:00
|
|
|
import mapsHelper from "../../assets/javascripts/helpers/maps.js";
|
2022-02-03 15:33:24 +01:00
|
|
|
import wikipediaHelper from "../../assets/javascripts/helpers/wikipedia.js";
|
|
|
|
import mediumHelper from "../../assets/javascripts/helpers/medium.js";
|
2022-02-08 21:04:18 +01:00
|
|
|
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
|
2022-02-09 22:04:00 +01:00
|
|
|
import tiktokHelper from "../../assets/javascripts/helpers/tiktok.js";
|
2022-04-14 23:26:03 +02:00
|
|
|
import speedtestHelper from "../../assets/javascripts/helpers/speedtest.js";
|
2022-03-10 08:30:23 +01:00
|
|
|
import sendTargetsHelper from "../../assets/javascripts/helpers/sendTargets.js";
|
2022-03-14 23:30:30 +01:00
|
|
|
import peertubeHelper from "../../assets/javascripts/helpers/peertube.js";
|
2022-03-16 08:59:34 +01:00
|
|
|
import lbryHelper from "../../assets/javascripts/helpers/lbry.js";
|
2022-03-19 11:33:51 +01:00
|
|
|
import spotifyHelper from "../../assets/javascripts/helpers/spotify.js";
|
2022-03-02 22:46:29 +01:00
|
|
|
import generalHelper from "../../assets/javascripts/helpers/general.js";
|
2022-02-23 21:45:22 +01:00
|
|
|
import youtubeMusicHelper from "../../assets/javascripts/helpers/youtubeMusic.js";
|
2019-10-07 13:59:31 +02:00
|
|
|
|
2020-02-24 04:19:56 +01:00
|
|
|
window.browser = window.browser || window.chrome;
|
|
|
|
|
2022-04-25 17:48:39 +02:00
|
|
|
browser.runtime.onInstalled.addListener(async details => {
|
|
|
|
if (details.reason == 'install') {
|
2022-05-04 12:59:37 +02:00
|
|
|
youtubeHelper.initDefaults();
|
|
|
|
youtubeMusicHelper.initDefaults();
|
|
|
|
twitterHelper.initDefaults();
|
|
|
|
instagramHelper.initDefaults();
|
|
|
|
mapsHelper.initDefaults();
|
|
|
|
searchHelper.initDefaults();
|
|
|
|
translateHelper.initDefaults();
|
|
|
|
mediumHelper.initDefaults();
|
|
|
|
redditHelper.initDefaults();
|
|
|
|
wikipediaHelper.initDefaults();
|
|
|
|
imgurHelper.initDefaults();
|
|
|
|
tiktokHelper.initDefaults();
|
|
|
|
speedtestHelper.initDefaults();
|
|
|
|
sendTargetsHelper.initDefaults();
|
|
|
|
peertubeHelper.initDefaults();
|
|
|
|
lbryHelper.initDefaults();
|
|
|
|
spotifyHelper.initDefaults();
|
2022-04-25 17:48:39 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-02-20 17:00:12 +01:00
|
|
|
async function wholeInit() {
|
2022-03-16 08:59:34 +01:00
|
|
|
await youtubeHelper.init();
|
|
|
|
await youtubeMusicHelper.init();
|
|
|
|
await twitterHelper.init();
|
|
|
|
await instagramHelper.init();
|
|
|
|
await mapsHelper.init();
|
|
|
|
await searchHelper.init();
|
|
|
|
await translateHelper.init();
|
|
|
|
await mediumHelper.init();
|
|
|
|
await redditHelper.init();
|
|
|
|
await wikipediaHelper.init();
|
|
|
|
await imgurHelper.init();
|
|
|
|
await tiktokHelper.init();
|
2022-04-14 23:26:03 +02:00
|
|
|
await speedtestHelper.init();
|
2022-03-16 08:59:34 +01:00
|
|
|
await sendTargetsHelper.init();
|
|
|
|
await peertubeHelper.init();
|
|
|
|
await lbryHelper.init();
|
2022-03-19 11:33:51 +01:00
|
|
|
await spotifyHelper.init();
|
2022-03-16 08:59:34 +01:00
|
|
|
await generalHelper.init();
|
2022-02-20 17:00:12 +01:00
|
|
|
}
|
2022-02-04 00:13:37 +01:00
|
|
|
|
2022-04-30 11:34:38 +02:00
|
|
|
let incognitoInit = false;
|
|
|
|
browser.tabs.onCreated.addListener(
|
|
|
|
tab => {
|
|
|
|
if (!incognitoInit && tab.incognito) {
|
|
|
|
browser.tabs.create({
|
|
|
|
url: browser.extension.getURL("/pages/background/incognito.html"),
|
|
|
|
});
|
|
|
|
incognitoInit = true;
|
|
|
|
}
|
|
|
|
});
|
2022-02-26 13:38:13 +01:00
|
|
|
|
2022-04-25 17:48:39 +02:00
|
|
|
|
2022-04-30 11:34:38 +02:00
|
|
|
let BYPASSTABs = [];
|
2022-04-25 17:48:39 +02:00
|
|
|
|
2020-02-24 04:19:56 +01:00
|
|
|
browser.webRequest.onBeforeRequest.addListener(
|
2022-05-04 12:59:37 +02:00
|
|
|
async details => {
|
|
|
|
await wholeInit();
|
2020-02-01 04:17:51 +01:00
|
|
|
const url = new URL(details.url);
|
2022-03-22 18:23:40 +01:00
|
|
|
// console.info("url:", url.href, "type:", details.type);
|
2020-03-31 08:39:57 +02:00
|
|
|
let initiator;
|
2022-01-30 21:36:07 +01:00
|
|
|
if (details.originUrl)
|
2020-03-31 08:39:57 +02:00
|
|
|
initiator = new URL(details.originUrl);
|
2022-01-30 21:36:07 +01:00
|
|
|
else if (details.initiator)
|
2020-07-12 03:26:48 +02:00
|
|
|
initiator = new URL(details.initiator);
|
2022-01-29 19:01:49 +01:00
|
|
|
|
2022-05-03 15:45:14 +02:00
|
|
|
let newUrl;
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-02-26 13:38:13 +01:00
|
|
|
if (!newUrl) newUrl = youtubeHelper.redirect(url, details, initiator)
|
|
|
|
if (youtubeMusicHelper.isYoutubeMusic(url, initiator)) newUrl = youtubeMusicHelper.redirect(url, details.type)
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-03-01 20:42:48 +01:00
|
|
|
if (!newUrl) newUrl = twitterHelper.redirect(url, initiator);
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-03-05 17:37:16 +01:00
|
|
|
if (!newUrl) newUrl = instagramHelper.redirect(url, details.type, initiator);
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-03-07 04:37:58 +01:00
|
|
|
if (!newUrl) newUrl = mapsHelper.redirect(url, initiator);
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-02-26 16:28:19 +01:00
|
|
|
if (!newUrl) newUrl = redditHelper.redirect(url, details.type, initiator);
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-03-15 12:48:36 +01:00
|
|
|
if (!newUrl) newUrl = mediumHelper.redirect(url, details.type, initiator);
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-05-03 15:45:14 +02:00
|
|
|
if (!newUrl) newUrl = imgurHelper.redirect(url, details.type, initiator);
|
2022-02-08 21:04:18 +01:00
|
|
|
|
2022-04-27 18:51:34 +02:00
|
|
|
if (!newUrl) newUrl = tiktokHelper.redirect(url, details.type, initiator);
|
2022-02-09 22:04:00 +01:00
|
|
|
|
2022-04-14 23:26:03 +02:00
|
|
|
if (!newUrl) newUrl = speedtestHelper.redirect(url, details.type, initiator);
|
|
|
|
|
2022-03-10 08:30:23 +01:00
|
|
|
if (!newUrl) newUrl = sendTargetsHelper.redirect(url, details.type, initiator);
|
|
|
|
|
2022-03-14 23:30:30 +01:00
|
|
|
if (!newUrl) newUrl = peertubeHelper.redirect(url, details.type, initiator);
|
|
|
|
|
2022-03-16 08:59:34 +01:00
|
|
|
if (!newUrl) newUrl = lbryHelper.redirect(url, details.type, initiator);
|
|
|
|
|
2022-03-19 11:33:51 +01:00
|
|
|
if (!newUrl) newUrl = spotifyHelper.redirect(url, details.type, initiator);
|
2022-03-16 17:58:55 +01:00
|
|
|
|
2022-03-10 12:22:23 +01:00
|
|
|
if (!newUrl) newUrl = translateHelper.redirect(url);
|
2022-02-02 17:13:44 +01:00
|
|
|
|
2022-03-10 08:57:10 +01:00
|
|
|
if (!newUrl) newUrl = searchHelper.redirect(url)
|
2022-01-31 19:01:16 +01:00
|
|
|
|
2022-03-10 12:22:23 +01:00
|
|
|
if (!newUrl) newUrl = wikipediaHelper.redirect(url);
|
2022-01-29 19:01:49 +01:00
|
|
|
|
2022-04-03 12:55:54 +02:00
|
|
|
if (
|
|
|
|
details.frameAncestors && details.frameAncestors.length > 0 &&
|
|
|
|
generalHelper.isException(new URL(details.frameAncestors[0].url))
|
|
|
|
) newUrl = null;
|
|
|
|
|
2022-04-03 14:23:52 +02:00
|
|
|
if (generalHelper.isException(url)) newUrl = 'BYPASSTAB';
|
2022-02-19 11:04:10 +01:00
|
|
|
|
2022-03-01 20:42:48 +01:00
|
|
|
if (BYPASSTABs.includes(details.tabId)) newUrl = null;
|
2022-02-26 13:38:13 +01:00
|
|
|
|
2022-01-29 19:01:49 +01:00
|
|
|
if (newUrl) {
|
2022-05-03 15:45:14 +02:00
|
|
|
if (newUrl === 'CANCEL') {
|
2022-02-05 13:49:12 +01:00
|
|
|
console.log(`Canceled ${url}`);
|
|
|
|
return { cancel: true };
|
|
|
|
}
|
2022-05-03 15:45:14 +02:00
|
|
|
else if (newUrl === 'BYPASSTAB') {
|
2022-03-01 20:42:48 +01:00
|
|
|
console.log(`Bybassed ${details.tabId} ${url}`);
|
2022-04-03 12:55:54 +02:00
|
|
|
if (!BYPASSTABs.includes(details.tabId)) BYPASSTABs.push(details.tabId);
|
2022-02-26 13:38:13 +01:00
|
|
|
return null;
|
|
|
|
}
|
2022-02-05 13:49:12 +01:00
|
|
|
else {
|
|
|
|
console.info("Redirecting", url.href, "=>", newUrl);
|
|
|
|
return { redirectUrl: newUrl };
|
|
|
|
}
|
2020-01-14 10:48:37 +01:00
|
|
|
}
|
2022-01-30 21:36:07 +01:00
|
|
|
return null;
|
2019-09-20 12:45:58 +02:00
|
|
|
},
|
2022-01-30 21:36:07 +01:00
|
|
|
{ urls: ["<all_urls>"], },
|
2020-08-27 07:22:46 +02:00
|
|
|
["blocking"]
|
2019-09-20 12:45:58 +02:00
|
|
|
);
|
2020-04-09 11:37:56 +02:00
|
|
|
|
2022-03-16 08:59:34 +01:00
|
|
|
browser.tabs.onRemoved.addListener(
|
|
|
|
tabId => {
|
|
|
|
let i = BYPASSTABs.indexOf(tabId);
|
|
|
|
if (i > -1) {
|
|
|
|
BYPASSTABs.splice(i, 1);
|
|
|
|
console.log("Removed BYPASSTABs", tabId);
|
|
|
|
}
|
2022-03-01 20:42:48 +01:00
|
|
|
}
|
2022-03-16 08:59:34 +01:00
|
|
|
);
|
2022-02-26 13:38:13 +01:00
|
|
|
|
2022-03-23 11:50:51 +01:00
|
|
|
browser.webRequest.onHeadersReceived.addListener(
|
2022-05-04 12:59:37 +02:00
|
|
|
async e => {
|
|
|
|
await wholeInit();
|
2022-03-23 11:50:51 +01:00
|
|
|
return twitterHelper.removeXFrameOptions(e);
|
|
|
|
},
|
|
|
|
{ urls: ["<all_urls>"], },
|
|
|
|
["blocking", "responseHeaders"]
|
|
|
|
);
|
|
|
|
|
2022-05-04 12:59:37 +02:00
|
|
|
async function redirectOfflineInstance(url, tabId) {
|
|
|
|
await wholeInit();
|
2022-03-22 19:57:01 +01:00
|
|
|
let newUrl;
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
newUrl = youtubeHelper.switchInstance(url);
|
|
|
|
if (!newUrl) newUrl = twitterHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = instagramHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = redditHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = searchHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = translateHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = mediumHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = imgurHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = wikipediaHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = peertubeHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = lbryHelper.switchInstance(url);
|
2022-03-16 08:59:34 +01:00
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
if (!newUrl) newUrl = spotifyHelper.switchInstance(url);
|
2022-03-09 20:52:58 +01:00
|
|
|
|
2022-04-18 07:06:05 +02:00
|
|
|
if (newUrl) {
|
|
|
|
if (counter >= 5) {
|
|
|
|
browser.tabs.update(tabId, { url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}` });
|
|
|
|
counter = 0;
|
|
|
|
} else {
|
|
|
|
browser.tabs.update(tabId, { url: newUrl });
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
}
|
2022-03-22 19:57:01 +01:00
|
|
|
}
|
2022-04-18 07:06:05 +02:00
|
|
|
let counter = 0;
|
2022-03-22 19:57:01 +01:00
|
|
|
browser.webRequest.onResponseStarted.addListener(
|
|
|
|
details => {
|
|
|
|
if (!generalHelper.getAutoRedirect()) return null;
|
2022-03-16 17:58:55 +01:00
|
|
|
|
2022-04-13 22:51:23 +02:00
|
|
|
console.log('details.statusCode', details.statusCode);
|
|
|
|
if (details.type == 'main_frame' && (details.statusCode == 502 || details.statusCode == 503 || details.statusCode == 504)) {
|
2022-03-22 19:57:01 +01:00
|
|
|
// if (details.type == 'main_frame' && details.statusCode >= 200) {
|
2022-03-31 05:19:51 +02:00
|
|
|
// console.log("statusCode", details.statusCode);
|
2022-03-22 19:57:01 +01:00
|
|
|
const url = new URL(details.url);
|
|
|
|
redirectOfflineInstance(url, details.tabId);
|
2022-03-09 20:52:58 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ urls: ["<all_urls>"], }
|
|
|
|
)
|
|
|
|
|
2022-03-22 19:57:01 +01:00
|
|
|
browser.webRequest.onErrorOccurred.addListener(
|
|
|
|
details => {
|
|
|
|
if (!generalHelper.getAutoRedirect()) return;
|
2022-03-31 05:19:51 +02:00
|
|
|
if (details.type == 'main_frame') {
|
|
|
|
const url = new URL(details.url);
|
|
|
|
redirectOfflineInstance(url, details.tabId);
|
|
|
|
}
|
2022-03-22 19:57:01 +01:00
|
|
|
},
|
|
|
|
{ urls: ["<all_urls>"], }
|
|
|
|
)
|
|
|
|
|
2022-02-19 13:48:28 +01:00
|
|
|
browser.tabs.onUpdated.addListener(
|
2022-05-04 12:59:37 +02:00
|
|
|
async (tabId, changeInfo, _) => {
|
|
|
|
await wholeInit();
|
2022-03-05 09:44:59 +01:00
|
|
|
let url;
|
|
|
|
try { url = new URL(changeInfo.url); }
|
|
|
|
catch (_) { return }
|
|
|
|
if (youtubeHelper.isPipedorInvidious(url, 'main_frame', 'piped')) youtubeHelper.initPipedLocalStorage(tabId);
|
2022-03-13 12:18:06 +01:00
|
|
|
if (youtubeHelper.isPipedorInvidious(url, 'main_frame', 'pipedMaterial')) youtubeHelper.initPipedMaterialLocalStorage(tabId);
|
2022-03-10 12:22:23 +01:00
|
|
|
if (translateHelper.isTranslateRedirects(url, 'main_frame', 'lingva')) translateHelper.initLingvaLocalStorage(tabId);
|
2022-03-05 12:16:58 +01:00
|
|
|
if (instagramHelper.isBibliogram(url)) instagramHelper.initBibliogramCookies(url);
|
2022-03-05 09:44:59 +01:00
|
|
|
// if (changeInfo.url && youtubeHelper.isPipedorInvidious(url, 'main_frame', 'pipedMaterial')) youtubeHelper.initPipedMaterialLocalStorage(tabId);
|
2022-04-03 12:55:54 +02:00
|
|
|
}
|
|
|
|
);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-05-04 12:59:37 +02:00
|
|
|
async function changeWholeInstance(url) {
|
|
|
|
await wholeInit();
|
2022-03-18 23:19:46 +01:00
|
|
|
let newUrl = youtubeHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = twitterHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = instagramHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = redditHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = searchHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = translateHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = mediumHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = sendTargetsHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = peertubeHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = imgurHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
2022-03-18 23:19:46 +01:00
|
|
|
if (!newUrl) newUrl = wikipediaHelper.switchInstance(url);
|
2022-03-15 14:16:17 +01:00
|
|
|
|
|
|
|
return newUrl;
|
|
|
|
}
|
|
|
|
|
2022-03-15 19:55:03 +01:00
|
|
|
browser.commands.onCommand.addListener(
|
|
|
|
command => {
|
2022-03-18 23:19:46 +01:00
|
|
|
if (command === 'switchInstance')
|
2022-04-02 17:23:43 +02:00
|
|
|
browser.tabs.query(
|
2022-03-15 19:55:03 +01:00
|
|
|
{ active: true, currentWindow: true },
|
|
|
|
tabs => {
|
|
|
|
let url;
|
|
|
|
try { url = new URL(tabs[0].url); }
|
|
|
|
catch (_) { return }
|
|
|
|
let newUrl = changeWholeInstance(url);
|
|
|
|
if (newUrl) browser.tabs.update({ url: newUrl });
|
|
|
|
}
|
|
|
|
);
|
2022-03-15 14:16:17 +01:00
|
|
|
}
|
2022-03-18 23:19:46 +01:00
|
|
|
)
|
|
|
|
|
2022-04-14 01:53:47 +02:00
|
|
|
browser.contextMenus.create({
|
2022-03-18 23:19:46 +01:00
|
|
|
id: "settings",
|
2022-04-02 17:23:43 +02:00
|
|
|
title: browser.i18n.getMessage("Settings"),
|
2022-03-18 23:19:46 +01:00
|
|
|
contexts: ["browser_action"]
|
|
|
|
});
|
|
|
|
|
2022-04-14 01:53:47 +02:00
|
|
|
browser.contextMenus.create({
|
2022-03-18 23:19:46 +01:00
|
|
|
id: "switchInstance",
|
2022-04-02 17:23:43 +02:00
|
|
|
title: chrome.i18n.getMessage("switchInstance"),
|
2022-03-18 23:19:46 +01:00
|
|
|
contexts: ["browser_action"]
|
|
|
|
});
|
|
|
|
|
2022-04-14 01:53:47 +02:00
|
|
|
browser.contextMenus.onClicked.addListener((info, tab) => {
|
2022-03-18 23:19:46 +01:00
|
|
|
if (info.menuItemId == 'switchInstance') {
|
|
|
|
let url;
|
|
|
|
try { url = new URL(tab.url); }
|
|
|
|
catch (_) { return }
|
|
|
|
let newUrl = changeWholeInstance(url);
|
|
|
|
if (newUrl) browser.tabs.update({ url: newUrl });
|
|
|
|
}
|
|
|
|
else if (info.menuItemId == 'settings')
|
|
|
|
browser.runtime.openOptionsPage()
|
2022-04-02 17:23:43 +02:00
|
|
|
});
|