aboutsummaryrefslogtreecommitdiffstats
path: root/src/assets/javascripts
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-01-31 21:01:16 +0300
committerManeraKai <manerakai@protonmail.com>2022-01-31 21:01:24 +0300
commit540b41ef0a752bf7aa0d90df37bdb69a28b6f39f (patch)
tree741443b9b61f81b0c8690c3c71aed75bc770c781 /src/assets/javascripts
parentUpdating RandomPools (diff)
downloadlibredirect-540b41ef0a752bf7aa0d90df37bdb69a28b6f39f.zip
Refining code. Adding frontend option to search
Diffstat (limited to 'src/assets/javascripts')
-rw-r--r--src/assets/javascripts/helpers/common.js22
-rw-r--r--src/assets/javascripts/helpers/google-search.js165
-rw-r--r--src/assets/javascripts/persist-invidious-prefs.js6
3 files changed, 163 insertions, 30 deletions
diff --git a/src/assets/javascripts/helpers/common.js b/src/assets/javascripts/helpers/common.js
index 066869ec..a2f951ae 100644
--- a/src/assets/javascripts/helpers/common.js
+++ b/src/assets/javascripts/helpers/common.js
@@ -1,6 +1,8 @@
function filterInstances(instances) {
- return instances.filter((instance) => !instance.includes(".onion"));
+ let onionScan = instances.filter((instance) => !instance.includes(".onion"))
+ let i2pScan = onionScan.filter((instance) => !instance.includes(".i2p"))
+ return i2pScan;
}
function addHttps(instances) {
@@ -8,11 +10,10 @@ function addHttps(instances) {
}
function getRandomInstance(instances) {
- console.info(instances.length * Math.random(), "=>", instances.length * Math.random())
return instances[~~(instances.length * Math.random())];
}
-function getInstances() {
+function updateInstances() {
const apiEndpoint = 'https://raw.githubusercontent.com/libredirect/instances/main/data.json';
let request = new XMLHttpRequest();
request.open('GET', apiEndpoint, false);
@@ -20,18 +21,27 @@ function getInstances() {
if (request.status === 200) {
const instances = JSON.parse(request.responseText);
- const list = addHttps(filterInstances(instances.nitter));
const invidiousRandomPool = addHttps(filterInstances(instances.invidious));
+ const nitterRandomPool = addHttps(filterInstances(instances.nitter));
const bibliogramRandomPool = addHttps(filterInstances(instances.bibliogram));
+ const tedditRandomPool = addHttps(filterInstances(instances.teddit));
+ const simplyTranslateRandomPool = addHttps(filterInstances(instances.simplyTranslate))
+ const searxRandomPool = addHttps(filterInstances(instances.simplyTranslate));
+ const whoogleRandomPool = addHttps(filterInstances(instances.whoogle));
const wikilessRandomPool = addHttps(filterInstances(instances.wikiless));
const scribeRandomPool = addHttps(filterInstances(instances.scribe));
browser.storage.sync.set({
- list,
invidiousRandomPool,
+ nitterRandomPool,
bibliogramRandomPool,
+ tedditRandomPool,
+ searxRandomPool,
+ whoogleRandomPool,
+ simplyTranslateRandomPool,
wikilessRandomPool,
scribeRandomPool
});
+ console.info("Successfully updated Instances")
return true;
}
return false;
@@ -88,7 +98,7 @@ function updateListElement(listElement, list) {
export default {
filterInstances,
getRandomInstance,
- getInstances,
+ updateInstances,
addHttps,
debounce,
validURL,
diff --git a/src/assets/javascripts/helpers/google-search.js b/src/assets/javascripts/helpers/google-search.js
index 8bd6a101..fa38df10 100644
--- a/src/assets/javascripts/helpers/google-search.js
+++ b/src/assets/javascripts/helpers/google-search.js
@@ -1,25 +1,148 @@
-const targets = /https?:\/\/(((www|maps)\.)?(google\.).*(\/search)|search\.(google\.).*)/;
-const redirects = [
- { link: "https://duckduckgo.com", q: "/" },
- { link: "https://startpage.com", q: "/search/" },
- { link: "https://www.ecosia.org", q: "/search" },
- { link: "https://www.qwant.com", q: "/" },
- { link: "https://www.mojeek.com", q: "/search" },
- { link: "https://search.snopyta.org", q: "/" },
- { link: "https://searx.info", q: "/" },
- { link: "https://searx.be", q: "/" },
- { link: "https://search.disroot.org", q: "/" },
- { link: "https://searx.tuxcloud.net", q: "/" },
- { link: "https://searx.ninja", q: "/" },
- { link: "https://tromland.org/searx", q: "/search" },
- { link: "https://engine.presearch.org", q: "/search" },
- { link: "https://searx.silkky.cloud", q: "/" },
- { link: "https://search.trom.tf", q: "/" },
- { link: "https://whooglesearch.net", q: "/search" },
- { link: "https://whoogle.sdf.org", q: "/search" },
- { link: "https://whoogle.himiko.cloud", q: "/search" },
- { link: "https://whoogle-search.zeet.app", q: "/search" },
+const targets = [
+ /https:\/\/google\.com/,
+ /https:\/\/.*\.google\.com/,
+ /https?:\/\/(((www|maps)\.)?(google\.).*(\/search)|search\.(google\.).*)/
];
+const redirects = {
+ "searx":
+ [
+ "https://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion",
+ "https://ransack.i2p",
+ "https://mqamk4cfykdvhw5kjez2gnvse56gmnqxn7vkvvbuor4k4j2lbbnq.b32.i2p",
+ "https://searxbgetrkiwxhdwi6svpgh7eotopqyxhbqiokrwzg7dcte44t36kyd.onion",
+ "https://suche.xyzco456vwisukfg.onion",
+ "https://w5rl6wsd7mzj4bdkbuqvzidet5osdsm5jhg2f7nvfidakfq5exda5wid.onion",
+ "https://a.searx.space",
+ "https://anon.sx",
+ "https://beezboo.com",
+ "https://darmarit.org",
+ "https://dynabyte.ca",
+ "https://engo.mint.lgbt",
+ "https://jsearch.pw",
+ "https://metasearch.nl",
+ "https://nibblehole.com",
+ "https://northboot.xyz",
+ "https://4n53nafyi77iplnbrpmxnp3x4exbswwxigujaxy3b37fvr7bvlopxeyd.onion",
+ "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://z34ambyi6makk6ta7ksog2sljly2ctt2sa3apekb7wkllk72sxecdtad.onion",
+ "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.4bkxscubgtxwvhpe.onion",
+ "https://search.ononoki.org",
+ "https://search.snopyta.org",
+ "https://juy4e6eicawzdrz7.onion",
+ "https://search.st8.at",
+ "https://search.stinpriza.org",
+ "https://z5vawdol25vrmorm4yydmohsd4u6rdoj2sylvoi3e3nqvxkvpqul7bqd.onion",
+ "https://search.trom.tf",
+ "https://search.zdechov.net",
+ "https://searx.bar",
+ "https://searx.be",
+ "https://searx.bissisoft.com",
+ "https://zbuc3bbzbfdqqo2x46repx2ddajbha6fpsjeeptjhhhhzji3zopxdqyd.onion",
+ "https://searx.divided-by-zero.eu",
+ "https://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion",
+ "https://searx.dresden.network",
+ "https://searx.esmailelbob.xyz",
+ "https://searx.everdot.org",
+ "https://searx.feneas.org",
+ "https://searx.fmac.xyz",
+ "https://searx.fossencdi.org",
+ "https://searx.cwuzdtzlubq5uual.onion",
+ "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://rq2w52kyrif3xpfihkgjnhqm3a5aqhoikpv72z3drpjglfzc2wr5z4yd.onion",
+ "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://searx3aolosaf3urwnhpynlhuokqsgz47si4pzz5hvb7uuzyjncl2tid.onion",
+ "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.bsbvtqi5oq2cqzn32zt4cr2f2z2rwots3dq7gmdcnlyqoxko2wx6reqd.onion",
+ "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",
+ "https://trovu.komun.org",
+ "https://www.gruble.de",
+ "https://www.perfectpixel.de",
+ "https://www.searxs.eu",
+ "https://www.webrats.xyz",
+ "https://xeek.com",
+ "searx.roflcopter.fr"
+ ],
+ "whoogle":
+ [
+ "https://s.alefvanoon.xyz",
+ "https://search.albony.xyz",
+ "https://search.exonip.de",
+ "https://search.garudalinux.org",
+ "https://search.sethforprivacy.com",
+ "https://whoogle.fossho.st",
+ "https://whooglesearch.net",
+ "https://www.whooglesearch.ml",
+ "https://whoogle.dcs0.hu",
+ ]
+};
export default {
targets,
diff --git a/src/assets/javascripts/persist-invidious-prefs.js b/src/assets/javascripts/persist-invidious-prefs.js
index dff2dd5a..9e313059 100644
--- a/src/assets/javascripts/persist-invidious-prefs.js
+++ b/src/assets/javascripts/persist-invidious-prefs.js
@@ -17,12 +17,12 @@ function getCookie() {
}
browser.storage.sync.get(
- ["alwaysProxy", "videoQuality", "invidiousDarkMode", "persistInvidiousPrefs"],
+ ["invidiousAlwaysProxy", "invidiousVideoQuality", "invidiousDarkMode", "persistInvidiousPrefs"],
(result) => {
if (result.persistInvidiousPrefs) {
const prefs = getCookie();
- prefs.local = result.alwaysProxy;
- prefs.quality = result.videoQuality;
+ prefs.local = result.invidiousAlwaysProxy;
+ prefs.quality = result.invidiousVideoQuality;
prefs.dark_mode = result.invidiousDarkMode;
document.cookie = `PREFS=${encodeURIComponent(JSON.stringify(prefs))}`;
}