Skip to content

Commit 2b7e4c9

Browse files
committed
Update
1 parent 1374dae commit 2b7e4c9

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

tools/searxng.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
const MIN_MONTH_UPTIME = 95;
1313
const FALLBACKS = ['searx.bndkt.io', 'paulgo.io', 'search.im-in.space', 'search.ononoki.org', 'search.undertale.uk', 'searx.oloke.xyz', 'searxng.biz'];
1414

15+
const params = new URLSearchParams(window.location.search);
16+
1517
const loadInstances = async () => {
18+
const fallbacks = FALLBACKS.map(i => `https://${i}/`);
19+
if (params.get('fast') === 1) return fallbacks;
20+
1621
const response = await fetch('https://searx.space/data/instances.json');
1722
if (!response.ok) {
1823
console.log('fallback');
19-
return FALLBACKS.map(i => `https://${i}/`);
24+
return fallbacks;
2025
}
2126

2227
const instances = (await response.json()).instances;
@@ -57,20 +62,20 @@
5762
};
5863

5964
const redirect = (url, query) => {
60-
url.searchParams.set('q', query);
61-
url.searchParams.set('language', params.get('language') || detectLang(query));
65+
params
66+
.entries()
67+
.filter(([k, _]) => k !== 'fast')
68+
.forEach(([k, v]) => url.searchParams.set(k, v));
6269
console.log(url);
6370
window.location.replace(url.toString());
6471
};
6572

66-
const params = new URLSearchParams(window.location.search);
67-
const query = params.get('q');
68-
6973
const pick = xs => xs[Math.floor(Math.random() * xs.length)];
7074
const targetUrl = new URL(pick(await loadInstances()));
7175
targetUrl.pathname = '/search';
7276
targetUrl.searchParams.set('safesearch', params.get('safesearch') || '0');
7377

78+
const query = params.get('q');
7479
if (query) {
7580
redirect(targetUrl, query);
7681
} else {

0 commit comments

Comments
 (0)