about summary refs log tree commit diff stats
path: root/src/pages/background/background.js
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-02-26 01:31:48 +0300
committerManeraKai <manerakai@protonmail.com>2022-02-26 01:31:48 +0300
commit41e145bf7a63fc0a181370005f780d5e85f72e83 (patch)
tree05749311c1a8c7fa256dd5d2114776c7f706009b /src/pages/background/background.js
parentAdded youtube embed exceptions #46 (diff)
downloadlibredirect-41e145bf7a63fc0a181370005f780d5e85f72e83.zip
Made auto changing instances manual #59
Diffstat (limited to 'src/pages/background/background.js')
-rw-r--r--src/pages/background/background.js90
1 files changed, 1 insertions, 89 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 1f91ad4d..50b054ec 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -90,96 +90,8 @@ browser.webRequest.onBeforeRequest.addListener(
   ["blocking"]
 );
 
-browser.webRequest.onResponseStarted.addListener(
-  (responseDetails) => {
-    let url = new URL(responseDetails.url);
-    let protocolHost = `${url.protocol}//${url.host}`;
-    var mightyList = getMightyList();
-
-    if (mightyList.includes(protocolHost)); {
-      if (responseDetails.statusCode >= 500 && responseDetails.type === "main_frame") {
-        console.log("Instance is corrupted, redirecting", responseDetails.url);
-        changeInstance(responseDetails.url);
-      }
-    }
-  },
-  { urls: ["<all_urls>"] }
-);
-
 browser.tabs.onUpdated.addListener(
   (tabId, changeInfo) => {
     if (changeInfo.url && youtubeHelper.isUrlPipedorInvidious(changeInfo.url))
       youtubeHelper.invidiousInitCookies(tabId);
-  });
-
-function changeInstance(url) {
-  var tabUrl = new URL(url);
-  var protocolHost = `${tabUrl.protocol}//${tabUrl.host}`;
-  var newUrl;
-
-  console.log("wewe")
-  newUrl = youtubeHelper.changeInstance(url);
-
-  let twitterList = [...twitterHelper.getRedirects().nitter.normal];
-  if (twitterList.includes(protocolHost) && twitterList.length > 1) newUrl = 'https://twitter.com';
-
-  let instagramList = [...instagramHelper.getRedirects().bibliogram.normal];
-  if (instagramList.includes(protocolHost) && instagramList.length > 1) newUrl = 'https://instagram.com';
-
-  let redditList = [...redditHelper.getRedirects().libreddit.normal, ...redditHelper.getRedirects().teddit.normal]
-  if (redditList.includes(protocolHost) && redditList.length > 1) {
-    if (tabUrl.pathname.startsWith('/img')) {
-      newUrl = "https://i.redd.it"
-      tabUrl.href = tabUrl.href.replace("/img", "")
-    }
-    else
-      newUrl = 'https://reddit.com';
-  }
-
-  let searchList = [...searchHelper.getRedirects().searx.normal, ...searchHelper.getRedirects().whoogle.normal]
-  if (searchList.includes(protocolHost) && searchList.length > 1) newUrl = 'https://google.com';
-
-  let translateList = [...translateHelper.getRedirects().simplyTranslate.normal, ...translateHelper.getRedirects().lingva.normal]
-  if (translateList.includes(protocolHost) && translateList.length > 1) newUrl = 'https://translate.google.com';
-
-  let mediumList = [...mediumHelper.getRedirects().scribe.normal]
-  if (mediumList.includes(protocolHost) && mediumList.length > 1) newUrl = 'https://medium.com';
-
-  let imgurList = [...imgurHelper.getRedirects().rimgo.normal];
-  if (imgurList.includes(protocolHost) && imgurList.length > 1) newUrl = 'https://imgur.com';
-
-  let wikipediaList = [...wikipediaHelper.getRedirects().wikiless.normal]
-  if (wikipediaList.includes(protocolHost) && wikipediaList.length > 1) newUrl = 'https://wikipedia.com';
-
-  if (newUrl) browser.tabs.update({ url: tabUrl.href.replace(protocolHost, newUrl) });
-}
-
-function getMightyList() {
-  return [
-    ...youtubeHelper.getCustomRedirects().invidious.normal,
-    ...youtubeHelper.getCustomRedirects().piped.normal,
-
-    ...twitterHelper.getCustomRedirects().nitter.normal,
-
-    ...youtubeMusicHelper.getCustomRedirects().beatbump.normal,
-
-    ...instagramHelper.getCustomRedirects().bibliogram.normal,
-
-    ...redditHelper.getCustomRedirects().libreddit.normal,
-    ...redditHelper.getCustomRedirects().teddit.normal,
-    redditHelper.getCustomRedirects().desktop,
-    redditHelper.getCustomRedirects().mobile,
-
-    ...searchHelper.getCustomRedirects().searx.normal,
-    ...searchHelper.getCustomRedirects().whoogle.normal,
-
-    ...translateHelper.getCustomRedirects().simplyTranslate.normal,
-    ...translateHelper.getCustomRedirects().lingva.normal,
-
-    ...mediumHelper.getCustomRedirects().scribe.normal,
-
-    ...imgurHelper.getCustomRedirects().rimgo.normal,
-
-    ...wikipediaHelper.getCustomRedirects().wikiless.normal
-  ];
-}
+  });
\ No newline at end of file