2022-02-02 15:46:14 +01:00
|
|
|
import commonHelper from './common.js'
|
|
|
|
|
2022-01-31 19:01:16 +01:00
|
|
|
const targets = [
|
2022-02-09 18:09:10 +01:00
|
|
|
/https?:\/\/(www\.|maps\.|search\.|)google\.com(\/search\?q=..*|\/$|)/,
|
2021-01-11 02:39:26 +01:00
|
|
|
];
|
2022-02-03 11:41:23 +01:00
|
|
|
let redirects = {
|
2022-02-06 03:58:42 +01:00
|
|
|
"searx": {
|
2022-02-01 19:37:43 +01:00
|
|
|
"normal": [
|
2022-01-31 19:01:16 +01:00
|
|
|
"https://a.searx.space",
|
|
|
|
"https://anon.sx",
|
|
|
|
"https://beezboo.com",
|
2022-02-04 16:48:24 +01:00
|
|
|
"https://darmarit.org/searx",
|
2022-01-31 19:01:16 +01:00
|
|
|
"https://dynabyte.ca",
|
|
|
|
"https://engo.mint.lgbt",
|
2022-02-08 16:28:25 +01:00
|
|
|
|
2022-01-31 19:01:16 +01:00
|
|
|
],
|
2022-02-01 19:37:43 +01:00
|
|
|
"onion": [
|
2022-02-04 16:48:24 +01:00
|
|
|
"http://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion",
|
|
|
|
"http://searxbgetrkiwxhdwi6svpgh7eotopqyxhbqiokrwzg7dcte44t36kyd.onion",
|
|
|
|
"http://suche.xyzco456vwisukfg.onion",
|
|
|
|
"http://w5rl6wsd7mzj4bdkbuqvzidet5osdsm5jhg2f7nvfidakfq5exda5wid.onion",
|
|
|
|
"http://4n53nafyi77iplnbrpmxnp3x4exbswwxigujaxy3b37fvr7bvlopxeyd.onion",
|
|
|
|
"http://z34ambyi6makk6ta7ksog2sljly2ctt2sa3apekb7wkllk72sxecdtad.onion",
|
|
|
|
"http://search.4bkxscubgtxwvhpe.onion",
|
|
|
|
"http://juy4e6eicawzdrz7.onion",
|
|
|
|
"http://z5vawdol25vrmorm4yydmohsd4u6rdoj2sylvoi3e3nqvxkvpqul7bqd.onion",
|
|
|
|
"http://zbuc3bbzbfdqqo2x46repx2ddajbha6fpsjeeptjhhhhzji3zopxdqyd.onion",
|
|
|
|
"http://f4qfqajszpx5b7itzxt6mb7kj4ktpgbdq7lq6xaiqyqx6a7de3epptad.onion",
|
|
|
|
"http://searx.cwuzdtzlubq5uual.onion",
|
|
|
|
"http://rq2w52kyrif3xpfihkgjnhqm3a5aqhoikpv72z3drpjglfzc2wr5z4yd.onion",
|
|
|
|
"http://searx3aolosaf3urwnhpynlhuokqsgz47si4pzz5hvb7uuzyjncl2tid.onion",
|
|
|
|
"http://searx.bsbvtqi5oq2cqzn32zt4cr2f2z2rwots3dq7gmdcnlyqoxko2wx6reqd.onion"
|
2022-02-01 19:37:43 +01:00
|
|
|
],
|
|
|
|
"i2p": [
|
2022-02-04 16:48:24 +01:00
|
|
|
"http://ransack.i2p",
|
|
|
|
"http://mqamk4cfykdvhw5kjez2gnvse56gmnqxn7vkvvbuor4k4j2lbbnq.b32.i2p"
|
2022-02-01 19:37:43 +01:00
|
|
|
]
|
|
|
|
},
|
2022-02-06 03:58:42 +01:00
|
|
|
"whoogle": {
|
2022-02-01 19:37:43 +01:00
|
|
|
"normal": [
|
2022-01-31 19:01:16 +01:00
|
|
|
"https://s.alefvanoon.xyz",
|
|
|
|
"https://search.albony.xyz",
|
|
|
|
"https://search.garudalinux.org",
|
|
|
|
"https://search.sethforprivacy.com",
|
|
|
|
"https://whoogle.fossho.st",
|
|
|
|
"https://whooglesearch.net",
|
|
|
|
"https://www.whooglesearch.ml",
|
2022-02-04 16:48:24 +01:00
|
|
|
"https://whoogle.dcs0.hu"
|
2022-01-31 19:01:16 +01:00
|
|
|
]
|
2022-02-04 16:48:24 +01:00
|
|
|
},
|
2022-02-01 19:37:43 +01:00
|
|
|
};
|
2022-02-04 00:13:37 +01:00
|
|
|
const getRedirects = () => redirects;
|
|
|
|
|
|
|
|
function setSearxRedirects(val) {
|
|
|
|
redirects.searx = val;
|
|
|
|
browser.storage.sync.set({ searchRedirects: redirects })
|
|
|
|
console.log("searxRedirects:", val)
|
2022-02-08 16:28:25 +01:00
|
|
|
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);
|
2022-02-04 00:13:37 +01:00
|
|
|
}
|
2022-02-06 15:24:39 +01:00
|
|
|
let whoogleRedirectsChecks;
|
|
|
|
const getWhoogleRedirectsChecks = () => whoogleRedirectsChecks;
|
|
|
|
function setWhoogleRedirectsChecks(val) {
|
|
|
|
whoogleRedirectsChecks = val;
|
|
|
|
browser.storage.sync.set({ whoogleRedirectsChecks })
|
|
|
|
console.log("whoogleRedirectsChecks: ", val)
|
2022-02-08 16:28:25 +01:00
|
|
|
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);
|
2022-02-06 15:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
let whoogleCustomRedirects = [];
|
|
|
|
const getWhoogleCustomRedirects = () => whoogleCustomRedirects;
|
|
|
|
function setWhoogleCustomRedirects(val) {
|
|
|
|
whoogleCustomRedirects = val;
|
|
|
|
browser.storage.sync.set({ whoogleCustomRedirects })
|
|
|
|
console.log("whoogleCustomRedirects: ", val)
|
|
|
|
}
|
|
|
|
|
|
|
|
let searxRedirectsChecks;
|
|
|
|
const getSearxRedirectsChecks = () => searxRedirectsChecks;
|
|
|
|
function setSearxRedirectsChecks(val) {
|
|
|
|
searxRedirectsChecks = val;
|
|
|
|
browser.storage.sync.set({ searxRedirectsChecks })
|
|
|
|
console.log("searxRedirectsChecks: ", val)
|
|
|
|
}
|
|
|
|
|
|
|
|
let searxCustomRedirects = [];
|
|
|
|
const getSearxCustomRedirects = () => searxCustomRedirects;
|
|
|
|
function setSearxCustomRedirects(val) {
|
|
|
|
searxCustomRedirects = val;
|
|
|
|
browser.storage.sync.set({ searxCustomRedirects })
|
|
|
|
console.log("searxCustomRedirects: ", val)
|
|
|
|
}
|
2022-02-04 00:13:37 +01:00
|
|
|
|
|
|
|
function setWhoogleRedirects(val) {
|
|
|
|
redirects.whoogle = val;
|
|
|
|
browser.storage.sync.set({ searchRedirects: redirects })
|
|
|
|
console.log("whoogleRedirects:", val)
|
|
|
|
}
|
|
|
|
|
2022-02-01 19:37:43 +01:00
|
|
|
let disableSearch;
|
|
|
|
const getDisableSearch = () => disableSearch;
|
|
|
|
function setDisableSearch(val) {
|
|
|
|
disableSearch = val;
|
|
|
|
browser.storage.sync.set({ disableSearch })
|
2022-02-02 15:46:14 +01:00
|
|
|
console.log("disableSearch: ", disableSearch)
|
2022-02-01 19:37:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
let searchFrontend;
|
|
|
|
const getSearchFrontend = () => searchFrontend;
|
|
|
|
function setSearchFrontend(val) {
|
|
|
|
searchFrontend = val;
|
|
|
|
browser.storage.sync.set({ searchFrontend })
|
2022-02-02 15:46:14 +01:00
|
|
|
console.log("searchFrontend: ", searchFrontend)
|
2022-02-01 19:37:43 +01:00
|
|
|
};
|
|
|
|
|
2022-02-04 00:13:37 +01:00
|
|
|
function redirect(url, initiator) {
|
2022-02-02 15:46:14 +01:00
|
|
|
if (disableSearch)
|
2022-02-01 19:37:43 +01:00
|
|
|
return null;
|
|
|
|
|
2022-02-06 15:24:39 +01:00
|
|
|
let randomInstance;
|
2022-02-01 19:37:43 +01:00
|
|
|
let path;
|
|
|
|
if (searchFrontend == 'searx') {
|
2022-02-06 15:24:39 +01:00
|
|
|
let instancesList = [...searxRedirectsChecks, ...searxCustomRedirects];
|
|
|
|
if (instancesList.length === 0) return null;
|
|
|
|
randomInstance = commonHelper.getRandomInstance(instancesList)
|
2022-02-01 19:37:43 +01:00
|
|
|
path = "/"
|
|
|
|
}
|
|
|
|
if (searchFrontend == 'whoogle') {
|
2022-02-06 15:24:39 +01:00
|
|
|
let instancesList = [...whoogleRedirectsChecks, ...whoogleCustomRedirects];
|
|
|
|
if (instancesList.length === 0) return null;
|
|
|
|
randomInstance = commonHelper.getRandomInstance(instancesList)
|
2022-02-01 19:37:43 +01:00
|
|
|
path = "/search"
|
|
|
|
}
|
|
|
|
|
|
|
|
let searchQuery = "";
|
|
|
|
url.search.slice(1).split("&").forEach(function (input) {
|
|
|
|
if (input.startsWith("q=")) searchQuery = input;
|
|
|
|
});
|
2022-02-06 15:24:39 +01:00
|
|
|
return `${randomInstance}${path}?${searchQuery}`;
|
2022-02-01 19:37:43 +01:00
|
|
|
}
|
|
|
|
|
2022-02-04 00:13:37 +01:00
|
|
|
function isSearch(url) {
|
|
|
|
return targets.some((rx) => rx.test(url.href));
|
|
|
|
}
|
|
|
|
|
2022-02-02 15:46:14 +01:00
|
|
|
async function init() {
|
|
|
|
let result = await browser.storage.sync.get([
|
|
|
|
"disableSearch",
|
|
|
|
"searchFrontend",
|
2022-02-04 00:13:37 +01:00
|
|
|
"searchRedirects",
|
2022-02-06 15:24:39 +01:00
|
|
|
"whoogleRedirectsChecks",
|
|
|
|
"whoogleCustomRedirects",
|
|
|
|
"searxRedirectsChecks",
|
|
|
|
"searxCustomRedirects",
|
2022-02-02 15:46:14 +01:00
|
|
|
])
|
2022-02-03 15:33:24 +01:00
|
|
|
disableSearch = result.disableSearch ?? false;
|
|
|
|
searchFrontend = result.searchFrontend ?? 'searx';
|
2022-02-04 00:13:37 +01:00
|
|
|
if (result.searchRedirects)
|
|
|
|
redirects = result.searchRedirects;
|
2022-02-06 15:24:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
whoogleRedirectsChecks = result.whoogleRedirectsChecks ?? [...redirects.whoogle.normal];
|
|
|
|
whoogleCustomRedirects = result.whoogleCustomRedirects ?? [];
|
|
|
|
|
2022-02-06 19:59:55 +01:00
|
|
|
searxRedirectsChecks = result.searxRedirectsChecks ?? [...redirects.searx.normal];
|
2022-02-08 16:28:25 +01:00
|
|
|
|
|
|
|
|
2022-02-06 15:24:39 +01:00
|
|
|
searxCustomRedirects = result.searxCustomRedirects ?? [];
|
2022-02-02 15:46:14 +01:00
|
|
|
}
|
|
|
|
|
2021-01-11 02:39:26 +01:00
|
|
|
export default {
|
|
|
|
targets,
|
2022-02-04 00:13:37 +01:00
|
|
|
isSearch,
|
|
|
|
|
|
|
|
getRedirects,
|
|
|
|
setSearxRedirects,
|
|
|
|
setWhoogleRedirects,
|
|
|
|
|
2022-02-01 19:37:43 +01:00
|
|
|
getDisableSearch,
|
|
|
|
setDisableSearch,
|
2022-02-04 00:13:37 +01:00
|
|
|
|
2022-02-01 19:37:43 +01:00
|
|
|
getSearchFrontend,
|
|
|
|
setSearchFrontend,
|
2022-02-04 00:13:37 +01:00
|
|
|
|
2022-02-06 15:24:39 +01:00
|
|
|
getWhoogleRedirectsChecks,
|
|
|
|
setWhoogleRedirectsChecks,
|
|
|
|
|
|
|
|
getWhoogleCustomRedirects,
|
|
|
|
setWhoogleCustomRedirects,
|
|
|
|
|
|
|
|
getSearxRedirectsChecks,
|
|
|
|
setSearxRedirectsChecks,
|
|
|
|
|
|
|
|
getSearxCustomRedirects,
|
|
|
|
setSearxCustomRedirects,
|
|
|
|
|
2022-02-01 19:37:43 +01:00
|
|
|
redirect,
|
2022-02-02 15:46:14 +01:00
|
|
|
init,
|
2021-01-11 02:39:26 +01:00
|
|
|
};
|