diff --git a/src/assets/javascripts/helpers/instagram.js b/src/assets/javascripts/helpers/instagram.js index fc004e0..3145fb6 100644 --- a/src/assets/javascripts/helpers/instagram.js +++ b/src/assets/javascripts/helpers/instagram.js @@ -101,7 +101,7 @@ function setDisable(val) { } let protocol; -const getprotocol = () => protocol; +const getProtocol = () => protocol; function setProtocol(val) { protocol = val; browser.storage.local.set({ nitterProtocol: val }) @@ -182,7 +182,7 @@ export default { getDisable, setDisable, - getprotocol, + getProtocol, setProtocol, getBibliogramNormalRedirectsChecks, diff --git a/src/assets/javascripts/helpers/medium.js b/src/assets/javascripts/helpers/medium.js index dcec574..cd45917 100644 --- a/src/assets/javascripts/helpers/medium.js +++ b/src/assets/javascripts/helpers/medium.js @@ -20,19 +20,16 @@ const targets = [ let redirects = { "scribe": { - "normal": [ - "https://scribe.rip", - "https://scribe.nixnet.services", - "https://scribe.citizen4.eu", - "https://scribe.bus-hit.me" - ] + "normal": [], + "tor": [] } }; const getRedirects = () => redirects; const getCustomRedirects = function () { return { "scribe": { - "normal": [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects] + "normal": [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects], + "tor": [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects] }, }; }; @@ -45,6 +42,18 @@ function setRedirects(val) { if (index !== -1) scribeNormalRedirectsChecks.splice(index, 1); } setScribeNormalRedirectsChecks(scribeNormalRedirectsChecks); + + for (const item of scribeNormalRedirectsChecks) if (!redirects.scribe.normal.includes(item)) { + var index = scribeNormalRedirectsChecks.indexOf(item); + if (index !== -1) scribeNormalRedirectsChecks.splice(index, 1); + } + setScribeNormalRedirectsChecks(scribeNormalRedirectsChecks); + + for (const item of scribeTorRedirectsChecks) if (!redirects.scribe.normal.includes(item)) { + var index = scribeTorRedirectsChecks.indexOf(item); + if (index !== -1) scribeTorRedirectsChecks.splice(index, 1); + } + setScribeTorRedirectsChecks(scribeTorRedirectsChecks); } let scribeNormalRedirectsChecks; @@ -55,6 +64,14 @@ function setScribeNormalRedirectsChecks(val) { console.log("scribeNormalRedirectsChecks: ", val) } +let scribeTorRedirectsChecks; +const getScribeTorRedirectsChecks = () => scribeTorRedirectsChecks; +function setScribeTorRedirectsChecks(val) { + scribeTorRedirectsChecks = val; + browser.storage.local.set({ scribeTorRedirectsChecks }) + console.log("scribeTorRedirectsChecks: ", val) +} + let scribeNormalCustomRedirects = []; const getScribeNormalCustomRedirects = () => scribeNormalCustomRedirects; function setScribeNormalCustomRedirects(val) { @@ -63,6 +80,14 @@ function setScribeNormalCustomRedirects(val) { console.log("scribeNormalCustomRedirects: ", val) } +let scribeTorCustomRedirects = []; +const getScribeTorCustomRedirects = () => scribeTorCustomRedirects; +function setScribeTorCustomRedirects(val) { + scribeTorCustomRedirects = val; + browser.storage.local.set({ scribeTorCustomRedirects }) + console.log("scribeTorCustomRedirects: ", val) +} + let disable; const getDisable = () => disable; function setDisable(val) { @@ -71,6 +96,14 @@ function setDisable(val) { console.log("disableMedium", disable) } +let protocol; +const getProtocol = () => protocol; +function setProtocol(val) { + protocol = val; + browser.storage.local.set({ mediumProtocol: val }) + console.log("mediumProtocol: ", val) +} + function isMedium(url, initiator) { if (disable) return false; if (url.pathname == "/") return false; @@ -86,7 +119,9 @@ function redirect(url, type) { if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other") return null; - let instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]; + let instancesList; + if (protocol == 'normal') instancesList = [...scribeNormalRedirectsChecks, ...scribeNormalCustomRedirects]; + else if (protocol == 'tor') instancesList = [...scribeTorRedirectsChecks, ...scribeTorCustomRedirects]; if (instancesList.length === 0) return null; let randomInstance = commonHelper.getRandomInstance(instancesList) @@ -95,26 +130,37 @@ function redirect(url, type) { async function init() { return new Promise((resolve) => { - browser.storage.local.get( - [ - "disableMedium", - "mediumRedirects", - "scribeNormalRedirectsChecks", - "scribeNormalCustomRedirects", - ], - (result) => { - disable = result.disableMedium ?? false; + fetch('/instances/data.json').then(response => response.text()).then(data => { + let dataJson = JSON.parse(data); + browser.storage.local.get( + [ + "disableMedium", + "mediumRedirects", + "scribeNormalRedirectsChecks", + "scribeNormalCustomRedirects", + "scribeTorRedirectsChecks", + "scribeTorCustomRedirects", + "mediumProtocol" + ], + (result) => { + disable = result.disableMedium ?? false; - if (result.mediumRedirects) redirects = result.mediumRedirects; + protocol = result.mediumProtocol ?? "normal"; - scribeNormalRedirectsChecks = result.scribeNormalRedirectsChecks ?? [...redirects.scribe.normal]; - scribeNormalCustomRedirects = result.scribeNormalCustomRedirects ?? []; + redirects.scribe = dataJson.scribe; + if (result.mediumRedirects) redirects = result.mediumRedirects; - resolve(); - } - ) + scribeNormalRedirectsChecks = result.scribeNormalRedirectsChecks ?? [...redirects.scribe.normal]; + scribeNormalCustomRedirects = result.scribeNormalCustomRedirects ?? []; + + scribeTorRedirectsChecks = result.scribeTorRedirectsChecks ?? [...redirects.scribe.tor]; + scribeTorCustomRedirects = result.scribeTorCustomRedirects ?? []; + + resolve(); + } + ) + }) }) - } export default { @@ -127,11 +173,18 @@ export default { getDisable, setDisable, + getProtocol, + setProtocol, + getScribeNormalRedirectsChecks, setScribeNormalRedirectsChecks, + getScribeTorRedirectsChecks, + setScribeTorRedirectsChecks, getScribeNormalCustomRedirects, setScribeNormalCustomRedirects, + getScribeTorCustomRedirects, + setScribeTorCustomRedirects, redirect, isMedium, diff --git a/src/assets/javascripts/helpers/reddit.js b/src/assets/javascripts/helpers/reddit.js index 08b3e52..382f15c 100644 --- a/src/assets/javascripts/helpers/reddit.js +++ b/src/assets/javascripts/helpers/reddit.js @@ -177,7 +177,7 @@ function setRedditFrontend(val) { }; let protocol; -const getprotocol = () => protocol; +const getProtocol = () => protocol; function setProtocol(val) { protocol = val; browser.storage.local.set({ redditProtocol: val }) @@ -316,7 +316,7 @@ export default { getRedditFrontend, setRedditFrontend, - getprotocol, + getProtocol, setProtocol, getLibredditNormalRedirectsChecks, diff --git a/src/assets/javascripts/helpers/search.js b/src/assets/javascripts/helpers/search.js index caa0399..789f7d9 100644 --- a/src/assets/javascripts/helpers/search.js +++ b/src/assets/javascripts/helpers/search.js @@ -146,7 +146,7 @@ function setFrontend(val) { }; let protocol; -const getprotocol = () => protocol; +const getProtocol = () => protocol; function setProtocol(val) { protocol = val; browser.storage.local.set({ searchProtocol: val }) @@ -274,7 +274,7 @@ export default { getSearxTorCustomRedirects, setSearxTorCustomRedirects, - getprotocol, + getProtocol, setProtocol, redirect, diff --git a/src/assets/javascripts/helpers/twitter.js b/src/assets/javascripts/helpers/twitter.js index 3edea7a..a1b9979 100644 --- a/src/assets/javascripts/helpers/twitter.js +++ b/src/assets/javascripts/helpers/twitter.js @@ -88,7 +88,7 @@ function setDisable(val) { } let protocol; -const getprotocol = () => protocol; +const getProtocol = () => protocol; function setProtocol(val) { protocol = val; browser.storage.local.set({ nitterProtocol: val }) @@ -187,7 +187,7 @@ export default { getNitterTorCustomRedirects, setNitterTorCustomRedirects, - getprotocol, + getProtocol, setProtocol, redirect, diff --git a/src/assets/javascripts/helpers/wikipedia.js b/src/assets/javascripts/helpers/wikipedia.js index e27f80b..0211063 100644 --- a/src/assets/javascripts/helpers/wikipedia.js +++ b/src/assets/javascripts/helpers/wikipedia.js @@ -146,12 +146,12 @@ async function init() { "wikilessTorRedirectsChecks", "wikilessNormalCustomRedirects", "wikilessTorCustomRedirects", - "wikilessProtocol" + "wikipediaProtocol" ], (result) => { disable = result.disableWikipedia ?? false; - protocol = result.wikilessProtocol ?? "normal"; + protocol = result.wikipediaProtocol ?? "normal"; redirects.wikiless = dataJson.wikiless; if (result.wikipediaRedirects) redirects = result.wikipediaRedirects; diff --git a/src/assets/javascripts/helpers/youtube/youtube.js b/src/assets/javascripts/helpers/youtube/youtube.js index 70148f7..2feb64a 100644 --- a/src/assets/javascripts/helpers/youtube/youtube.js +++ b/src/assets/javascripts/helpers/youtube/youtube.js @@ -136,7 +136,7 @@ function setDisable(val) { let protocol; -const getprotocol = () => protocol; +const getProtocol = () => protocol; function setProtocol(val) { protocol = val; browser.storage.local.set({ youtubeProtocol: val }) @@ -573,7 +573,7 @@ export default { getDisable, setDisable, - getprotocol, + getProtocol, setProtocol, setInvidiousAlwaysProxy, diff --git a/src/instances/data.json b/src/instances/data.json index fe7c400..80f6d43 100644 --- a/src/instances/data.json +++ b/src/instances/data.json @@ -74,7 +74,8 @@ "https://de.nttr.stream", "https://nitter.winscloud.net", "https://nitter.tiekoetter.com", - "https://nitter.spaceint.fr" + "https://nitter.spaceint.fr", + "https://twtr.bch.bar" ], "tor": [ "http://3nzoldnxplag42gqjs23xvghtzf6t6yzssrtytnntc6ppc7xxuoneoad.onion", @@ -156,7 +157,8 @@ "https://scribe.nixnet.services", "https://scribe.citizen4.eu", "https://scribe.bus-hit.me" - ] + ], + "tor": [] }, "simplyTranslate": { "normal": [ diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 3aee6cd..8f95af1 100644 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -106,6 +106,7 @@ r = requests.get( rJson = json.loads(r.text) scribeList = {} scribeList['normal'] = [] +scribeList['tor'] = [] for item in rJson: scribeList['normal'].append(item) mightyList['scribe'] = scribeList diff --git a/src/pages/options/instagram/instagram.js b/src/pages/options/instagram/instagram.js index c5ed805..9967176 100644 --- a/src/pages/options/instagram/instagram.js +++ b/src/pages/options/instagram/instagram.js @@ -31,7 +31,7 @@ function changeProtocolSettings(protocol) { instagramHelper.init().then(() => { disableInstagramElement.checked = !instagramHelper.getDisable(); - let protocol = instagramHelper.getprotocol(); + let protocol = instagramHelper.getProtocol(); protocolElement.value = protocol; changeProtocolSettings(protocol); diff --git a/src/pages/options/medium/medium.html b/src/pages/options/medium/medium.html index 9efd21c..f19f8d4 100644 --- a/src/pages/options/medium/medium.html +++ b/src/pages/options/medium/medium.html @@ -2,146 +2,179 @@
- - - - - -