Add support for unifying settings
This commit is contained in:
parent
714ef46a8d
commit
c531943e48
|
@ -32,7 +32,7 @@ Quora => [Quetre](https://github.com/zyachel/quetre)\
|
|||
IMDb => [Libremdb](https://github.com/zyachel/libremdb)\
|
||||
PeerTube => [SimpleerTube](https://git.sr.ht/~metalune/simpleweb_peertube)\
|
||||
LBRY/Odysee => [Librarian](https://codeberg.org/librarian/librarian)\
|
||||
Search => [SearXNG](https://github.com/searxng/searxng), [SearX](https://searx.github.io/searx/), [Whoogle](https://benbusby.com/projects/whoogle-search/)\
|
||||
Search => [SearXNG](https://github.com/searxng/searxng), [SearX](https://searx.github.io/searx/), [Whoogle](https://benbusby.com/projects/whoogle-search/), [Librex](https://github.com/hnhx/librex/)\
|
||||
Translate => [SimplyTranslate](https://git.sr.ht/~metalune/simplytranslate_web), [LingvaTranslate](https://github.com/TheDavidDelta/lingva-translate)\
|
||||
Maps => [OpenStreetMap](https://www.openstreetmap.org/), [FacilMap](https://github.com/FacilMap/facilmap)\
|
||||
Send Files => [Send](https://gitlab.com/timvisee/send)
|
||||
|
|
|
@ -66,7 +66,7 @@ function setRedirects(val) {
|
|||
if (c > -1) whoogleNormalRedirectsChecks.splice(c, 1);
|
||||
|
||||
const d = librexNormalRedirectsChecks.indexOf(instance);
|
||||
if (c > -1) librexNormalRedirectsChecks.splice(d, 1);
|
||||
if (d > -1) librexNormalRedirectsChecks.splice(d, 1);
|
||||
}
|
||||
browser.storage.local.set({
|
||||
searchRedirects: redirects,
|
||||
|
@ -224,8 +224,9 @@ function pasteSearxCookies() {
|
|||
await init();
|
||||
if (disableSearch || searchFrontend != 'searx') { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (searchProtocol == 'normal') checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects]
|
||||
else if (searchProtocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects]
|
||||
if (searchProtocol == 'normal') checkedInstances = [...searxNormalRedirectsChecks, ...searxNormalCustomRedirects];
|
||||
else if (searchProtocol == 'tor') checkedInstances = [...searxTorRedirectsChecks, ...searxTorCustomRedirects];
|
||||
else if (searchProtocol == 'i2p') checkedInstances = [...searxI2pRedirectsChecks, ...searxI2pCustomRedirects];
|
||||
utils.getCookiesFromStorage('searx', checkedInstances, 'advanced_search');
|
||||
utils.getCookiesFromStorage('searx', checkedInstances, 'autocomplete');
|
||||
utils.getCookiesFromStorage('searx', checkedInstances, 'categories');
|
||||
|
@ -294,8 +295,9 @@ function pasteSearxngCookies() {
|
|||
await init();
|
||||
if (disableSearch || searchFrontend != 'searxng', searchProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (searchProtocol == 'normal') checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects]
|
||||
else if (searchProtocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects]
|
||||
if (searchProtocol == 'normal') checkedInstances = [...searxngNormalRedirectsChecks, ...searxngNormalCustomRedirects];
|
||||
else if (searchProtocol == 'tor') checkedInstances = [...searxngTorRedirectsChecks, ...searxngTorCustomRedirects];
|
||||
else if (searchProtocol == 'i2p') checkedInstances = [...searxngI2pRedirectsChecks, ...searxngI2pCustomRedirects];
|
||||
utils.getCookiesFromStorage('searxng', checkedInstances, 'autocomplete');
|
||||
utils.getCookiesFromStorage('searxng', checkedInstances, 'categories');
|
||||
utils.getCookiesFromStorage('searxng', checkedInstances, 'disabled_engines');
|
||||
|
@ -319,6 +321,56 @@ function pasteSearxngCookies() {
|
|||
})
|
||||
}
|
||||
|
||||
function initLibrexCookies(test, from) {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
let protocolHost = utils.protocolHost(from);
|
||||
if (![
|
||||
...librexNormalRedirectsChecks,
|
||||
...librexNormalCustomRedirects,
|
||||
...librexTorRedirectsChecks,
|
||||
...librexTorCustomRedirects,
|
||||
...librexI2pRedirectsChecks,
|
||||
...librexI2pCustomRedirects,
|
||||
].includes(protocolHost)) { resolve(); return; }
|
||||
|
||||
if(!test) {
|
||||
let checkedInstances;
|
||||
if (searchProtocol == 'normal') checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects];
|
||||
else if (searchProtocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects];
|
||||
else if (searchProtocol == 'i2p') checkedInstances = [...librexI2pRedirectsChecks, ...librexI2pCustomRedirects];
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'bibliogram');
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'disable_special');
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'invidious');
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'libreddit');
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'nitter');
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'proxitok');
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'theme');
|
||||
await utils.copyCookie('librex', from, checkedInstances, 'wikiless');
|
||||
}
|
||||
resolve(true);
|
||||
})
|
||||
}
|
||||
|
||||
function pasteLibrexCookies() {
|
||||
return new Promise(async resolve => {
|
||||
await init();
|
||||
if (disableSearch || searchFrontend != 'librex', searchProtocol === undefined) { resolve(); return; }
|
||||
let checkedInstances;
|
||||
if (searchProtocol == 'normal') checkedInstances = [...librexNormalRedirectsChecks, ...librexNormalCustomRedirects];
|
||||
else if (searchProtocol == 'tor') checkedInstances = [...librexTorRedirectsChecks, ...librexTorCustomRedirects];
|
||||
else if (searchProtocol == 'i2p') checkedInstances = [...librexI2pRedirectsChecks, ...librexI2pCustomRedirects];
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'bibliogram');
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'disable_special');
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'invidious');
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'libreddit');
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'nitter');
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'proxitok');
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'theme');
|
||||
utils.getCookiesFromStorage('librex', checkedInstances, 'wikiless');
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
|
||||
function redirect(url, disableOverride) {
|
||||
if (disableSearch && !disableOverride) return;
|
||||
|
@ -523,10 +575,10 @@ function initDefaults() {
|
|||
librexNormalRedirectsChecks: librexNormalRedirectsChecks,
|
||||
librexNormalCustomRedirects: [],
|
||||
|
||||
librexTorRedirectsChecks: librexTorRedirectsChecks,
|
||||
librexTorRedirectsChecks: [...redirects.librex.tor],
|
||||
librexTorCustomRedirects: [],
|
||||
|
||||
librexI2pRedirectsChecks: librexI2pRedirectsChecks,
|
||||
librexI2pRedirectsChecks: [...redirects.librex.i2p],
|
||||
librexI2pCustomRedirects: []
|
||||
}, () => resolve())
|
||||
})
|
||||
|
@ -540,6 +592,8 @@ export default {
|
|||
pasteSearxCookies,
|
||||
initSearxngCookies,
|
||||
pasteSearxngCookies,
|
||||
initLibrexCookies,
|
||||
pasteLibrexCookies,
|
||||
redirect,
|
||||
initDefaults,
|
||||
switchInstance,
|
||||
|
|
|
@ -46,7 +46,7 @@ function updateInstances() {
|
|||
instagramHelper.setRedirects(instances.bibliogram);
|
||||
redditHelper.setRedirects({ 'libreddit': instances.libreddit, 'teddit': instances.teddit });
|
||||
translateHelper.setRedirects({ "simplyTranslate": instances.simplyTranslate, "lingva": instances.lingva });
|
||||
searchHelper.setRedirects({ 'searx': instances.searx, 'searxng': instances.searxng, 'whoogle': instances.whoogle });
|
||||
searchHelper.setRedirects({ 'searx': instances.searx, 'searxng': instances.searxng, 'whoogle': instances.whoogle, 'librex': instances.librex });
|
||||
wikipediaHelper.setRedirects(instances.wikiless);
|
||||
mediumHelper.setRedirects(instances.scribe);
|
||||
quoraHelper.setRedirects(instances.quetre);
|
||||
|
@ -384,6 +384,7 @@ function unify(test) {
|
|||
|
||||
if (!result) result = await searchHelper.initSearxCookies(test, url);
|
||||
if (!result) result = await searchHelper.initSearxngCookies(test, url);
|
||||
if (!result) result = await searchHelper.initLibrexCookies(test, url);
|
||||
|
||||
if (!result) result = await tiktokHelper.initProxiTokCookies(test, url);
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ def librex():
|
|||
_list['i2p'] = []
|
||||
|
||||
tmp = re.findall(
|
||||
r"\| \[(?:(?:[a-zA-Z0-9]+\.)+[a-zA-Z]{2,}|✅)\]\((https?:\/{2}(?:[a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,})", r.text)
|
||||
r"\| {1,2}\[(?:(?:[a-zA-Z0-9]+\.)+[a-zA-Z]{2,}|✅)\]\((https?:\/{2}(?:[a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,})", r.text)
|
||||
tmp = filterLastSlash(tmp)
|
||||
|
||||
for item in tmp:
|
||||
|
|
|
@ -81,6 +81,7 @@ twitterHelper.pasteNitterCookies();
|
|||
wikipediaHelper.pasteWikilessCookies();
|
||||
searchHelper.pasteSearxCookies();
|
||||
searchHelper.pasteSearxngCookies();
|
||||
searchHelper.pasteLibrexCookies();
|
||||
redditHelper.pasteLibredditCookies();
|
||||
redditHelper.pasteTedditCookies();
|
||||
tiktokHelper.pasteProxiTokCookies();
|
||||
|
@ -257,4 +258,4 @@ browser.contextMenus.onClicked.addListener(
|
|||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.function === 'unify') utils.unify(false).then(r => sendResponse({ response: r }))
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,8 +14,9 @@ await twitterHelper.pasteNitterCookies();
|
|||
await wikipediaHelper.pasteWikilessCookies();
|
||||
await searchHelper.pasteSearxCookies();
|
||||
await searchHelper.pasteSearxngCookies();
|
||||
await searchHelper.pasteLibrexCookies();
|
||||
await redditHelper.pasteLibredditCookies();
|
||||
await redditHelper.pasteTedditCookies();
|
||||
await tiktokHelper.pasteProxiTokCookies();
|
||||
|
||||
window.close()
|
||||
window.close()
|
||||
|
|
|
@ -83,6 +83,7 @@ importSettingsElement.addEventListener("change",
|
|||
|
||||
await searchHelper.pasteSearxCookies();
|
||||
await searchHelper.pasteSearxngCookies();
|
||||
await searchHelper.pasteLibrexCookies();
|
||||
|
||||
await redditHelper.pasteLibredditCookies();
|
||||
await redditHelper.pasteTedditCookies();
|
||||
|
|
Loading…
Reference in New Issue