about summary refs log tree commit diff stats
path: root/src/assets
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-02-08 18:28:25 +0300
committerManeraKai <manerakai@protonmail.com>2022-02-08 18:28:34 +0300
commit352c9127a69c60ba3320666973079d6dbc364400 (patch)
tree5cb2076dab760bb63ed446ea00ea1578506f051c /src/assets
parentBump version (diff)
downloadlibredirect-352c9127a69c60ba3320666973079d6dbc364400.zip
Added update instances to lingva. Fixed some bugs #16
Diffstat (limited to 'src/assets')
-rw-r--r--src/assets/javascripts/helpers/common.js17
-rw-r--r--src/assets/javascripts/helpers/instagram.js6
-rw-r--r--src/assets/javascripts/helpers/medium.js6
-rw-r--r--src/assets/javascripts/helpers/reddit.js12
-rw-r--r--src/assets/javascripts/helpers/search.js118
-rw-r--r--src/assets/javascripts/helpers/translate.js14
-rw-r--r--src/assets/javascripts/helpers/twitter.js6
-rw-r--r--src/assets/javascripts/helpers/wikipedia.js6
8 files changed, 83 insertions, 102 deletions
diff --git a/src/assets/javascripts/helpers/common.js b/src/assets/javascripts/helpers/common.js
index 52a41379..82d70e2e 100644
--- a/src/assets/javascripts/helpers/common.js
+++ b/src/assets/javascripts/helpers/common.js
@@ -14,13 +14,27 @@ function getRandomInstance(instances) {
   return instances[~~(instances.length * Math.random())];
 }
 
