Completing on supporting tor #32

This commit is contained in:
ManeraKai 2022-02-20 19:00:12 +03:00
parent 7b51851eeb
commit 1a1e0c988c
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
6 changed files with 99 additions and 116 deletions

View File

@ -3,7 +3,7 @@ window.browser = window.browser || window.chrome;
import commonHelper from './common.js'
const targets = [
/https?:\/\/(www\.|maps\.|search\.|)google\.com(\/search\?q=..*|\/$)/,
/https?:\/\/(www\.|maps\.|search\.|)google\.com(\/search\?..*|\/$)/,
];
let redirects = {
"searx": {
@ -132,7 +132,8 @@ let redirects = {
"https://whooglesearch.net",
"https://www.whooglesearch.ml",
"https://whoogle.dcs0.hu"
]
],
"tor": []
},
};
const getRedirects = () => redirects;

View File

@ -96,7 +96,7 @@ function setRedirects(val) {
redirects.nitter = val;
browser.storage.sync.set({ twitterRedirects: redirects })
console.log("twitterRedirects:", val)
for (const item of nitterRedirectsChecks)
for (const item of nitterNormalRedirectsChecks)
if (!redirects.nitter.normal.includes(item)) {
var index = nitterRedirectsChecks.indexOf(item);
if (index !== -1) nitterRedirectsChecks.splice(index, 1);

View File

@ -18,29 +18,8 @@ const targets = [
];
let redirects = {
"invidious": {
"normal": [
"https://yewtu.be",
"https://invidious.snopyta.org",
"https://vid.puffyan.us",
"https://invidious.kavin.rocks",
"https://invidio.xamh.de",
"https://inv.riverside.rocks",
"https://invidious-us.kavin.rocks",
"https://invidious.osi.kr",
"https://inv.cthd.icu",
"https://yt.artemislena.eu",
"https://youtube.076.ne.jp",
"https://invidious.namazso.eu"
],
"tor": [
"http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion",
"http://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion",
"http://kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad.onion",
"http://grwp24hodrefzvjjuccrkw3mjq4tzhaaq32amf33dzpmuxe7ilepcmad.onion",
"http://hpniueoejy4opn7bc4ftgazyqjoeqwlvh2uiku2xqku6zpoa4bf5ruid.onion",
"http://osbivz6guyeahrwp2lnwyjk2xos342h4ocsxyqrlaopqjuhwn2djiiyd.onion",
"http://u2cvlit75owumwpy4dj2hsmvkq7nvrclkpht7xgyye2pyoxhpmclkrad.onion"
]
"normal": [],
"tor": []
},
"piped": {
"normal": [
@ -55,7 +34,7 @@ let redirects = {
const getRedirects = () => redirects;
const getCustomRedirects = function () {
function getCustomRedirects() {
return {
"invidious": {
"normal": [...invidiousNormalRedirectsChecks, ...invidiousNormalCustomRedirects],
@ -141,9 +120,6 @@ function setPipedTorCustomRedirects(val) {
console.log("pipedTorCustomRedirects: ", val)
}
function setPipedRedirects(val) {
redirects.piped = val;
browser.storage.sync.set({ youtubeRedirects: redirects })
@ -418,8 +394,9 @@ function addUrlParams(url) {
...redirects.invidious.normal,
...redirects.invidious.tor,
...invidiousNormalCustomRedirects,
...invidiousTorCustomRedirects,
].includes(protocolHost)) {
...invidiousTorCustomRedirects
].includes(protocolHost)
) {
if (!url.searchParams.has("dark_mode") && theme != "DEFAULT") {
url.searchParams.append("dark_mode", theme);
isChanged = true;
@ -461,7 +438,8 @@ function addUrlParams(url) {
...redirects.piped.tor,
...pipedNormalCustomRedirects,
...pipedTorCustomRedirects,
].includes(protocolHost)) {
].includes(protocolHost)
) {
if (!url.searchParams.has("theme") && theme != "DEFAULT") {
url.searchParams.append("theme", theme);
@ -493,76 +471,81 @@ function invidiousInitCookies(tabId) {
);
}
async function init() {
return new Promise((resolve) => {
browser.storage.sync.get(
[
"invidiousAlwaysProxy",
"invidiousVideoQuality",
"youtubeTheme",
"persistInvidiousPrefs",
"disableYoutube",
"OnlyEmbeddedVideo",
"youtubeVolume",
"invidiousPlayerStyle",
"invidiousSubtitles",
"youtubeAutoplay",
"youtubeRedirects",
"youtubeFrontend",
fetch('/instances/data.json').then(response => response.text()).then(data => {
let dataJson = JSON.parse(data);
browser.storage.sync.get(
[
"invidiousAlwaysProxy",
"invidiousVideoQuality",
"youtubeTheme",
"persistInvidiousPrefs",
"disableYoutube",
"OnlyEmbeddedVideo",
"youtubeVolume",
"invidiousPlayerStyle",
"invidiousSubtitles",
"youtubeAutoplay",
"youtubeRedirects",
"youtubeFrontend",
"invidiousNormalRedirectsChecks",
"invidiousNormalCustomRedirects",
"invidiousNormalRedirectsChecks",
"invidiousNormalCustomRedirects",
"invidiousTorRedirectsChecks",
"invidiousTorCustomRedirects",
"invidiousTorRedirectsChecks",
"invidiousTorCustomRedirects",
"pipedNormalRedirectsChecks",
"pipedNormalCustomRedirects",
"pipedNormalRedirectsChecks",
"pipedNormalCustomRedirects",
"pipedTorRedirectsChecks",
"pipedTorCustomRedirects",
"alwaysusePreferred",
"freetubeFrontend",
"pipedTorRedirectsChecks",
"pipedTorCustomRedirects",
"alwaysusePreferred",
"freetubeFrontend",
"youtubeProtocol",
],
(result) => {
if (result.youtubeRedirects) redirects = result.youtubeRedirects;
"youtubeProtocol",
],
(result) => {
redirects.invidious = dataJson.invidious;
if (result.youtubeRedirects) redirects = result.youtubeRedirects;
disable = result.disableYoutube ?? false;
protocol = result.youtubeProtocol ?? 'normal';
frontend = result.youtubeFrontend ?? 'piped';
freetubeFrontend = result.freetubeFrontend ?? 'invidious';
theme = result.youtubeTheme ?? 'DEFAULT';
volume = result.youtubeVolume ?? '--';
autoplay = result.youtubeAutoplay ?? 'DEFAULT';
disable = result.disableYoutube ?? false;
protocol = result.youtubeProtocol ?? 'normal';
frontend = result.youtubeFrontend ?? 'piped';
freetubeFrontend = result.freetubeFrontend ?? 'invidious';
invidiousAlwaysProxy = result.invidiousAlwaysProxy ?? 'DEFAULT';
OnlyEmbeddedVideo = result.OnlyEmbeddedVideo ?? 'both';
invidiousVideoQuality = result.invidiousVideoQuality ?? 'DEFAULT';
invidiousPlayerStyle = result.invidiousPlayerStyle ?? 'DEFAULT';
invidiousSubtitles = result.invidiousSubtitles || '';
theme = result.youtubeTheme ?? 'DEFAULT';
volume = result.youtubeVolume ?? '--';
autoplay = result.youtubeAutoplay ?? 'DEFAULT';
invidiousNormalRedirectsChecks = result.invidiousNormalRedirectsChecks ?? [...redirects.invidious.normal];
invidiousNormalCustomRedirects = result.invidiousNormalCustomRedirects ?? [];
invidiousAlwaysProxy = result.invidiousAlwaysProxy ?? 'DEFAULT';
OnlyEmbeddedVideo = result.OnlyEmbeddedVideo ?? 'both';
invidiousVideoQuality = result.invidiousVideoQuality ?? 'DEFAULT';
invidiousPlayerStyle = result.invidiousPlayerStyle ?? 'DEFAULT';
invidiousSubtitles = result.invidiousSubtitles || '';
invidiousTorRedirectsChecks = result.invidiousTorRedirectsChecks ?? [...redirects.invidious.tor];
invidiousTorCustomRedirects = result.invidiousTorCustomRedirects ?? [];
invidiousNormalRedirectsChecks = result.invidiousNormalRedirectsChecks ?? [...redirects.invidious.normal];
invidiousNormalCustomRedirects = result.invidiousNormalCustomRedirects ?? [];
pipedNormalRedirectsChecks = result.pipedNormalRedirectsChecks ?? [...redirects.piped.normal];
pipedNormalCustomRedirects = result.pipedNormalCustomRedirects ?? [];
invidiousTorRedirectsChecks = result.invidiousTorRedirectsChecks ?? [...redirects.invidious.tor];
invidiousTorCustomRedirects = result.invidiousTorCustomRedirects ?? [];
pipedTorRedirectsChecks = result.pipedTorRedirectsChecks ?? [...redirects.piped.tor];
pipedTorCustomRedirects = result.pipedTorCustomRedirects ?? [];
pipedNormalRedirectsChecks = result.pipedNormalRedirectsChecks ?? [...redirects.piped.normal];
pipedNormalCustomRedirects = result.pipedNormalCustomRedirects ?? [];
persistInvidiousPrefs = result.persistInvidiousPrefs ?? false;
pipedTorRedirectsChecks = result.pipedTorRedirectsChecks ?? [...redirects.piped.tor];
pipedTorCustomRedirects = result.pipedTorCustomRedirects ?? [];
alwaysusePreferred = result.alwaysusePreferred ?? true;
persistInvidiousPrefs = result.persistInvidiousPrefs ?? false;
resolve();
});
alwaysusePreferred = result.alwaysusePreferred ?? true;
resolve();
});
});
})
}

View File

@ -16,7 +16,7 @@
"https://youtube.076.ne.jp",
"https://invidious.namazso.eu"
],
"onion": [
"tor": [
"http://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion",
"http://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion",
"http://kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad.onion",
@ -75,7 +75,7 @@
"https://nitter.winscloud.net",
"https://nitter.tiekoetter.com"
],
"onion": [
"tor": [
"http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion",
"http://nitter.l4qlywnpwqsluw65ts7md3khrivpirse744un3x7mlskqauz5pyuzgqd.onion",
"http://nitter7bryz3jv7e3uekphigvmoyoem4al3fynerxkj22dmoxoq553qd.onion",
@ -128,7 +128,7 @@
"https://teddit.adminforge.de",
"https://teddit.bus-hit.me"
],
"onion": [
"tor": [
"http://teddit4w6cmzmj5kimhfcavs7yo5s7alszvsi2khqutqtlaanpcftfyd.onion",
"http://snoo.ioensistjs7wd746zluwixvojbbkxhr37lepdvwtdfeav673o64iflqd.onion",
"http://ibarajztopxnuhabfu7fg6gbudynxofbnmvis3ltj6lfx47b6fhrd5qd.onion",
@ -144,7 +144,7 @@
"https://wikiless.sethforprivacy.com",
"https://wiki.604kph.xyz"
],
"onion": [
"tor": [
"http://dj2tbh2nqfxyfmvq33cjmhuw7nb6am7thzd3zsjvizeqf374fixbrxyd.onion"
]
},
@ -169,7 +169,7 @@
"https://translate.northboot.xyz",
"https://translate.tiekoetter.com"
],
"onion": [
"tor": [
"http://fyng2tsmzmvxmojzbbwmfnsn2lrcyftf4cw6rk5j2v2huliazud3fjid.onion",
"http://xxtbwyb5z5bdvy2f6l2yquu5qilgkjeewno4qfknvb3lkg3nmoklitid.onion"
]
@ -279,7 +279,7 @@
"https://xeek.com",
"https://searx.roflcopter.fr"
],
"onion": [
"tor": [
"http://3afisqjw2rxm6z7mmstyt5rx75qfqrgxnkzftknbp2vhipr2nrmrjdyd.onion",
"http://searxbgetrkiwxhdwi6svpgh7eotopqyxhbqiokrwzg7dcte44t36kyd.onion",
"http://suche.xyzco456vwisukfg.onion",
@ -324,7 +324,7 @@
"https://rimgo.totaldarkness.net",
"https://rimgo.bus-hit.me"
],
"onion": [
"tor": [
"http://l4d4owboqr6xcmd6lf64gbegel62kbudu3x3jnldz2mx6mhn3bsv3zyd.onion",
"http://jx3dpcwedpzu2mh54obk5gvl64i2ln7pt5mrzd75s4jnndkqwzaim7ad.onion"
]

View File

@ -18,12 +18,12 @@ r = requests.get('https://api.invidious.io/instances.json')
rJson = json.loads(r.text)
invidiousList = {}
invidiousList['normal'] = []
invidiousList['onion'] = []
invidiousList['tor'] = []
for instance in rJson:
if instance[1]['type'] == 'https':
invidiousList['normal'].append(instance[1]['uri'])
elif instance[1]['type'] == 'onion':
invidiousList['onion'].append(instance[1]['uri'])
elif instance[1]['type'] == 'tor':
invidiousList['tor'].append(instance[1]['uri'])
mightyList['invidious'] = invidiousList
print('fetched Invidious')
@ -37,7 +37,7 @@ tables.pop(3)
tables.pop(3)
nitterList = {}
nitterList['normal'] = []
nitterList['onion'] = []
nitterList['tor'] = []
for table in tables:
tbody = table.find('tbody')
trs = tbody.find_all('tr')
@ -47,7 +47,7 @@ for table in tables:
url = a.contents[0]
if url.endswith('.onion'):
url = 'http://' + url
nitterList['onion'].append(url)
nitterList['tor'].append(url)
else:
url = 'https://' + url
nitterList['normal'].append(url)
@ -71,15 +71,15 @@ r = requests.get(
rJson = json.loads(r.text)
tedditList = {}
tedditList['normal'] = []
tedditList['onion'] = []
tedditList['tor'] = []
for item in rJson:
url = item['url']
if url != '':
tedditList['normal'].append(url)
if 'onion' in item:
onion = item['onion']
if 'tor' in item:
onion = item['tor']
if onion != '':
tedditList['onion'].append(onion)
tedditList['tor'].append(onion)
mightyList['teddit'] = tedditList
print('fetched Teddit')
@ -90,10 +90,10 @@ r = requests.get('https://wikiless.org/instances.json')
rJson = json.loads(r.text)
wikilessList = {}
wikilessList['normal'] = []
wikilessList['onion'] = []
wikilessList['tor'] = []
for item in rJson:
if item.endswith('.onion'):
wikilessList['onion'].append('http://' + item)
wikilessList['tor'].append('http://' + item)
else:
wikilessList['normal'].append('https://' + item)
mightyList['wikiless'] = wikilessList
@ -119,9 +119,9 @@ for item in r.text.strip().split('\n'):
simplyTranslateList['normal'].append('https://' + item)
r = requests.get('https://simple-web.org/instances/simplytranslate_onion')
simplyTranslateList['onion'] = []
simplyTranslateList['tor'] = []
for item in r.text.strip().split('\n'):
simplyTranslateList['onion'].append('http://' + item)
simplyTranslateList['tor'].append('http://' + item)
mightyList['simplyTranslate'] = simplyTranslateList
print('fetched SimplyTranslate')
@ -138,18 +138,17 @@ mightyList['lingva'] = lingvaList
print('fetched LinvgaTranslate')
# SearX
r = requests.get('https://searx.space/data/instances.json')
rJson = json.loads(r.text)
searxList = {}
searxList['normal'] = []
searxList['onion'] = []
searxList['tor'] = []
searxList['i2p'] = []
for item in rJson['instances'].keys():
item = item[:-1]
if item.endswith('.onion'):
searxList['onion'].append(item)
searxList['tor'].append(item)
elif item.endswith('.i2p'):
searxList['i2p'].append(item)
else:
@ -176,11 +175,11 @@ r = requests.get(
rJson = json.loads(r.text)
rimgoList = {}
rimgoList['normal'] = []
rimgoList['onion'] = []
rimgoList['tor'] = []
for item in rJson:
if item.endswith('.onion'):
rimgoList['onion'].append('http://' + item)
rimgoList['tor'].append('http://' + item)
else:
rimgoList['normal'].append('https://' + item)
mightyList['rimgo'] = rimgoList
@ -189,7 +188,7 @@ print('fetched Rimgo')
# Writing to file
json_object = json.dumps(mightyList, ensure_ascii=False, indent=2)
with open('instances/data.json', 'w') as outfile:
with open('src/instances/data.json', 'w') as outfile:
outfile.write(json_object)
# print(json_object)
print('wrote instances/data.json')

View File

@ -15,21 +15,21 @@ import exceptionsHelper from "../../assets/javascripts/helpers/exceptions.js";
window.browser = window.browser || window.chrome;
function wholeInit() {
async function wholeInit() {
youtubeHelper.init()
twitterHelper.init()
instagramHelper.init()
mapsHelper.init()
searchHelper.init()
translateHelper.init()
instagramHelper.init()
mediumHelper.init()
redditHelper.init()
twitterHelper.init()
wikipediaHelper.init()
youtubeHelper.init()
imgurHelper.init()
tiktokHelper.init()
exceptionsHelper.init()
}
}
wholeInit();
browser.storage.onChanged.addListener(wholeInit);