diff options
45 files changed, 393 insertions, 354 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 4dba8a7b..b7ee2205 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -17,10 +17,6 @@ async function getConfig() { }) } -function camelCase(str) { - return str.charAt(0).toUpperCase() + str.slice(1) -} - function init() { return new Promise(async resolve => { browser.storage.local.get(["network", "networkFallback"], r => { @@ -31,8 +27,8 @@ function init() { //cur = current for (const service in config.services) { options[service] = {} - browser.storage.local.get([`disable${camelCase(service)}`, `${service}RedirectType`, `${service}Frontend`], r => { - options[service].disabled = r["disable" + camelCase(service)] + browser.storage.local.get([`disable${utils.camelCase(service)}`, `${service}RedirectType`, `${service}Frontend`], r => { + options[service].disabled = r["disable" + utils.camelCase(service)] options[service].frontend = r[service + "Frontend"] options[service].redirectType = r[service + "RedirectType"] // console.log(r) @@ -42,11 +38,11 @@ function init() { options[frontend].checks = [] options[frontend].custom = [] for (const network in config.networks) { - browser.storage.local.get([`${frontend}${camelCase(network)}RedirectsChecks`, `${frontend}${camelCase(network)}CustomRedirects`], r => { + browser.storage.local.get([`${frontend}${utils.camelCase(network)}RedirectsChecks`, `${frontend}${utils.camelCase(network)}CustomRedirects`], r => { // console.log(r) - // console.log(`${frontend}${camelCase(network)}RedirectsChecks`) - options[frontend].checks = r[frontend + camelCase(network) + "RedirectsChecks"] - options[frontend].custom = r[frontend + camelCase(network) + "CustomRedirects"] + // console.log(`${frontend}${utils.camelCase(network)}RedirectsChecks`) + options[frontend].checks = r[frontend + utils.camelCase(network) + "RedirectsChecks"] + options[frontend].custom = r[frontend + utils.camelCase(network) + "CustomRedirects"] }) } } @@ -72,6 +68,7 @@ function redirect(url, type, initiator) { let frontend = options[service].frontend let network = options.network let networkFallback = options.networkFallback + let redirectType = options[service].redirectType if (url.pathname == "/") return for (const service in config.services) { if (options[service].disabled && !disableOverride) continue @@ -82,9 +79,9 @@ function redirect(url, type, initiator) { if (initiator && (all(service).includes(initiator.origin) || targets.includes(initiator.host))) continue if (!targets.some(rx => rx.test(url.href))) continue - if (type != options[service].redirectType && type != "both") continue + if (type != redirectType && type != "both") continue // browser.storage.local.get(`${service}Frontend`, (frontend = r[service + "Frontend"])) - let instanceList = [...[service + camelCase(network) + "RedirectsChecks"], ...[service + camelCase(network) + "CustomRedirects"]] + let instanceList = [...[service + utils.camelCase(network) + "RedirectsChecks"], ...[service + utils.camelCase(network) + "CustomRedirects"]] if (instanceList.length === 0 && networkFallback) instanceList = [...[service + "ClearnetRedirectsChecks"], ...[service + "ClearnetCustomRedirects"]] if (instanceList.length === 0 && redirects.indexOf(frontend) != -1) return randomInstance = utils.getRandomInstance(instanceList) @@ -400,13 +397,13 @@ function initDefaults() { browser.storage.local.set({ [defaultOption]: config.services[service].defaults[defaultOption] }) } for (const frontend in config.services[service].frontends) { - let clearnetChecks = redirects[frontend][clearnet] + let clearnetChecks = redirects[frontend].clearnet for (const instance of [...r.cloudflareBlackList, ...r.authenticateBlackList, ...r.offlineBlackList]) { let i = clearnetChecks.indexOf(instance) if (i > -1) clearnetChecks.splice(i, 1) } for (const network in config.networks) { - console.log(redirects[frontend][network]) + // console.log(redirects[frontend][network]) switch (network) { case "clearnet": browser.storage.local.set({ @@ -416,8 +413,8 @@ function initDefaults() { break default: browser.storage.local.set({ - [frontend + camelCase(network) + "RedirectsChecks"]: [...redirects[frontend][network]], - [frontend + camelCase(network) + "CustomRedirects"]: [], + [frontend + utils.camelCase(network) + "RedirectsChecks"]: [...redirects[frontend][network]], + [frontend + utils.camelCase(network) + "CustomRedirects"]: [], }) } } diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 50ada765..9c5947a7 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -123,17 +123,16 @@ async function processDefaultCustomInstances(target, name, protocol, document) { let redirectsChecks = `${name}${camelCase(protocol)}RedirectsChecks` let customRedirects = `${name}${camelCase(protocol)}CustomRedirects` - let redirectsKey = `${target}Redirects` let redirects async function getFromStorage() { return new Promise(async resolve => - browser.storage.local.get([redirectsChecks, customRedirects, redirectsKey, latencyKey], r => { + browser.storage.local.get([redirectsChecks, customRedirects, "redirects", latencyKey], r => { nameDefaultRedirects = r[redirectsChecks] nameCustomInstances = r[customRedirects] instancesLatency = r[latencyKey] ?? [] - redirects = r[redirectsKey] + redirects = r.redirects resolve() }) ) @@ -298,9 +297,9 @@ async function testLatency(element, instances, frontend) { let myList = {} let latencyThreshold let redirectsChecks = [] - browser.storage.local.get(["latencyThreshold", `${frontend}NormalRedirectsChecks`], r => { + browser.storage.local.get(["latencyThreshold", `${frontend}ClearnetRedirectsChecks`], r => { latencyThreshold = r.latencyThreshold - redirectsChecks = r[`${frontend}NormalRedirectsChecks`] + redirectsChecks = r[`${frontend}ClearnetRedirectsChecks`] }) for (const href of instances) await ping(href).then(time => { @@ -315,7 +314,7 @@ async function testLatency(element, instances, frontend) { redirectsChecks.splice(redirectsChecks.indexOf(href), 1) } - browser.storage.local.set({ [`${frontend}NormalRedirectsChecks`]: redirectsChecks }) + browser.storage.local.set({ [`${frontend}ClearnetRedirectsChecks`]: redirectsChecks }) let text if (time == 5000) text = "5000ms+" @@ -516,10 +515,10 @@ function latency(name, frontend, document, location) { let redirects = r[key] const oldHtml = latencyLabel.innerHTML latencyLabel.innerHTML = "..." - testLatency(latencyLabel, redirects[frontend].normal, frontend).then(r => { + testLatency(latencyLabel, redirects[frontend].clearnet, frontend).then(r => { browser.storage.local.set({ [`${frontend}Latency`]: r }) latencyLabel.innerHTML = oldHtml - processDefaultCustomInstances(name, frontend, "normal", document) + processDefaultCustomInstances(name, frontend, "clearnet", document) latencyElement.removeEventListener("click", reloadWindow) }) }) @@ -537,4 +536,5 @@ export default { switchInstance, copyRaw, unify, + camelCase, } diff --git a/src/config/config.json b/src/config/config.json index 6c4d8026..97fd838c 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -1,19 +1,19 @@ { "networks": { "clearnet": { - "url": "org", + "tld": "org", "name": "Clearnet" }, "tor": { - "url": "onion", + "tld": "onion", "name": "Tor" }, "i2p": { - "url": "i2p", + "tld": "i2p", "name": "I2P" }, "loki": { - "url": "loki", + "tld": "loki", "name": "Lokinet" } }, @@ -72,14 +72,14 @@ "^https?:\\/{2}(www\\.|)(youtube|youtube-nocookie)\\.com\\/embed\\/..*" ], "name": "Youtube", - "defaults": { - "disableYoutube": false, - "enableYoutubeCustomSettings": false, - "onlyEmbeddedVideo": "both", - "youtubeFrontend": "invidious", - "youtubeEmbedFrontend": "invidious" - }, - "imageType": "png" + "options": { + "disabled": false, + "redirectType": "both", + "frontend": "invidious", + "embedFrontend": "invidious" + }, + "imageType": "png", + "embeddable": true }, "youtubeMusic": { "frontends": { @@ -88,11 +88,12 @@ }, "targets": ["^https?:\\/{2}music\\.youtube\\.com(\\/.*|$)"], "name": "YT Music", - "defaults": { - "disableYoutubeMusic": false, - "youtubeMusicFrontend": "beatbump" + "options": { + "disabled": false, + "frontend": "beatbump" }, - "imageType": "png" + "imageType": "png", + "embeddable": false }, "twitter": { "frontends": { @@ -123,11 +124,12 @@ }, "targets": ["^https?:\\/{2}(www\\.|mobile\\.|)twitter\\.com", "^https?:\\/{2}(pbs\\.|video\\.|)twimg\\.com", "^https?:\\/{2}platform\\.twitter\\.com/embed", "^https?:\\/{2}t\\.co"], "name": "Twitter", - "defaults": { - "disableTwitter": false, - "twitterRedirectType": "both" + "options": { + "disabled": false, + "redirectType": "both" }, - "imageType": "png" + "imageType": "png", + "embeddable": true }, "instagram": { "frontends": { @@ -141,10 +143,9 @@ }, "targets": ["^https?:\\/{2}(www\\.)?instagram\\.com"], "name": "Instagram", - "defaults": { - "disableInstagram": false - }, - "imageType": "png" + "options": { "disabled": false }, + "imageType": "png", + "embeddable": false }, "tiktok": { "frontends": { @@ -152,10 +153,9 @@ }, "targets": ["^https?:\\/{2}(www\\.|)tiktok\\.com.*"], "name": "TikTok", - "defaults": { - "disableTiktok": false - }, - "imageType": "png" + "options": { "disabled": false }, + "imageType": "png", + "embeddable": false }, "reddit": { "frontends": { @@ -185,11 +185,12 @@ }, "targets": ["^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com", "^https?:\\/{2}(i\\.|preview\\.)redd\\.it"], "name": "Reddit", - "defaults": { - "disableReddit": false, - "redditFrontend": "libreddit" + "options": { + "disabled": false, + "frontend": "libreddit" }, - "imageType": "png" + "imageType": "png", + "embeddable": false }, "imgur": { "frontends": { @@ -199,8 +200,9 @@ }, "targets": ["^https?:\\/{2}([im]\\.)?imgur\\.(com|io)(\\/|$)"], "name": "Imgur", - "defaults": { "disableImgur": false }, - "imageType": "png" + "options": { "disabled": false }, + "imageType": "png", + "embeddable": false }, "wikipedia": { "frontends": { @@ -212,8 +214,9 @@ }, "targets": ["^https?:\\/{2}([a-z]+\\.)*wikipedia\\.org"], "name": "Wikipedia", - "defaults": { "disableWikipedia": true }, - "imageType": "svg" + "options": { "disabled": true }, + "imageType": "svg", + "embeddable": false }, "medium": { "frontends": { @@ -242,8 +245,9 @@ "^writingcooperative\\.com " ], "name": "Medium", - "defaults": { "disableMedium": false }, - "imageType": "svg" + "options": { "disabled": false }, + "imageType": "svg", + "embeddable": false }, "quora": { "frontends": { @@ -253,10 +257,9 @@ }, "targets": ["^https?:\\/{2}([a-z]+\\.)*quora\\.com.*"], "name": "Quora", - "defaults": { - "disableQuora": false - }, - "imageType": "png" + "options": { "disabled": false }, + "imageType": "png", + "embeddable": false }, "imdb": { "frontends": { @@ -266,10 +269,9 @@ }, "targets": ["^https?:\\/{2}(?:www\\.|)imdb\\.com.*"], "name": "IMDb", - "defaults": { - "disableImdb": true - }, - "imageType": "svg" + "options": { "disabled": true }, + "imageType": "svg", + "embeddable": false }, "reuters": { "frontends": { @@ -279,10 +281,9 @@ }, "targets": ["^https?:\\/{2}(www\\.|)reuters\\.com.*"], "name": "Reuters", - "defaults": { - "disableReuters": true - }, - "imageType": "svg" + "options": { "disabled": true }, + "imageType": "svg", + "embeddable": false }, "peertube": { "frontends": { @@ -292,10 +293,9 @@ }, "targets": "datajson", "name": "PeerTube", - "defaults": { - "disablePeertube": true - }, - "imageType": "svg" + "options": { "disabled": true }, + "imageType": "svg", + "embeddable": false }, "lbry": { "frontends": { @@ -309,12 +309,13 @@ "singleInstanceFrontends": ["lbryDesktop"], "targets": ["^https?:\\/{2}odysee\\.com", "^https?:\\/{2}lbry\\.tv"], "name": "LBRY", - "defaults": { - "disableLbry": true, - "lbryFrontend": "librarian", - "lbryRedirectType": "both" + "options": { + "disabled": true, + "frontend": "librarian", + "redirectType": "both" }, - "imageType": "png" + "imageType": "png", + "embeddable": true }, "search": { "frontends": { @@ -377,12 +378,12 @@ }, "targets": ["^https?:\\/{2}search\\.libredirect\\.invalid"], "name": "Search", - "defaults": { - "disableSearch": false, - "searchFrontend": "searxng", - "searxngCustomSettings": false + "options": { + "disabled": false, + "frontend": "searxng" }, - "imageType": "svg" + "imageType": "svg", + "embeddable": false }, "translate": { "frontends": { @@ -399,11 +400,12 @@ }, "targets": ["^https?:\\/{2}translate\\.google(\\.[a-z]{2,3}){1,2}\\/"], "name": "Translate", - "defaults": { - "translateDisable": false, - "translateFrontend": "simplyTranslate" + "options": { + "disabled": false, + "frontend": "simplyTranslate" }, - "imageType": "svg" + "imageType": "svg", + "embeddable": false }, "maps": { "frontends": { @@ -414,11 +416,12 @@ "singleInstanceFrontends": ["osm"], "targets": ["^https?:\\/{2}(((www|maps)\\.)?(google\\.).*(\\/maps)|maps\\.(google\\.).*)"], "name": "Maps", - "defaults": { - "disableMaps": false, - "mapsFrontend": "osm" + "options": { + "disabled": false, + "frontend": "osm" }, - "imageType": "svg" + "imageType": "svg", + "embeddable": false }, "sendTargets": { "frontends": { @@ -428,10 +431,9 @@ }, "targets": ["^https?:\\/{2}send\\.libredirect\\.invalid\\/$", "^https?:\\/{2}send\\.firefox\\.com\\/$", "^https?:\\/{2}sendfiles\\.online\\/$"], "name": "Send Files", - "defaults": { - "disableSendTargets": false - }, - "imageType": "svg" + "options": { "disabled": false }, + "imageType": "svg", + "embeddable": false } } } diff --git a/src/pages/options/index.html b/src/pages/options/index.html index 077b3da2..5c0aedd5 100644 --- a/src/pages/options/index.html +++ b/src/pages/options/index.html @@ -78,7 +78,7 @@ <div class="some-block option-block"> <h4 data-localise="__MSG_protocol__"></h4> <select id="protocol"> - <option value="normal" data-localise="__MSG_normal__">Normal</option> + <option value="clearnet" data-localise="__MSG_normal__">Clearnet</option> <option value="tor">Tor</option> <option value="i2p">I2P</option> <option value="loki">Lokinet</option> @@ -318,7 +318,7 @@ </div> <div id="invidious"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -414,7 +414,7 @@ </div> <div id="piped"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -510,7 +510,7 @@ </div> <div id="pipedMaterial"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -606,7 +606,7 @@ </div> <div id="cloudtube"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -720,7 +720,7 @@ </div> <div id="beatbump"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -816,7 +816,7 @@ </div> <div id="hyperpipe"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -931,7 +931,7 @@ </div> <div id="nitter"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1038,7 +1038,7 @@ </div> <div id="bibliogram"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1145,7 +1145,7 @@ </div> <div id="proxiTok"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1259,7 +1259,7 @@ </div> <div id="libreddit"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1355,7 +1355,7 @@ </div> <div id="teddit"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1462,7 +1462,7 @@ </div> <div id="rimgo"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1569,7 +1569,7 @@ </div> <div id="wikiless"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1676,7 +1676,7 @@ </div> <div id="scribe"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1783,7 +1783,7 @@ </div> <div id="quetre"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1890,7 +1890,7 @@ </div> <div id="libremdb"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -1997,7 +1997,7 @@ </div> <div id="neuters"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2104,7 +2104,7 @@ </div> <div id="simpleertube"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2226,7 +2226,7 @@ </div> <div id="librarian"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2345,7 +2345,7 @@ </div> <div id="searx"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2441,7 +2441,7 @@ </div> <div id="searxng"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2537,7 +2537,7 @@ </div> <div id="whoogle"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2633,7 +2633,7 @@ </div> <div id="librex"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2747,7 +2747,7 @@ </div> <hr> <div id="simplyTranslate"> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2842,7 +2842,7 @@ </div> </div> <div id="lingva"> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -2956,7 +2956,7 @@ </div> <div id="facil"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -3063,7 +3063,7 @@ </div> <div id="send"> <hr> - <div class="normal"> + <div class="clearnet"> <div class="some-block option-block"> <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> </div> @@ -3186,4 +3186,4 @@ </div> </body> <script type="module" src="./index.js"></script> -</html> +</html> \ No newline at end of file diff --git a/src/pages/options/widgets/about.ejs b/src/pages/options/widgets/about.ejs new file mode 100644 index 00000000..99202141 --- /dev/null +++ b/src/pages/options/widgets/about.ejs @@ -0,0 +1,24 @@ +<section class="option-block" id="about_page"> +<div class="some-block option-block"> + <h1 data-localise="__MSG_about__">About</h1> +</div> +<hr> +<div class="about"> + <div class="some-block option-block"> + <h4>Donate: ♥️</h4> + <h4><a href='https://libredirect.github.io/donate'>https://libredirect.github.io/donate</a> </h4> + </div> + <div class="some-block option-block"> + <h4>FAQ:</h4> + <h4><a href='https://libredirect.github.io/faq'>https://libredirect.github.io/faq</a></h4> + </div> + <div class="some-block option-block"> + <h4>Docs:</h4> + <h4><a href='https://libredirect.github.io/docs'>https://libredirect.github.io/docs</a></h4> + </div> + <div class="some-block option-block"> + <h4>Source Code:</h4> + <h4><a href='https://libredirect.github.io/source_code'>https://libredirect.github.io/source_code</a></h4> + </div> +</div> +</section> diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index d6824251..e573b4ee 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -3,25 +3,7 @@ window.browser = window.browser || window.chrome import utils from "../../../assets/javascripts/utils.js" import generalHelper from "../../../assets/javascripts/general.js" - -import youtubeHelper from "../../../assets/javascripts/youtube/youtube.js" -import youtubeMusicHelper from "../../../assets/javascripts/youtubeMusic.js" -import twitterHelper from "../../../assets/javascripts/twitter.js" -import instagramHelper from "../../../assets/javascripts/instagram.js" -import redditHelper from "../../../assets/javascripts/reddit.js" -import searchHelper from "../../../assets/javascripts/search.js" -import translateHelper from "../../../assets/javascripts/translate/translate.js" -import mapsHelper from "../../../assets/javascripts/maps.js" -import wikipediaHelper from "../../../assets/javascripts/wikipedia.js" -import mediumHelper from "../../../assets/javascripts/medium.js" -import quoraHelper from "../../../assets/javascripts/quora.js" -import libremdbHelper from "../../../assets/javascripts/imdb.js" -import reutersHelper from "../../../assets/javascripts/reuters.js" -import imgurHelper from "../../../assets/javascripts/imgur.js" -import tiktokHelper from "../../../assets/javascripts/tiktok.js" -import sendTargetsHelper from "../../../assets/javascripts/sendTargets.js" -import peertubeHelper from "../../../assets/javascripts/peertube.js" -import lbryHelper from "../../../assets/javascripts/lbry.js" +import servicesHelper from "../../../assets/javascripts/services.js" let updateInstancesElement = document.getElementById("update-instances") updateInstancesElement.addEventListener("click", async () => { @@ -82,28 +64,10 @@ resetSettings.addEventListener("click", async () => { .then(async data => { browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare }, () => { browser.storage.local.set({ offlineBlackList: JSON.parse(data).offline }, () => { - browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, async () => { - await generalHelper.initDefaults() - await youtubeHelper.initDefaults() - await youtubeMusicHelper.initDefaults() - await twitterHelper.initDefaults() - await instagramHelper.initDefaults() - await mapsHelper.initDefaults() - await searchHelper.initDefaults() - await translateHelper.initDefaults() - await mediumHelper.initDefaults() - await quoraHelper.initDefaults() - await libremdbHelper.initDefaults() - await reutersHelper.initDefaults() - await redditHelper.initDefaults() - await wikipediaHelper.initDefaults() - await imgurHelper.initDefaults() - await tiktokHelper.initDefaults() - await sendTargetsHelper.initDefaults() - await peertubeHelper.initDefaults() - await lbryHelper.initDefaults() - location.reload() - }) + browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate }, async () => { + await servicesHelper.initDefaults() + location.reload() + }) }) }) }) @@ -125,13 +89,13 @@ themeElement.addEventListener("change", event => { let protocolElement = document.getElementById("protocol") protocolElement.addEventListener("change", event => { const value = event.target.options[protocol.selectedIndex].value - browser.storage.local.set({ protocol: value }) + browser.storage.local.set({ network: value }) location.reload() }) let protocolFallbackCheckbox = document.getElementById("protocol-fallback-checkbox") protocolFallbackCheckbox.addEventListener("change", event => { - browser.storage.local.set({ protocolFallback: event.target.checked }) + browser.storage.local.set({ networkFallback: event.target.checked }) }) let latencyOutput = document.getElementById("latency-output") @@ -166,21 +130,21 @@ browser.storage.local.get( "theme", "autoRedirect", "exceptions", - "protocol", - "protocolFallback", + "network", + "networkFallback", "latencyThreshold", // 'firstPartyIsolate' ], r => { autoRedirectElement.checked = r.autoRedirect themeElement.value = r.theme - protocolElement.value = r.protocol - protocolFallbackCheckbox.checked = r.protocolFallback + protocolElement.value = r.network + protocolFallbackCheckbox.checked = r.networkFallback latencyOutput.value = r.latencyThreshold // firstPartyIsolate.checked = r.firstPartyIsolate; let protocolFallbackElement = document.getElementById("protocol-fallback") - if (protocolElement.value == "normal") { + if (protocolElement.value == "clearnet") { protocolFallbackElement.style.display = "none" } else { protocolFallbackElement.style.display = "block" diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index e523d5bb..be3d495e 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -17,7 +17,7 @@ section#general_page.option-block .some-block.option-block h4(data-localise="__MSG_protocol__") select#protocol - option(value="normal" data-localise="__MSG_normal__") Normal + option(value="clearnet" data-localise="__MSG_normal__") Clearnet option(value="tor") Tor option(value="i2p") I2P option(value="loki") Lokinet diff --git a/src/pages/options/widgets/imdb.js b/src/pages/options/widgets/imdb.js index 094c5672..f04bef20 100644 --- a/src/pages/options/widgets/imdb.js +++ b/src/pages/options/widgets/imdb.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("libremdb") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("imdb-enable") const imdb = document.getElementById("imdb_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableImdb", "protocol"], r => { enable.checked = !r.disableImdb - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/imdb.pug b/src/pages/options/widgets/imdb.pug index 008e1c00..67eb8eca 100644 --- a/src/pages/options/widgets/imdb.pug +++ b/src/pages/options/widgets/imdb.pug @@ -8,7 +8,7 @@ section#imdb_page.option-block #libremdb hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://libremdb.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/imgur.js b/src/pages/options/widgets/imgur.js index 236e809d..0272b94e 100644 --- a/src/pages/options/widgets/imgur.js +++ b/src/pages/options/widgets/imgur.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("rimgo") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("imgur-enable") const imgur = document.getElementById("imgur_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableImgur", "protocol"], r => { enable.checked = !r.disableImgur - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/imgur.pug b/src/pages/options/widgets/imgur.pug index eacd066e..46c497ec 100644 --- a/src/pages/options/widgets/imgur.pug +++ b/src/pages/options/widgets/imgur.pug @@ -9,7 +9,7 @@ section#imgur_page.option-block #rimgo hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://rimgo.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/instagram.js b/src/pages/options/widgets/instagram.js index e22f720f..f8301ae7 100644 --- a/src/pages/options/widgets/instagram.js +++ b/src/pages/options/widgets/instagram.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("bibliogram") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("instagram-enable") const instagram = document.getElementById("instagram_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableInstagram", "protocol"], r => { enable.checked = !r.disableInstagram - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/instagram.pug b/src/pages/options/widgets/instagram.pug index cc72f787..702aa651 100644 --- a/src/pages/options/widgets/instagram.pug +++ b/src/pages/options/widgets/instagram.pug @@ -9,7 +9,7 @@ section#instagram_page.option-block #bibliogram hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://bibliogram.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/lbry.js b/src/pages/options/widgets/lbry.js index d50de843..970f9130 100644 --- a/src/pages/options/widgets/lbry.js +++ b/src/pages/options/widgets/lbry.js @@ -1,7 +1,7 @@ import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("librarian") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("lbry-enable") const lbry = document.getElementById("lbry_page") @@ -36,7 +36,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableLbryTargets", "protocol", "lbryFrontend", "lbryRedirectType"], r => { enable.checked = !r.disableLbryTargets - protocol = r.protocol + protocol = r.network redirectType.value = r.lbryRedirectType frontend.value = r.lbryFrontend changeFrontendsSettings() diff --git a/src/pages/options/widgets/lbry.pug b/src/pages/options/widgets/lbry.pug index e4278438..9f01ebc6 100644 --- a/src/pages/options/widgets/lbry.pug +++ b/src/pages/options/widgets/lbry.pug @@ -21,7 +21,7 @@ section#lbry_page.option-block #librarian hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://librarian.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/maps.js b/src/pages/options/widgets/maps.js index acc8aca8..ba44c0c0 100644 --- a/src/pages/options/widgets/maps.js +++ b/src/pages/options/widgets/maps.js @@ -1,7 +1,7 @@ import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("facil") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("maps-enable") const maps = document.getElementById("maps_page") @@ -35,7 +35,7 @@ function changeFrontendsSettings() { browser.storage.local.get(["disableMaps", "protocol", "mapsFrontend"], r => { enable.checked = !r.disableMaps - protocol = r.protocol + protocol = r.network frontend.value = r.mapsFrontend changeFrontendsSettings() changeProtocolSettings() diff --git a/src/pages/options/widgets/maps.pug b/src/pages/options/widgets/maps.pug index 166e6494..66d0d411 100644 --- a/src/pages/options/widgets/maps.pug +++ b/src/pages/options/widgets/maps.pug @@ -14,7 +14,7 @@ section#maps_page.option-block #facil hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://facilmap.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/medium.js b/src/pages/options/widgets/medium.js index 8db5c0f0..c12df456 100644 --- a/src/pages/options/widgets/medium.js +++ b/src/pages/options/widgets/medium.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("scribe") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("medium-enable") const medium = document.getElementById("medium_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableMedium", "protocol"], r => { enable.checked = !r.disableMedium - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/medium.pug b/src/pages/options/widgets/medium.pug index 4eef0511..60223fdf 100644 --- a/src/pages/options/widgets/medium.pug +++ b/src/pages/options/widgets/medium.pug @@ -8,7 +8,7 @@ section#medium_page.option-block #scribe hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://scribe.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/peertube.js b/src/pages/options/widgets/peertube.js index e3b8dcc5..ca2be429 100644 --- a/src/pages/options/widgets/peertube.js +++ b/src/pages/options/widgets/peertube.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("simpleertube") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("peertube-enable") const peertube = document.getElementById("peertube_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disablePeertubeTargets", "protocol"], r => { enable.checked = !r.disablePeertubeTargets - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/peertube.pug b/src/pages/options/widgets/peertube.pug index 38690d04..2b818df4 100644 --- a/src/pages/options/widgets/peertube.pug +++ b/src/pages/options/widgets/peertube.pug @@ -8,7 +8,7 @@ section#peertube_page.option-block #simpleertube hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://simpleertube.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/quora.js b/src/pages/options/widgets/quora.js index f3e361c3..c0c0d68f 100644 --- a/src/pages/options/widgets/quora.js +++ b/src/pages/options/widgets/quora.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("quetre") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("quora-enable") const quora = document.getElementById("quora_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableQuora", "protocol"], r => { enable.checked = !r.disableQuora - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/quora.pug b/src/pages/options/widgets/quora.pug index 9e45abc9..7c3c52ac 100644 --- a/src/pages/options/widgets/quora.pug +++ b/src/pages/options/widgets/quora.pug @@ -8,7 +8,7 @@ section#quora_page.option-block #quetre hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://quetre.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/reddit.js b/src/pages/options/widgets/reddit.js index c2d16fa3..cae7a764 100644 --- a/src/pages/options/widgets/reddit.js +++ b/src/pages/options/widgets/reddit.js @@ -1,7 +1,7 @@ import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("libreddit", "teddit") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("reddit-enable") const reddit = document.getElementById("reddit_page") @@ -35,7 +35,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableReddit", "protocol", "redditFrontend"], r => { enable.checked = !r.disableReddit - protocol = r.protocol + protocol = r.network frontend.value = r.redditFrontend changeFrontendsSettings() changeProtocolSettings() diff --git a/src/pages/options/widgets/reddit.pug b/src/pages/options/widgets/reddit.pug index 1726f9ce..24c437f4 100644 --- a/src/pages/options/widgets/reddit.pug +++ b/src/pages/options/widgets/reddit.pug @@ -14,7 +14,7 @@ section#reddit_page.option-block #libreddit hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://libreddit.com') include ../../widgets/latency.pug @@ -31,7 +31,7 @@ section#reddit_page.option-block #teddit hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://teddit.com') +latency('teddit') diff --git a/src/pages/options/widgets/reuters.js b/src/pages/options/widgets/reuters.js index d8c937e4..58299969 100644 --- a/src/pages/options/widgets/reuters.js +++ b/src/pages/options/widgets/reuters.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("neuters") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("reuters-enable") const reuters = document.getElementById("reuters_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableReuters", "protocol"], r => { enable.checked = !r.disableReuters - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/reuters.pug b/src/pages/options/widgets/reuters.pug index 08a37d50..985965a1 100644 --- a/src/pages/options/widgets/reuters.pug +++ b/src/pages/options/widgets/reuters.pug @@ -8,7 +8,7 @@ section#reuters_page.option-block #neuters hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://neuters.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/search.js b/src/pages/options/widgets/search.js index 3301cd70..aa0aa94d 100644 --- a/src/pages/options/widgets/search.js +++ b/src/pages/options/widgets/search.js @@ -5,7 +5,7 @@ import utils from "../../../assets/javascripts/utils.js" // ONCE FINISHED: add librex and see if it works const frontends = new Array("searx", "searxng", "whoogle", "librex") // Add librex once /javascripts/search.js is made agnostic -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") //let frontendProtocols = (frontends.length) // I will leave comments of my privious attemps so that people can learn from my mistakes. :) @@ -29,12 +29,6 @@ for (var i = 0; i < frontends.length; i++) { } */ -/* -const searxDiv = document.getElementById("searx"); -const searxngDiv = document.getElementById("searxng"); -const whoogleDiv = document.getElementById("whoogle"); -*/ - const enable = document.getElementById("search-enable") const search = document.getElementById("search_page") const frontend = document.getElementById("search-frontend") @@ -49,33 +43,6 @@ function changeFrontendsSettings() { frontendDiv.style.display = "none" } } - - /* - if (frontend.value == 'searx') { - searxDiv.style.display = 'block'; - searxngDiv.style.display = 'none'; - whoogleDiv.style.display = 'none'; - librexDiv.style.display = 'none'; - } - else if (frontend.value == 'searxng') { - searxDiv.style.display = 'none'; - searxngDiv.style.display = 'block'; - whoogleDiv.style.display = 'none'; - librexDiv.style.display = 'none'; - } - else if (frontend.value == 'whoogle') { - searxDiv.style.display = 'none'; - searxngDiv.style.display = 'none'; - whoogleDiv.style.display = 'block'; - librexDiv.style.display = 'none'; - } - else if (frontend.value == 'librex') { - searxDiv.style.display = 'none'; - searxDiv.style.display = 'none'; - searxngDiv.style.display = 'none'; - librexDiv.style.display = 'block'; - } - */ } function changeProtocolSettings() { @@ -97,75 +64,12 @@ function changeProtocolSettings() { } */ } - - /* - * "Legacy" code - const normalsearxDiv = searxDiv.getElementsByClassName("normal")[0]; - const torsearxDiv = searxDiv.getElementsByClassName("tor")[0]; - const i2psearxDiv = searxDiv.getElementsByClassName("i2p")[0]; - - const normalsearxngDiv = searxngDiv.getElementsByClassName("normal")[0]; - const torsearxngDiv = searxngDiv.getElementsByClassName("tor")[0]; - const i2psearxngDiv = searxngDiv.getElementsByClassName("i2p")[0]; - - const torwhoogleDiv = whoogleDiv.getElementsByClassName("tor")[0]; - const i2pwhoogleDiv = whoogleDiv.getElementsByClassName("i2p")[0]; - const normalwhoogleDiv = whoogleDiv.getElementsByClassName("normal")[0]; - - - function protocolDisplay(proto) { - proto.searxngDiv = 'block' - } - - protocolDisplay(protocol.value) - - - if (protocol.value == 'normal') { - normalsearxDiv.style.display = 'block'; - normalsearxngDiv.style.display = 'block'; - normalwhoogleDiv.style.display = 'block'; - - torsearxDiv.style.display = 'none'; - torsearxngDiv.style.display = 'none'; - torwhoogleDiv.style.display = 'none'; - - i2psearxDiv.style.display = 'none'; - i2psearxngDiv.style.display = 'none'; - i2pwhoogleDiv.style.display = 'none'; - } - else if (protocol.value == 'tor') { - normalsearxDiv.style.display = 'none'; - normalsearxngDiv.style.display = 'none'; - normalwhoogleDiv.style.display = 'none'; - - torsearxDiv.style.display = 'block'; - torsearxngDiv.style.display = 'block'; - torwhoogleDiv.style.display = 'block'; - - i2psearxDiv.style.display = 'none'; - i2psearxngDiv.style.display = 'none'; - i2pwhoogleDiv.style.display = 'none'; - } - else if (protocol.value == 'i2p') { - normalsearxDiv.style.display = 'none'; - normalsearxngDiv.style.display = 'none'; - normalwhoogleDiv.style.display = 'none'; - - torsearxDiv.style.display = 'none'; - torsearxngDiv.style.display = 'none'; - torwhoogleDiv.style.display = 'none'; - - i2psearxDiv.style.display = 'block'; - i2psearxngDiv.style.display = 'block'; - i2pwhoogleDiv.style.display = 'block'; - } - */ } browser.storage.local.get(["disableSearch", "searchFrontend", "protocol"], r => { enable.checked = !r.disableSearch frontend.value = r.searchFrontend - protocol = r.protocol + protocol = r.network changeFrontendsSettings() changeProtocolSettings() @@ -185,20 +89,3 @@ search.addEventListener("change", () => { }) changeFrontendsSettings() }) - -/* - * more "legacy" code -utils.processDefaultCustomInstances('search', 'searx', 'normal', document); -utils.processDefaultCustomInstances('search', 'searx', 'tor', document); -utils.processDefaultCustomInstances('search', 'searx', 'i2p', document); -utils.processDefaultCustomInstances('search', 'searxng', 'normal', document); -utils.processDefaultCustomInstances('search', 'searxng', 'tor', document); -utils.processDefaultCustomInstances('search', 'searxng', 'i2p', document); -utils.processDefaultCustomInstances('search', 'whoogle', 'normal', document); -utils.processDefaultCustomInstances('search', 'whoogle', 'tor', document); -utils.processDefaultCustomInstances('search', 'whoogle', 'i2p', document); - -utils.latency('search', 'searx', document, location, true) -utils.latency('search', 'searxng', document, location, true) -utils.latency('search', 'whoogle', document, location, true) -*/ diff --git a/src/pages/options/widgets/search.pug b/src/pages/options/widgets/search.pug index 8f23350e..f449e0db 100644 --- a/src/pages/options/widgets/search.pug +++ b/src/pages/options/widgets/search.pug @@ -19,7 +19,7 @@ section#search_page.option-block #searx hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://searx.com') include ../../widgets/latency.pug @@ -36,7 +36,7 @@ section#search_page.option-block #searxng hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://searxng.com') +latency('searxng') @@ -52,7 +52,7 @@ section#search_page.option-block #whoogle hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://whoogle.com') +latency('whoogle') @@ -68,7 +68,7 @@ section#search_page.option-block #librex hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://librex.com') +latency('librex') diff --git a/src/pages/options/widgets/sendTargets.js b/src/pages/options/widgets/sendTargets.js index 9380a72f..b6acc02c 100644 --- a/src/pages/options/widgets/sendTargets.js +++ b/src/pages/options/widgets/sendTargets.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("send") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("sendTargets-enable") const sendTargets = document.getElementById("sendTargets_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableSendTarget", "protocol"], r => { enable.checked = !r.disableSendTarget - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/sendTargets.pug b/src/pages/options/widgets/sendTargets.pug index fc2e9e73..e7676b37 100644 --- a/src/pages/options/widgets/sendTargets.pug +++ b/src/pages/options/widgets/sendTargets.pug @@ -8,7 +8,7 @@ section#sendTargets_page.option-block #send hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://send.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/services.ejs b/src/pages/options/widgets/services.ejs new file mode 100644 index 00000000..14365871 --- /dev/null +++ b/src/pages/options/widgets/services.ejs @@ -0,0 +1,84 @@ +<% config.services.forEach(service=>{ %> +<section class="option-block" id="<%= service =%>_page"</section> + <div class="some-block option-block"> + <h1 data-localise="__MSG_<%= service =%>__"><%= config.services[service].name =%></h1> + </div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_enable__">Enable</h4> + <input id="<%= service =%>-enable" type="checkbox"> + </div> + <div class="some-block option-block"> + <h4 data-localise="__MSG_frontend__">Frontend</h4> + <select id="<%= service =%>-frontend"> + <% config.services[service].frontends.forEach(frontend=>{ %> + <option value="<%= frontend =%>"><%= frontend =%></option> + <% }); %> + <% config.services[service].singleInstanceFrontends.forEach(frontend=>{ %> + <option value="<%= frontend =%>"><%= frontend =%></option> + <% }); %> + </select> + </div> + <% if (config.services[service].embeddable) { %> + <% if (config.services[service].singleInstanceFrontends) { %> + <div id="<%= service =%>-embedded_frontend"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_embeddedVids__">Embedded Videos Frontend</h4> + <select id="<%= service =%>-embed_frontend"> + <% config.services[service].frontends.forEach(frontend=>{ %> + <option value="frontend">frontend</option> + <% }); %> + </select> + </div> + </div> + <% } %> + <div class="some-block option-block"> + <h4 data-localise="__MSG_redirectType__">Redirect Type</h4> + <select id="<%= service =%-redirect_type"> + <option value="both" data-localise="__MSG_both__">both</option> + <option value="onlyEmbedded" data-localise="__MSG_onlyEmbedded__">Only Embedded</option> + <option value="onlyNotEmbedded" data-localise="__MSG_onlyNotEmbedded__">Only Not Embedded</option> + </select> + </div> + <% } %> + <hr> + <% config.services[service].frontends.forEach(frontend=>{ %> + <div id="<%= frontend =%>"> + <% config.networks.forEach(network=>{ %> + <div class="<%= network =%>"> + <div class="some-block option-block"> + <h4 data-localise="__MSG_defaultInstances__">Default Instances</h4> + </div> + <div class="checklist"></div> + <hr> + <div class="some-block option-block"> + <h4 data-localise="__MSG_customInstances__">Custom Instances</h4> + </div> + <form class="custom-instance-form"> + <div class="some-block option-block"> + <input class="custom-instance" placeholder="http://<%= frontend =%>.<%= config[network].tld =%>" type="url"> + <button class="add add-instance" type="submit"> + <svg xmlns="https://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor"> + <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path> + </svg> + </button> + </div> + </form> + <div class="checklist custom-checklist"></div> + <% if (network == "clearnet") { %> + <div class="buttons buttons-inline"> + <label class="button button-inline" id="latency-<%= frontend =%>-label" for="latency-<%= frontend =%>"> + <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"> + <path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path> + </svg> + <x data-localise="__MSG_testInstancesLatency__">Test Instances Latency</x> + </label> + <input class="button button-inline" id="latency-<%= frontend =%>" style="display:none;"> + </div> + <% } %> + </div> + <% }); %> + <% }); %> +</section> +<% }); %> +<script type="module" src="./widgets/services.js"></script> \ No newline at end of file diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js new file mode 100644 index 00000000..5f370a18 --- /dev/null +++ b/src/pages/options/widgets/services.js @@ -0,0 +1,81 @@ +import utils from "../../../assets/javascripts/utils.js" + +// const frontends = new Array("librarian") +// const protocols = new Array("clearnet", "tor", "i2p", "loki") + +let config, + network, + divs = {} + +async function getConfig() { + return new Promise(resolve => { + fetch("/config/config.json") + .then(response => response.text()) + .then(data => { + config = JSON.parse(data) + resolve() + }) + }) +} + +getConfig() + +browser.storage.local.get("network", r => { + network = r.network +}) + +function changeFrontendsSettings(service) { + for (const frontend in config.services[service].frontends) { + const frontendDiv = document.getElementById(frontend) + if (frontend == divs[service].frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } + } +} + +function changeNetworkSettings(selectedNetwork) { + for (const frontend in config.frontends) { + const frontendDiv = document.getElementById(frontend) + for (const network in config.networks) { + const networkDiv = frontendDiv.getElementsByClassName(network)[0] + if (network == selectedNetwork) { + networkDiv.style.display = "block" + } else { + networkDiv.style.display = "none" + } + } + } +} + +for (service in config.services) { + divs[service][service] = document.getElementById(`${service}_page`) + for (const option in config.services[service].options) { + divs[service][option] = document.getElementById(`${service}-${option}`) + + browser.storage.local.get([`${service + utils.camelCase(option)}`], r => { + if (typeof config.services[service].options[option] == "boollean") divs[service][option].checked = !r[service + utils.camelCase(option)] + else divs[service][option].value = !r[service + utils.camelCase(option)] + }) + + divs[service][option].addEventListener("change", () => { + if (typeof config.services[service].options[option] == "boollean") { + browser.storage.local.set({ [service + utils.camelCase(option)]: !divs[service][option].checked }) + } else { + browser.storage.local.set({ [service + utils.camelCase(option)]: divs[service][option].value }) + } + changeFrontendsSettings() + }) + } + + changeFrontendsSettings(service) + changeNetworkSettings(network) + + for (const frontend in config.services[service].frontends) { + for (const network in config.networks) { + utils.processDefaultCustomInstances(service, frontend, network, document) + } + utils.latency(service, frontend, document, location) + } +} diff --git a/src/pages/options/widgets/tiktok.js b/src/pages/options/widgets/tiktok.js index 38ec9ea0..f382ad5a 100644 --- a/src/pages/options/widgets/tiktok.js +++ b/src/pages/options/widgets/tiktok.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("proxiTok") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("tiktok-enable") const tiktok = document.getElementById("tiktok_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableTiktok", "protocol"], r => { enable.checked = !r.disableTiktok - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/tiktok.pug b/src/pages/options/widgets/tiktok.pug index 29ab5e2a..986bd270 100644 --- a/src/pages/options/widgets/tiktok.pug +++ b/src/pages/options/widgets/tiktok.pug @@ -8,7 +8,7 @@ section#tiktok_page.option-block #proxiTok hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://proxitok.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/translate.js b/src/pages/options/widgets/translate.js index e1008139..c70b679f 100644 --- a/src/pages/options/widgets/translate.js +++ b/src/pages/options/widgets/translate.js @@ -1,7 +1,7 @@ import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("simplyTranslate", "lingva") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("translate-enable") const translate = document.getElementById("translate_page") @@ -36,7 +36,7 @@ function changeProtocolSettings() { browser.storage.local.get(["translateDisable", "translateFrontend", "protocol"], r => { enable.checked = !r.translateDisable frontend.value = r.translateFrontend - protocol = r.protocol + protocol = r.network changeFrontendsSettings() changeProtocolSettings() }) diff --git a/src/pages/options/widgets/translate.pug b/src/pages/options/widgets/translate.pug index 4836c0f3..40d42bca 100644 --- a/src/pages/options/widgets/translate.pug +++ b/src/pages/options/widgets/translate.pug @@ -14,7 +14,7 @@ section#translate_page.option-block hr #simplyTranslate - .normal + .clearnet include ../../widgets/instances.pug +instances('https://simplytranslate.org') include ../../widgets/latency.pug @@ -30,7 +30,7 @@ section#translate_page.option-block +instances('http://simplytranslate.loki') #lingva - .normal + .clearnet include ../../widgets/instances.pug +instances('https://lingvatranslate.com') +latency('lingva') diff --git a/src/pages/options/widgets/twitter.js b/src/pages/options/widgets/twitter.js index 5ad760b3..52d7a73b 100644 --- a/src/pages/options/widgets/twitter.js +++ b/src/pages/options/widgets/twitter.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("nitter") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("twitter-enable") const twitter = document.getElementById("twitter_page") @@ -40,7 +40,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableTwitter", "protocol", "twitterRedirectType"], r => { enable.checked = !r.disableTwitter - protocol = r.protocol + protocol = r.network redirectType.value = r.twitterRedirectType changeProtocolSettings() }) diff --git a/src/pages/options/widgets/twitter.pug b/src/pages/options/widgets/twitter.pug index 6e610545..fa7f1320 100644 --- a/src/pages/options/widgets/twitter.pug +++ b/src/pages/options/widgets/twitter.pug @@ -15,7 +15,7 @@ section#twitter_page.option-block #nitter hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://nitter.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/wikipedia.js b/src/pages/options/widgets/wikipedia.js index 9d06488b..120af919 100644 --- a/src/pages/options/widgets/wikipedia.js +++ b/src/pages/options/widgets/wikipedia.js @@ -3,7 +3,7 @@ import utils from "../../../assets/javascripts/utils.js" // UNCOMMENT ALL COMMENTS ONCE OTHER FRONTENDS EXIST const frontends = new Array("wikiless") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const enable = document.getElementById("wikipedia-enable") const wikipedia = document.getElementById("wikipedia_page") @@ -39,7 +39,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableWikipedia", "protocol"], r => { enable.checked = !r.disableWikipedia - protocol = r.protocol + protocol = r.network changeProtocolSettings() }) diff --git a/src/pages/options/widgets/wikipedia.pug b/src/pages/options/widgets/wikipedia.pug index c9aee64c..a0ad37c3 100644 --- a/src/pages/options/widgets/wikipedia.pug +++ b/src/pages/options/widgets/wikipedia.pug @@ -8,7 +8,7 @@ section#wikipedia_page.option-block #wikiless hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://wikiless.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/youtube.js b/src/pages/options/widgets/youtube.js index 065a195b..4e4bbbae 100644 --- a/src/pages/options/widgets/youtube.js +++ b/src/pages/options/widgets/youtube.js @@ -1,7 +1,7 @@ import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("invidious", "piped", "pipedMaterial", "cloudtube") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") const singleInstanceFrontends = new Array("freetube", "yatte") const enable = document.getElementById("youtube-enable") @@ -66,7 +66,7 @@ browser.storage.local.get(["disableYoutube", "onlyEmbeddedVideo", "youtubeRedire onlyEmbeddedVideo.value = r.onlyEmbeddedVideo youtubeEmbedFrontend.value = r.youtubeEmbedFrontend frontend.value = r.youtubeFrontend - protocol = r.protocol + protocol = r.network changeFrontendsSettings() changeProtocolSettings() diff --git a/src/pages/options/widgets/youtube.pug b/src/pages/options/widgets/youtube.pug index 33a43c34..cf48d9be 100644 --- a/src/pages/options/widgets/youtube.pug +++ b/src/pages/options/widgets/youtube.pug @@ -34,7 +34,7 @@ section#youtube_page.option-block #invidious hr - .normal + .clearnet include ../../widgets/instances.pug +instances('http://invidious.com') include ../../widgets/latency.pug @@ -51,7 +51,7 @@ section#youtube_page.option-block #piped hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://piped.com') include ../../widgets/latency.pug @@ -68,7 +68,7 @@ section#youtube_page.option-block #pipedMaterial hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://piped-material.com') include ../../widgets/latency.pug @@ -85,7 +85,7 @@ section#youtube_page.option-block #cloudtube hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://cloudtube.com') include ../../widgets/latency.pug diff --git a/src/pages/options/widgets/youtubeMusic.js b/src/pages/options/widgets/youtubeMusic.js index ad51ce7c..bb985b28 100644 --- a/src/pages/options/widgets/youtubeMusic.js +++ b/src/pages/options/widgets/youtubeMusic.js @@ -1,7 +1,7 @@ import utils from "../../../assets/javascripts/utils.js" const frontends = new Array("beatbump", "hyperpipe") -const protocols = new Array("normal", "tor", "i2p", "loki") +const protocols = new Array("clearnet", "tor", "i2p", "loki") let enable = document.getElementById("youtubeMusic-enable") const youtubeMusic = document.getElementById("youtubeMusic_page") @@ -36,7 +36,7 @@ function changeProtocolSettings() { browser.storage.local.get(["disableYoutubeMusic", "youtubeMusicFrontend", "protocol"], r => { enable.checked = !r.disableYoutubeMusic frontend.value = r.youtubeMusicFrontend - protocol = r.protocol + protocol = r.network changeFrontendsSettings() changeProtocolSettings() }) diff --git a/src/pages/options/widgets/youtubeMusic.pug b/src/pages/options/widgets/youtubeMusic.pug index bcba3d2d..9c2c08cf 100644 --- a/src/pages/options/widgets/youtubeMusic.pug +++ b/src/pages/options/widgets/youtubeMusic.pug @@ -14,7 +14,7 @@ section#youtubeMusic_page.option-block #beatbump hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://beatbump.org') include ../../widgets/latency.pug @@ -31,7 +31,7 @@ section#youtubeMusic_page.option-block #hyperpipe hr - .normal + .clearnet include ../../widgets/instances.pug +instances('https://hyperpipe.org') include ../../widgets/latency.pug |