-function updateInstances() {
+async function wholeInit() {
+  await youtubeHelper.init();
+  await twitterHelper.init();
+  await instagramHelper.init();
+  await redditHelper.init();
+  await translateHelper.init();
+  await searchHelper.init();
+  await wikipediaHelper.init();
+  await mediumHelper.init();
+}
+
+async function updateInstances() {
   const apiEndpoint = 'https://raw.githubusercontent.com/libredirect/instances/main/data.json';
   let request = new XMLHttpRequest();
   request.open('GET', apiEndpoint, false);
   request.send(null);
 
   if (request.status === 200) {
+
+    await wholeInit();
+
     const instances = JSON.parse(request.responseText);
 
     youtubeHelper.setInvidiousRedirects(instances.invidious);
@@ -32,6 +46,7 @@ function updateInstances() {
     redditHelper.setTedditRedirects(instances.teddit);
 
     translateHelper.setSimplyTranslateRedirects(instances.simplyTranslate);
+    translateHelper.setLingvaRedirects(instances.lingva)
 
     searchHelper.setSearxRedirects(instances.searx);
     searchHelper.setWhoogleRedirects(instances.whoogle);
diff --git a/src/assets/javascripts/helpers/instagram.js b/src/assets/javascripts/helpers/instagram.js
index e3255cc8..dc28990a 100644
--- a/src/assets/javascripts/helpers/instagram.js
+++ b/src/assets/javascripts/helpers/instagram.js
@@ -26,6 +26,12 @@ function setRedirects(val) {
   redirects.bibliogram = val;
   browser.storage.sync.set({ instagramRedirects: redirects })
   console.log("instagramRedirects: ", val)
+  for (const item of bibliogramRedirectsChecks)
+    if (!redirects.bibliogram.normal.includes(item)) {
+      var index = bibliogramRedirectsChecks.indexOf(item);
+      if (index !== -1) bibliogramRedirectsChecks.splice(index, 1);
+    }
+  setBibliogramRedirectsChecks(bibliogramRedirectsChecks);
 }
 
 
diff --git a/src/assets/javascripts/helpers/medium.js b/src/assets/javascripts/helpers/medium.js
index d99eae1c..216fcf20 100644
--- a/src/assets/javascripts/helpers/medium.js
+++ b/src/assets/javascripts/helpers/medium.js
@@ -31,6 +31,12 @@ function setRedirects(val) {
   redirects.scribe = val;
   browser.storage.sync.set({ mediumRedirects: redirects })
   console.log("mediumRedirects: ", val)
+  for (const item of scribeRedirectsChecks)
+    if (!redirects.scribe.normal.includes(item)) {
+      var index = scribeRedirectsChecks.indexOf(item);
+      if (index !== -1) scribeRedirectsChecks.splice(index, 1);
+    }
+  setScribeRedirectsChecks(scribeRedirectsChecks);
 }
 
 let scribeRedirectsChecks;
diff --git a/src/assets/javascripts/helpers/reddit.js b/src/assets/javascripts/helpers/reddit.js
index fe7b0ec3..0c8d635d 100644
--- a/src/assets/javascripts/helpers/reddit.js
+++ b/src/assets/javascripts/helpers/reddit.js
@@ -78,6 +78,12 @@ function setLibredditRedirectsChecks(val) {
   libredditRedirectsChecks = val;
   browser.storage.sync.set({ libredditRedirectsChecks })
   console.log("libredditRedirectsChecks: ", val)
+  for (const item of libredditRedirectsChecks)
+    if (!redirects.libreddit.normal.includes(item)) {
+      var index = libredditRedirectsChecks.indexOf(item);
+      if (index !== -1) libredditRedirectsChecks.splice(index, 1);
+    }
+  setLibredditRedirectsChecks(libredditRedirectsChecks);
 }
 
 let libredditCustomRedirects = [];
@@ -94,6 +100,12 @@ function setTedditRedirectsChecks(val) {
   tedditRedirectsChecks = val;
   browser.storage.sync.set({ tedditRedirectsChecks })
   console.log("tedditRedirectsChecks: ", val)
+  for (const item of tedditRedirectsChecks)
+    if (!redirects.teddit.normal.includes(item)) {
+      var index = tedditRedirectsChecks.indexOf(item);
+      if (index !== -1) tedditRedirectsChecks.splice(index, 1);
+    }
+  setTedditRedirectsChecks(tedditRedirectsChecks);
 }
 
 let tedditCustomRedirects = [];
diff --git a/src/assets/javascripts/helpers/search.js b/src/assets/javascripts/helpers/search.js
index 906b970d..d20d3029 100644
--- a/src/assets/javascripts/helpers/search.js
+++ b/src/assets/javascripts/helpers/search.js
@@ -14,106 +14,7 @@ let redirects = {
       "https://darmarit.org/searx",
       "https://dynabyte.ca",
       "https://engo.mint.lgbt",
-      "https://jsearch.pw",
-      "https://metasearch.nl",
-      "https://nibblehole.com",
-      "https://northboot.xyz",
-      "https://paulgo.io",
-      "https://procurx.pt",
-      "https://putin.agency",
-      "https://quickso.eu.org",
-      "https://s.zhaocloud.net",
-      "https://search.076.ne.jp",
-      "https://search.activemail.de",
-      "https://search.anonymize.com",
-      "https://search.antonkling.se",
-      "https://search.asynchronousexchange.com",
-      "https://search.biboumail.fr",
-      "https://search.blou.xyz",
-      "https://search.bluelock.org",
-      "https://search.bus-hit.me",
-      "https://search.disroot.org",
-      "https://search.ethibox.fr",
-      "https://search.jigsaw-security.com",
-      "https://search.jpope.org",
-      "https://search.mdosch.de",
-      "https://search.neet.works",
-      "https://search.ononoki.org",
-      "https://search.snopyta.org",
-      "https://search.st8.at",
-      "https://search.stinpriza.org",
-      "https://search.trom.tf",
-      "https://search.zdechov.net",
-      "https://searx.bar",
-      "https://searx.be",
-      "https://searx.bissisoft.com",
-      "https://searx.divided-by-zero.eu",
-      "https://searx.dresden.network",
-      "https://searx.esmailelbob.xyz",
-      "https://searx.everdot.org",
-      "https://searx.fmac.xyz",
-      "https://searx.fossencdi.org",
-      "https://searx.gnous.eu",
-      "https://searx.gnu.style",
-      "https://searx.hardwired.link",
-      "https://searx.hummel-web.at",
-      "https://searx.lavatech.top",
-      "https://searx.mastodontech.de",
-      "https://searx.mha.fi",
-      "https://searx.mxchange.org",
-      "https://searx.nakhan.net",
-      "https://searx.netzspielplatz.de",
-      "https://searx.nevrlands.de",
-      "https://searx.ninja",
-      "https://searx.nixnet.services",
-      "https://searx.openhoofd.nl",
-      "https://searx.operationtulip.com",
-      "https://searx.org",
-      "https://searx.prvcy.eu",
-      "https://searx.pwoss.org",
-      "https://searx.rasp.fr",
-      "https://searx.roughs.ru",
-      "https://searx.ru",
-      "https://searx.run",
-      "https://searx.s1gm4.eu",
-      "https://searx.sadblog.xyz",
-      "https://searx.semipvt.com",
-      "https://searx.slash-dev.de",
-      "https://searx.solusar.de",
-      "https://searx.sp-codes.de",
-      "https://searx.stuehieyr.com",
-      "https://searx.sunless.cloud",
-      "https://searx.theanonymouse.xyz",
-      "https://searx.thegreenwebfoundation.org",
-      "https://searx.tiekoetter.com",
-      "https://searx.tk",
-      "https://searx.tux.land",
-      "https://searx.tuxcloud.net",
-      "https://searx.tyil.nl",
-      "https://searx.vitanetworks.link",
-      "https://searx.webheberg.info",
-      "https://searx.xkek.net",
-      "https://searx.xyz",
-      "https://searx.zackptg5.com",
-      "https://searx.zapashcanon.fr",
-      "https://searx.zecircle.xyz",
-      "https://searxzh.cn",
-      "https://seeks.hsbp.org",
-      "https://serx.cf",
-      "https://spot.ecloud.global",
-      "https://suche.dasnetzundich.de",
-      "https://suche.uferwerk.org",
-      "https://swag.pw",
-      "https://sx.catgirl.cloud",
-      "https://sx.fedi.tech",
-      "https://timdor.noip.me/searx",
-      "https://trovu.komun.org",
-      "https://www.gruble.de",
-      "https://www.perfectpixel.de/searx",
-      "https://www.searxs.eu",
-      "https://www.webrats.xyz",
-      "https://xeek.com",
-      "https://searx.roflcopter.fr"
+
     ],
     "onion": [
       "http://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion",
@@ -156,6 +57,15 @@ function setSearxRedirects(val) {
   redirects.searx = val;
   browser.storage.sync.set({ searchRedirects: redirects })
   console.log("searxRedirects:", val)
+  for (const item of searxRedirectsChecks) {
+    console.log(item)
+    if (!redirects.searx.normal.includes(item)) {
+      var index = searxRedirectsChecks.indexOf(item);
+      if (index !== -1) searxRedirectsChecks.splice(index, 1);
+      console.log(`Deleted ${item}`);
+    }
+  }
+  setSearxRedirectsChecks(searxRedirectsChecks);
 }
 let whoogleRedirectsChecks;
 const getWhoogleRedirectsChecks = () => whoogleRedirectsChecks;
@@ -163,6 +73,12 @@ function setWhoogleRedirectsChecks(val) {
   whoogleRedirectsChecks = val;
   browser.storage.sync.set({ whoogleRedirectsChecks })
   console.log("whoogleRedirectsChecks: ", val)
+  for (const item of whoogleRedirectsChecks)
+    if (!redirects.whoogle.normal.includes(item)) {
+      var index = whoogleRedirectsChecks.indexOf(item);
+      if (index !== -1) whoogleRedirectsChecks.splice(index, 1);
+    }
+  setWhoogleRedirectsChecks(whoogleRedirectsChecks);
 }
 
 let whoogleCustomRedirects = [];
@@ -261,6 +177,8 @@ async function init() {
   whoogleCustomRedirects = result.whoogleCustomRedirects ?? [];
 
   searxRedirectsChecks = result.searxRedirectsChecks ?? [...redirects.searx.normal];
+
+
   searxCustomRedirects = result.searxCustomRedirects ?? [];
 }
 
diff --git a/src/assets/javascripts/helpers/translate.js b/src/assets/javascripts/helpers/translate.js
index 5a765c94..2f9b61db 100644
--- a/src/assets/javascripts/helpers/translate.js
+++ b/src/assets/javascripts/helpers/translate.js
@@ -42,6 +42,12 @@ function setSimplyTranslateRedirects(val) {
   redirects.simplyTranslate = val;
   browser.storage.sync.set({ translateRedirects: redirects })
   console.log("simplyTranslateRedirects:", val)
+  for (const item of simplyTranslateRedirectsChecks)
+    if (!redirects.simplyTranslate.normal.includes(item)) {
+      var index = simplyTranslateRedirectsChecks.indexOf(item);
+      if (index !== -1) simplyTranslateRedirectsChecks.splice(index, 1);
+    }
+  setSimplyTranslateRedirectsChecks(simplyTranslateRedirectsChecks);
 }
 
 let simplyTranslateRedirectsChecks;
@@ -65,6 +71,12 @@ function setLingvaRedirects(val) {
   redirects.lingva = val;
   browser.storage.sync.set({ translateRedirects: redirects })
   console.log("lingvaRedirects:", val)
+  for (const item of lingvaRedirectsChecks)
+    if (!redirects.lingva.normal.includes(item)) {
+      var index = lingvaRedirectsChecks.indexOf(item);
+      if (index !== -1) lingvaRedirectsChecks.splice(index, 1);
+    }
+  setLingvaRedirectsChecks(lingvaRedirectsChecks);
 }
 
 let lingvaRedirectsChecks;
@@ -105,7 +117,7 @@ function redirect(url, initiator) {
     console.log("SimplyTranslate disabled")
     return null
   };
-  
+
   if (translateFrontend == 'simplyTranslate') {
 
     let instancesList = [...simplyTranslateRedirectsChecks, ...simplyTranslateCustomRedirects];
diff --git a/src/assets/javascripts/helpers/twitter.js b/src/assets/javascripts/helpers/twitter.js
index 7bf3ca1d..a56ceeb6 100644
--- a/src/assets/javascripts/helpers/twitter.js
+++ b/src/assets/javascripts/helpers/twitter.js
@@ -89,6 +89,12 @@ const getNitterRedirectsChecks = () => nitterRedirectsChecks;
 function setNitterRedirectsChecks(val) {
   nitterRedirectsChecks = val;
   browser.storage.sync.set({ nitterRedirectsChecks })
+  for (const item of nitterRedirectsChecks)
+  if (!redirects.nitter.normal.includes(item)) {
+    var index = nitterRedirectsChecks.indexOf(item);
+    if (index !== -1) nitterRedirectsChecks.splice(index, 1);
+  }
+setNitterRedirectsChecks(nitterRedirectsChecks);
   console.log("nitterRedirectsChecks: ", val)
 }
 
diff --git a/src/assets/javascripts/helpers/wikipedia.js b/src/assets/javascripts/helpers/wikipedia.js
index 8afecc78..a2d84d07 100644
--- a/src/assets/javascripts/helpers/wikipedia.js
+++ b/src/assets/javascripts/helpers/wikipedia.js
@@ -20,6 +20,12 @@ function setRedirects(val) {
   redirects.wikiless = val;
   browser.storage.sync.set({ wikipediaRedirects: redirects })
   console.log("wikipediaRedirects: ", val)
+  for (const item of wikilessRedirectsChecks)
+  if (!redirects.wikiless.normal.includes(item)) {
+    var index = wikilessRedirectsChecks.indexOf(item);
+    if (index !== -1) wikilessRedirectsChecks.splice(index, 1);
+  }
+setWikilessRedirectsChecks(wikilessRedirectsChecks);
 }
 
 let disableWikipedia;