Added support for yahoo, bing, yandex, ecosia #199
This commit is contained in:
parent
b657b1ae2b
commit
8b88d53dee
@ -19,6 +19,7 @@ body.option(dir="auto")
|
|||||||
option(value="searxng") SearXNG
|
option(value="searxng") SearXNG
|
||||||
option(value="whoogle") Whoogle
|
option(value="whoogle") Whoogle
|
||||||
option(value="startpage") Startpage
|
option(value="startpage") Startpage
|
||||||
|
option(value="ecosia") Ecosia
|
||||||
|
|
||||||
|
|
||||||
#searx-whoogle
|
#searx-whoogle
|
||||||
|
@ -4,8 +4,13 @@ import commonHelper from './common.js'
|
|||||||
|
|
||||||
const targets = [
|
const targets = [
|
||||||
/^https?:\/{2}(www\.|search\.|)google(\.[a-z]{2,3}){1,2}(\/search(\?.*|$)|\/$)/,
|
/^https?:\/{2}(www\.|search\.|)google(\.[a-z]{2,3}){1,2}(\/search(\?.*|$)|\/$)/,
|
||||||
/^https?:\/{2}libredirect\.invalid/
|
/^https?:\/{2}(www\.|)bing\.com/,
|
||||||
// /^https?:\/{2}yandex\.com(\...|)(\/search\/..*|\/$)/,
|
|
||||||
|
/^https?:\/{2}search\.yahoo(\.[a-z]{2,3}){1,2}/,
|
||||||
|
|
||||||
|
/^https?:\/{2}yandex(\.[a-z]{2,3}){1,2}/,
|
||||||
|
|
||||||
|
/^https?:\/{2}libredirect\.invalid/,
|
||||||
];
|
];
|
||||||
let redirects = {
|
let redirects = {
|
||||||
"searx": {
|
"searx": {
|
||||||
@ -25,7 +30,9 @@ let redirects = {
|
|||||||
},
|
},
|
||||||
"startpage": {
|
"startpage": {
|
||||||
"normal": "https://www.startpage.com",
|
"normal": "https://www.startpage.com",
|
||||||
"tor": null
|
},
|
||||||
|
"ecosia": {
|
||||||
|
"normal": "https://www.ecosia.org",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const getRedirects = () => redirects;
|
const getRedirects = () => redirects;
|
||||||
@ -398,8 +405,7 @@ function redirect(url) {
|
|||||||
if (!targets.some(rx => rx.test(url.href))) return;
|
if (!targets.some(rx => rx.test(url.href))) return;
|
||||||
if (url.searchParams.has('tbm')) return;
|
if (url.searchParams.has('tbm')) return;
|
||||||
|
|
||||||
if (!url.searchParams.has('q') && url.pathname != '/') return;
|
if (url.hostname.includes('google') && !url.searchParams.has('q') && url.pathname != '/') return;
|
||||||
|
|
||||||
let randomInstance;
|
let randomInstance;
|
||||||
let path;
|
let path;
|
||||||
if (frontend == 'searx') {
|
if (frontend == 'searx') {
|
||||||
@ -433,10 +439,21 @@ function redirect(url) {
|
|||||||
randomInstance = redirects.startpage.normal;
|
randomInstance = redirects.startpage.normal;
|
||||||
path = "/do/search";
|
path = "/do/search";
|
||||||
}
|
}
|
||||||
if (!url.searchParams.has('q')) path = '/';
|
else if (frontend == 'ecosia') {
|
||||||
|
randomInstance = redirects.ecosia.normal;
|
||||||
|
path = '/search';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
((url.hostname.includes('google') || url.hostname.includes('bing')) && !url.searchParams.has('q')) ||
|
||||||
|
(url.hostname.includes('yahoo') && !url.searchParams.has('p')) ||
|
||||||
|
(url.hostname.includes('yandex') && !url.searchParams.has('text'))
|
||||||
|
) path = '/';
|
||||||
|
|
||||||
let searchQuery = "";
|
let searchQuery = "";
|
||||||
if (url.searchParams.has('q')) searchQuery = `?q=${url.searchParams.get('q')}`;
|
|
||||||
|
if ((url.hostname.includes('google') || url.hostname.includes('bing') || url.hostname.includes('libredirect.invalid')) && url.searchParams.has('q')) searchQuery = `?q=${url.searchParams.get('q')}`;
|
||||||
|
if (url.hostname.includes('yahoo') && url.searchParams.has('p')) searchQuery = `?q=${url.searchParams.get('p')}`;
|
||||||
|
if (url.hostname.includes('yandex') && url.searchParams.has('text')) searchQuery = `?q=${url.searchParams.get('text')}`;
|
||||||
|
|
||||||
return `${randomInstance}${path}${searchQuery}`;
|
return `${randomInstance}${path}${searchQuery}`;
|
||||||
}
|
}
|
||||||
@ -500,7 +517,7 @@ function switchInstance(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
fetch('/instances/data.json').then(response => response.text()).then(data => {
|
||||||
let dataJson = JSON.parse(data);
|
let dataJson = JSON.parse(data);
|
||||||
browser.storage.local.get(
|
browser.storage.local.get(
|
||||||
@ -514,27 +531,27 @@ async function init() {
|
|||||||
|
|
||||||
"whoogleTorRedirectsChecks",
|
"whoogleTorRedirectsChecks",
|
||||||
"whoogleTorCustomRedirects",
|
"whoogleTorCustomRedirects",
|
||||||
|
|
||||||
"whoogleI2pRedirectsChecks",
|
"whoogleI2pRedirectsChecks",
|
||||||
"whoogleI2pCustomRedirects",
|
"whoogleI2pCustomRedirects",
|
||||||
|
|
||||||
"searxNormalRedirectsChecks",
|
"searxNormalRedirectsChecks",
|
||||||
"searxNormalCustomRedirects",
|
"searxNormalCustomRedirects",
|
||||||
|
|
||||||
"searxTorRedirectsChecks",
|
"searxTorRedirectsChecks",
|
||||||
"searxTorCustomRedirects",
|
"searxTorCustomRedirects",
|
||||||
|
|
||||||
"searxI2pRedirectsChecks",
|
"searxI2pRedirectsChecks",
|
||||||
"searxI2pCustomRedirects",
|
"searxI2pCustomRedirects",
|
||||||
|
|
||||||
"searxngNormalRedirectsChecks",
|
"searxngNormalRedirectsChecks",
|
||||||
"searxngNormalCustomRedirects",
|
"searxngNormalCustomRedirects",
|
||||||
|
|
||||||
"searxngTorRedirectsChecks",
|
"searxngTorRedirectsChecks",
|
||||||
"searxngTorCustomRedirects",
|
"searxngTorCustomRedirects",
|
||||||
|
|
||||||
"searxngI2pRedirectsChecks",
|
"searxngI2pRedirectsChecks",
|
||||||
"searxngI2pCustomRedirects",
|
"searxngI2pCustomRedirects",
|
||||||
|
|
||||||
"theme",
|
"theme",
|
||||||
"applyThemeToSites",
|
"applyThemeToSites",
|
||||||
@ -562,27 +579,27 @@ async function init() {
|
|||||||
whoogleTorRedirectsChecks = r.whoogleTorRedirectsChecks ?? [...redirects.whoogle.tor];
|
whoogleTorRedirectsChecks = r.whoogleTorRedirectsChecks ?? [...redirects.whoogle.tor];
|
||||||
whoogleTorCustomRedirects = r.whoogleTorCustomRedirects ?? [];
|
whoogleTorCustomRedirects = r.whoogleTorCustomRedirects ?? [];
|
||||||
|
|
||||||
whoogleI2pRedirectsChecks = r.whoogleI2pRedirectsChecks ?? [...redirects.whoogle.i2p];
|
whoogleI2pRedirectsChecks = r.whoogleI2pRedirectsChecks ?? [...redirects.whoogle.i2p];
|
||||||
whoogleI2pCustomRedirects = r.whoogleI2pCustomRedirects ?? [];
|
whoogleI2pCustomRedirects = r.whoogleI2pCustomRedirects ?? [];
|
||||||
|
|
||||||
searxNormalRedirectsChecks = r.searxNormalRedirectsChecks ?? [...redirects.searx.normal];
|
searxNormalRedirectsChecks = r.searxNormalRedirectsChecks ?? [...redirects.searx.normal];
|
||||||
searxNormalCustomRedirects = r.searxNormalCustomRedirects ?? [];
|
searxNormalCustomRedirects = r.searxNormalCustomRedirects ?? [];
|
||||||
|
|
||||||
searxTorRedirectsChecks = r.searxTorRedirectsChecks ?? [...redirects.searx.tor];
|
searxTorRedirectsChecks = r.searxTorRedirectsChecks ?? [...redirects.searx.tor];
|
||||||
searxTorCustomRedirects = r.searxTorCustomRedirects ?? [];
|
searxTorCustomRedirects = r.searxTorCustomRedirects ?? [];
|
||||||
|
|
||||||
searxI2pRedirectsChecks = r.searxI2pRedirectsChecks ?? [...redirects.searx.i2p];
|
searxI2pRedirectsChecks = r.searxI2pRedirectsChecks ?? [...redirects.searx.i2p];
|
||||||
searxI2pCustomRedirects = r.searxI2pCustomRedirects ?? [];
|
searxI2pCustomRedirects = r.searxI2pCustomRedirects ?? [];
|
||||||
|
|
||||||
searxngNormalRedirectsChecks = r.searxngNormalRedirectsChecks ?? [...redirects.searxng.normal];
|
searxngNormalRedirectsChecks = r.searxngNormalRedirectsChecks ?? [...redirects.searxng.normal];
|
||||||
searxngNormalCustomRedirects = r.searxngNormalCustomRedirects ?? [];
|
searxngNormalCustomRedirects = r.searxngNormalCustomRedirects ?? [];
|
||||||
|
|
||||||
searxngTorRedirectsChecks = r.searxngTorRedirectsChecks ?? [...redirects.searxng.tor];
|
searxngTorRedirectsChecks = r.searxngTorRedirectsChecks ?? [...redirects.searxng.tor];
|
||||||
searxngTorCustomRedirects = r.searxngTorCustomRedirects ?? [];
|
searxngTorCustomRedirects = r.searxngTorCustomRedirects ?? [];
|
||||||
|
|
||||||
searxngI2pRedirectsChecks = r.searxngI2pRedirectsChecks ?? [...redirects.searxng.i2p];
|
searxngI2pRedirectsChecks = r.searxngI2pRedirectsChecks ?? [...redirects.searxng.i2p];
|
||||||
searxngI2pCustomRedirects = r.searxngI2pCustomRedirects ?? [];
|
searxngI2pCustomRedirects = r.searxngI2pCustomRedirects ?? [];
|
||||||
|
|
||||||
initSearxCookies()
|
initSearxCookies()
|
||||||
initSearxngCookies()
|
initSearxngCookies()
|
||||||
// initWhoogleCookies()
|
// initWhoogleCookies()
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
<option value="searxng">SearXNG</option>
|
<option value="searxng">SearXNG</option>
|
||||||
<option value="whoogle">Whoogle</option>
|
<option value="whoogle">Whoogle</option>
|
||||||
<option value="startpage">Startpage</option>
|
<option value="startpage">Startpage</option>
|
||||||
|
<option value="ecosia">Ecosia</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="searx-whoogle">
|
<div id="searx-whoogle">
|
||||||
|
@ -34,7 +34,7 @@ function changeFrontendsSettings(frontend) {
|
|||||||
whoogleDivElement.style.display = 'block';
|
whoogleDivElement.style.display = 'block';
|
||||||
SearxWhoogleElement.style.display = 'block';
|
SearxWhoogleElement.style.display = 'block';
|
||||||
}
|
}
|
||||||
else if (frontend == 'startpage') {
|
else if (frontend == 'startpage' || frontend == 'ecosia') {
|
||||||
frontendElement.innerHTML = `Frontend: <span style="color:red;">This is a centralized service</span>`;
|
frontendElement.innerHTML = `Frontend: <span style="color:red;">This is a centralized service</span>`;
|
||||||
searxDivElement.style.display = 'none';
|
searxDivElement.style.display = 'none';
|
||||||
searxngDivElement.style.display = 'none';
|
searxngDivElement.style.display = 'none';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user