From e48f68126d620bafe312a6caecc21a63612f8e69 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Tue, 12 Dec 2023 14:42:45 +0300 Subject: Fixed a bug that bypassses iframes in frontends pages https://github.com/libredirect/browser_extension/issues/866 --- src/pages/background/background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pages') diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 4b8f1ca2..9057f64a 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -71,7 +71,7 @@ browser.webRequest.onBeforeRequest.addListener( if (tabIdRedirects[details.tabId] != false) tabIdRedirects[details.tabId] = false return null } - console.info("Redirecting", url.href, "=>", newUrl) + console.log("Redirecting", url.href, "=>", newUrl) return { redirectUrl: newUrl } } return null -- cgit 1.4.1 From cfa6c887f1a9136f9ac96607fb3ff43be409bf99 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 8 Jan 2024 23:58:18 +0300 Subject: Fixed a bug in Switch Instance https://github.com/libredirect/browser_extension/issues/877 --- src/assets/javascripts/services.js | 13 ++++++++++--- src/pages/background/background.js | 4 +--- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/pages') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index a1935bff..3aba28d7 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -617,7 +617,11 @@ function switchInstance(url, customService) { if (customService) { const instancesList = options[options[customService].frontend] if (instancesList !== undefined) { - resolve(`${utils.getNextInstance(url.origin, instancesList)}${url.pathname}${url.search}`) + const newInstance = utils.getNextInstance(url.origin, instancesList) + if (newInstance) { + resolve(`${newInstance}${url.pathname}${url.search}`) + return + } } } else { for (const service in config.services) { @@ -630,8 +634,11 @@ function switchInstance(url, customService) { resolve() return } - resolve(`${utils.getNextInstance(url.origin, instancesList)}${url.pathname}${url.search}`) - return + const newInstance = utils.getNextInstance(url.origin, instancesList) + if (newInstance) { + resolve(`${newInstance}${url.pathname}${url.search}`) + return + } } } resolve() diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 9057f64a..3df43b52 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -160,9 +160,7 @@ browser.contextMenus.onClicked.addListener(async (info) => { case 'switchInstanceTab': { const url = new URL(info.pageUrl) const newUrl = await servicesHelper.switchInstance(url) - if (newUrl) { - browser.tabs.update({ url: newUrl }) - } + if (newUrl) browser.tabs.update({ url: newUrl }) return } case 'settingsTab': { -- cgit 1.4.1 From 8d944834fafe683d2d266252747d42a6317f5acf Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 29 Jan 2024 12:12:34 +0300 Subject: Fixed tapping on settings in popup not focusing https://github.com/libredirect/browser_extension/issues/873 --- package.json | 3 ++- src/manifest.json | 5 ++++- src/pages/popup/popup.js | 4 +++- src/pages/popup/popup.pug | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/pages') diff --git a/package.json b/package.json index fe0ac5aa..d6051747 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ }, "scripts": { "start": "web-ext run", - "start-nightly": "web-ext run --firefox=/home/manerakai/software/firefox_nightly/firefox", + "nightly": "web-ext run --firefox=/home/manerakai/software/firefox_nightly/firefox", + "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix", "build": "web-ext build", "test": "web-ext lint", "html": "pug --basedir ./ --obj ./src/config.json src/pages/options/index.pug --out src/pages/options/ && pug --basedir ./ --obj ./src/config.json src/pages/popup/popup.pug --out src/pages/popup/" diff --git a/src/manifest.json b/src/manifest.json index 34dea6e3..95c24bb1 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -7,6 +7,9 @@ "gecko": { "id": "7esoorv3@alefvanoon.anonaddy.me", "strict_min_version": "89.0" + }, + "gecko_android": { + "strict_min_version": "113.0" } }, "background": { @@ -85,4 +88,4 @@ "default_locale": "en", "update_url": "https://raw.githubusercontent.com/libredirect/libredirect/master/src/updates/updates.xml", "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAroWDSoSRZ1scj+eJRrvnhJbrqXTKnhQuxs6+AJg16sqr0bsMdFV+MSY4i4xnK+K5WOYkBliWXgUyk/wzicoAjOnSJddrL/Md4FuWHI2NVIkrlsLOrYkygi5OLqGPajRH/w8Cdmg7KzEpXe/OnYV0/qS8li8huEdTzdeLdhfbiVl1j3DOr4OJALQ7mPeeNFHFo/oVQ+OkSezWLezA5jUGfhtzPYV6u1TXzX7lCi8E/BbDbwkvvXOMcjXCv08kjdLOY2djCA2a6zr0xAb3q8DlexAMZ8vMof7AQRFtBKhLc9n9VFoipMMdBOVQQj/eIcRILBrmkcZNnJxFKiHNJ+NcZQIDAQAB" -} +} \ No newline at end of file diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 5eeb18c2..973637ba 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -4,7 +4,9 @@ window.browser = window.browser || window.chrome import servicesHelper from "../../assets/javascripts/services.js" import utils from "../../assets/javascripts/utils.js" -document.getElementById("more-options").addEventListener("click", () => browser.runtime.openOptionsPage()) +document.getElementById("more-options").href = browser.runtime.getURL("pages/options/index.html") +document.getElementById("more-options").setAttribute('target', '_blank') + const allSites = document.getElementById("all_sites") const currSite = document.getElementById("current_site") diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug index f145fe5d..709cace9 100644 --- a/src/pages/popup/popup.pug +++ b/src/pages/popup/popup.pug @@ -41,7 +41,7 @@ html(lang="en") path(d="M 17,20 V 11 Q 17,10.175 16.412,9.587 15.825,9 15,9 H 6.8 L 8.4,7.4 7,6 3,10 7,14 8.4,12.6 6.8,11 H 15 v 9 z" id="path2") div(class="block") - button(class="title button bottom-button" id="more-options") + a(class="title button bottom-button" id="more-options") label(data-localise="__MSG_settings__") Settings svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="26px" width="26px" fill="currentColor") path(d="m9.25 22-.4-3.2q-.325-.125-.612-.3-.288-.175-.563-.375L4.7 19.375l-2.75-4.75 2.575-1.95Q4.5 12.5 4.5 12.337v-.675q0-.162.025-.337L1.95 9.375l2.75-4.75 2.975 1.25q.275-.2.575-.375.3-.175.6-.3l.4-3.2h5.5l.4 3.2q.325.125.613.3.287.175.562.375l2.975-1.25 2.75 4.75-2.575 1.95q.025.175.025.337v.675q0 .163-.05.338l2.575 1.95-2.75 4.75-2.95-1.25q-.275.2-.575.375-.3.175-.6.3l-.4 3.2Zm2.8-6.5q1.45 0 2.475-1.025Q15.55 13.45 15.55 12q0-1.45-1.025-2.475Q13.5 8.5 12.05 8.5q-1.475 0-2.488 1.025Q8.55 10.55 8.55 12q0 1.45 1.012 2.475Q10.575 15.5 12.05 15.5Z") -- cgit 1.4.1 From fc6218c84d20860328e6d3ef3b79ab4fb04bed11 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 29 Jan 2024 18:15:31 +0300 Subject: Made popup mobile-friendly https://github.com/libredirect/browser_extension/issues/874 --- src/pages/popup/popup.js | 9 +++++++ src/pages/popup/popup.pug | 10 ++++---- src/pages/popup/style.css | 14 ++++++++++- src/pages/popup/switches.pug | 2 +- src/pages/stylesheets/styles.css | 51 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 7 deletions(-) (limited to 'src/pages') diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 973637ba..0e5a3d4b 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -7,6 +7,15 @@ import utils from "../../assets/javascripts/utils.js" document.getElementById("more-options").href = browser.runtime.getURL("pages/options/index.html") document.getElementById("more-options").setAttribute('target', '_blank') +const os = (await browser.runtime.getPlatformInfo()).os + +switch (os) { + case "fuchsia": + case "ios": + case "android": { + document.getElementsByTagName("html")[0].classList.add("mobile") + } +} const allSites = document.getElementById("all_sites") const currSite = document.getElementById("current_site") diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug index 709cace9..7e889702 100644 --- a/src/pages/popup/popup.pug +++ b/src/pages/popup/popup.pug @@ -19,31 +19,31 @@ html(lang="en") div(class="block" id="change_instance_div" style="display: none") button(class="title button bottom-button" id="change_instance") label(data-localise="__MSG_switchInstance__") Switch Instance - svg(xmlns="http://www.w3.org/2000/svg" height="26px" width="26px" fill="currentColor") + svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z") div(class="block" id="copy_original_div" title="Copy the original redirected link" style="display: none") button(class="title button bottom-button" id="copy_original") label() Copy Original - svg(xmlns="http://www.w3.org/2000/svg" height="24px" width="24px" fill="currentColor") + svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z") div(class="block" id="redirect_div" style="display: none") button(class="title button bottom-button" id="redirect") label Redirect - svg(xmlns="http://www.w3.org/2000/svg" height="24" width="24" fill="currentColor") + svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M7 20v-9q0-.825.588-1.413Q8.175 9 9 9h8.2l-1.6-1.6L17 6l4 4-4 4-1.4-1.4 1.6-1.6H9v9Z") div(class="block" id="redirect_to_original_div" style="display: none") button(class="title button bottom-button" id="redirect_to_original") label Redirect To Original - svg(xmlns="http://www.w3.org/2000/svg" height="24px" width="24px" fill="currentColor") + svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M 17,20 V 11 Q 17,10.175 16.412,9.587 15.825,9 15,9 H 6.8 L 8.4,7.4 7,6 3,10 7,14 8.4,12.6 6.8,11 H 15 v 9 z" id="path2") div(class="block") a(class="title button bottom-button" id="more-options") label(data-localise="__MSG_settings__") Settings - svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="26px" width="26px" fill="currentColor") + svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="m9.25 22-.4-3.2q-.325-.125-.612-.3-.288-.175-.563-.375L4.7 19.375l-2.75-4.75 2.575-1.95Q4.5 12.5 4.5 12.337v-.675q0-.162.025-.337L1.95 9.375l2.75-4.75 2.975 1.25q.275-.2.575-.375.3-.175.6-.3l.4-3.2h5.5l.4 3.2q.325.125.613.3.287.175.562.375l2.975-1.25 2.75 4.75-2.575 1.95q.025.175.025.337v.675q0 .163-.05.338l2.575 1.95-2.75 4.75-2.95-1.25q-.275.2-.575.375-.3.175-.6.3l-.4 3.2Zm2.8-6.5q1.45 0 2.475-1.025Q15.55 13.45 15.55 12q0-1.45-1.025-2.475Q13.5 8.5 12.05 8.5q-1.475 0-2.488 1.025Q8.55 10.55 8.55 12q0 1.45 1.012 2.475Q10.575 15.5 12.05 15.5Z") div(class="space") diff --git a/src/pages/popup/style.css b/src/pages/popup/style.css index 6c258d75..5e39b4ed 100644 --- a/src/pages/popup/style.css +++ b/src/pages/popup/style.css @@ -36,7 +36,6 @@ input { width: 46px; } - div.block label { margin: 0; font-size: 18px; @@ -50,4 +49,17 @@ div.block label:hover { div.block div { display: flex; +} + +html.mobile body { + width: 100%; +} + +html.mobile div.block label { + font-size: 24px; +} + +html.mobile .button svg { + width: 30px; + height: 30px; } \ No newline at end of file diff --git a/src/pages/popup/switches.pug b/src/pages/popup/switches.pug index bea107d2..20ed8c61 100644 --- a/src/pages/popup/switches.pug +++ b/src/pages/popup/switches.pug @@ -10,5 +10,5 @@ each _, service in services div input(class=`${service}-enabled` type="checkbox" aria-label=`toggle ${services[service].name}`) button(class=`${service}-change_instance title button` aria-label=`change instance for ${services[service].name}`) - svg(xmlns="http://www.w3.org/2000/svg" height="26px" width="26px" fill="currentColor") + svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z") \ No newline at end of file diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 2519a05f..2aa52d57 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -388,4 +388,55 @@ input:disabled { width: 750px; padding: 0 55px; } +} + +html.mobile img, +html.mobile svg { + margin-right: 10px; + height: 30px; + width: 30px; + color: var(--text); +} + +html.mobile div.block { + padding: 0 15px; + justify-content: space-between; + display: flex; + align-items: center; + margin-top: 20px; + margin-bottom: 20px; +} + +html.mobile div.block input[type="checkbox"] { + width: 58px; + height: 30px; +} + +html.mobile div.block input[type="checkbox"]::before { + width: 24px; + height: 24px; + top: 3px; + left: 3.5px; +} + +html.mobile div.block input[type="checkbox"]:checked::before { + left: 30px; +} + +html.mobile body.option { + flex-direction: column; + width: 100%; + padding: 0; + align-items: center; +} + + +html.mobile section.links { + flex-direction: row; + width: 100%; + padding: 0 55px; +} + +html.mobile section.block-option { + width: 100%; } \ No newline at end of file -- cgit 1.4.1 From e75eab979867d4813da6abcf527be50a509456e9 Mon Sep 17 00:00:00 2001 From: CompileNix Date: Sun, 10 Mar 2024 20:38:49 +0100 Subject: Re-order the popup menu items to improve UI / UX As discussed in #899 --- src/pages/popup/popup.pug | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/pages') diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug index 7e889702..d7ebdd49 100644 --- a/src/pages/popup/popup.pug +++ b/src/pages/popup/popup.pug @@ -6,16 +6,6 @@ html(lang="en") link(href="../stylesheets/styles.css" rel="stylesheet") link(href="./style.css" rel="stylesheet") body(dir="auto") - div(id="current_site") - include /src/pages/popup/switches - div(id="current_site_divider" style="display: none") - hr - - div(id="all_sites") - include /src/pages/popup/switches - - hr - div(class="block" id="change_instance_div" style="display: none") button(class="title button bottom-button" id="change_instance") label(data-localise="__MSG_switchInstance__") Switch Instance @@ -40,6 +30,18 @@ html(lang="en") svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M 17,20 V 11 Q 17,10.175 16.412,9.587 15.825,9 15,9 H 6.8 L 8.4,7.4 7,6 3,10 7,14 8.4,12.6 6.8,11 H 15 v 9 z" id="path2") + hr + + div(id="current_site") + include /src/pages/popup/switches + div(id="current_site_divider" style="display: none") + hr + + div(id="all_sites") + include /src/pages/popup/switches + + hr + div(class="block") a(class="title button bottom-button" id="more-options") label(data-localise="__MSG_settings__") Settings @@ -48,4 +50,4 @@ html(lang="en") div(class="space") script(type="module" src="../options/init.js") - script(type="module" src="./popup.js") \ No newline at end of file + script(type="module" src="./popup.js") -- cgit 1.4.1 From 2a239a2fb29b3a594602cc555a4e8f1946efb542 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 11 Mar 2024 07:51:30 +0300 Subject: Fixed settings conversion on update --- src/assets/javascripts/services.js | 37 +++++++++++++++++++++++------------ src/pages/options/widgets/general.pug | 2 +- 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'src/pages') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 4e243bb0..1a9c3f29 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -642,7 +642,6 @@ async function reverse(url) { case "imdb": case "imgur": case "tiktok": - case "twitter": case "reddit": case "imdb": case "snopes": @@ -702,7 +701,6 @@ const defaultInstances = { '4get': ['https://4get.ca'], 'rimgo': ['https://rimgo.vern.cc'], 'hyperpipe': ['https://hyperpipe.surge.sh'], - 'facil': [' https://facilmap.org '], 'osm': ['https://www.openstreetmap.org'], 'breezeWiki': ['https://breezewiki.com'], 'neuters': ['https://neuters.de'], @@ -749,12 +747,12 @@ function initDefaults() { } } } - options['exceptions'] = { + options.exceptions = { url: [], regex: [], } options.theme = "detect" - options.popupServices = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] + options.popupServices = ["youtube", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] options.fetchInstances = 'github' options.redirectOnlyInIncognito = false @@ -781,28 +779,27 @@ function upgradeOptions() { function processUpdate() { return new Promise(async resolve => { - let config = await utils.getConfig() + let frontends = [] + const config = await utils.getConfig() let options = await utils.getOptions() for (const service in config.services) { if (!options[service]) options[service] = {} if (!(options[service].frontend in config.services[service].frontends)) { - options[service] = config.services[service].options - delete options[options[service].frontend] + options[service] = config.services[service].options // Reset settings for service + delete options[options[service].frontend] // Remove deprecated frontend } for (const defaultOption in config.services[service].options) { - if (options[service][defaultOption] === undefined) { + if (!(defaultOption in options[service])) { options[service][defaultOption] = config.services[service].options[defaultOption] } } for (const frontend in config.services[service].frontends) { - if (options[frontend] === undefined && config.services[service].frontends[frontend].instanceList) { - options[frontend] = defaultInstances[frontend] - } - else if (frontend in options && !(frontend in config.services[service].frontends)) { - delete options[frontend] + frontends.push(frontend) + if (!(frontend in options) && config.services[service].frontends[frontend].instanceList) { + options[frontend] = defaultInstances[frontend] || [] } } @@ -813,6 +810,20 @@ function processUpdate() { } } } + const general = ['theme', 'popupServices', 'fetchInstances', 'redirectOnlyInIncognito'] + const combined = [ + ...Object.keys(config.services), + ...frontends, + ...general, + 'exceptions', + 'popupServices', + 'version', + ] + for (const key in options) { + if (combined.indexOf(key) < 0) { + delete options[key] // Remove any unknown settings in options + } + } browser.storage.local.set({ options }, () => { resolve() }) diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index 70316473..1388584a 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -51,7 +51,7 @@ section(class="block-option" id="general_page") 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") |  x(data-localise="__MSG_importSettings__") Import Settings - input(id="import-settings" type="file" style="display: none") + input(id="import-settings" type="file" accept=".json" style="display: none") |   -- cgit 1.4.1 From 5ca6836bd058faebdb4c2f442928b3f2baf77d92 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 11 Mar 2024 19:10:17 +0300 Subject: Fixed popup not working https://github.com/libredirect/browser_extension/issues/901 --- src/manifest.json | 2 +- src/pages/options/widgets/general.js | 10 +++------- src/pages/popup/popup.js | 16 +++++++++------- 3 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src/pages') diff --git a/src/manifest.json b/src/manifest.json index 95c24bb1..13908f0e 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", - "version": "2.8.2", + "version": "2.8.3", "manifest_version": 2, "browser_specific_settings": { "gecko": { diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 6f2852a9..8322a378 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -112,13 +112,9 @@ redirectOnlyInIncognitoElement.addEventListener('change', event => { const bookmarksMenuElement = document.getElementById('bookmarksMenu') bookmarksMenuElement.addEventListener('change', async event => { if (event.target.checked) - bookmarksMenuElement.checked = await browser.permissions.request({ - permissions: ["bookmarks"] - }) + browser.permissions.request({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = r) else - bookmarksMenuElement.checked = !await browser.permissions.remove({ - permissions: ["bookmarks"] - }) + browser.permissions.remove({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = !r) }) let themeElement = document.getElementById("theme") @@ -149,7 +145,7 @@ let options = await utils.getOptions() themeElement.value = options.theme fetchInstancesElement.value = options.fetchInstances redirectOnlyInIncognitoElement.checked = options.redirectOnlyInIncognito -bookmarksMenuElement.checked = await browser.permissions.contains({ permissions: ["bookmarks"] }) +browser.permissions.contains({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = r) for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service) instanceTypeElement.addEventListener("change", event => { diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 0e5a3d4b..777733f7 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -7,15 +7,17 @@ import utils from "../../assets/javascripts/utils.js" document.getElementById("more-options").href = browser.runtime.getURL("pages/options/index.html") document.getElementById("more-options").setAttribute('target', '_blank') -const os = (await browser.runtime.getPlatformInfo()).os - -switch (os) { - case "fuchsia": - case "ios": - case "android": { - document.getElementsByTagName("html")[0].classList.add("mobile") +await browser.runtime.getPlatformInfo(r => { + switch (r.os) { + case "fuchsia": + case "ios": + case "android": { + document.getElementsByTagName("html")[0].classList.add("mobile") + } } } +) + const allSites = document.getElementById("all_sites") const currSite = document.getElementById("current_site") -- cgit 1.4.1 From d53d84e39822e68efcbff3c6c7650783145d6864 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 14 Mar 2024 12:59:15 +0300 Subject: Hided hr in popup when no upper buttons are present --- src/pages/popup/popup.js | 5 +++++ src/pages/popup/popup.pug | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/pages') diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 777733f7..cfb7be27 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -70,10 +70,12 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { // Set visibility of control buttons if (tabs[0].url) { + const hr = document.getElementById("hr") url = new URL(tabs[0].url) servicesHelper.switchInstance(url).then(r => { if (r) { document.getElementById("change_instance_div").style.display = "" + hr.style.display = "" document.getElementById("change_instance").addEventListener("click", async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) }) ) @@ -82,6 +84,7 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { servicesHelper.copyRaw(url, true).then(r => { if (r) { document.getElementById("copy_original_div").style.display = "" + hr.style.display = "" document.getElementById("copy_original").addEventListener("click", () => servicesHelper.copyRaw(url) ) @@ -90,6 +93,7 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { servicesHelper.reverse(url).then(r => { if (r) { document.getElementById("redirect_to_original_div").style.display = "" + hr.style.display = "" document.getElementById("redirect_to_original").addEventListener("click", () => browser.runtime.sendMessage("reverseTab") ) @@ -98,6 +102,7 @@ browser.tabs.query({ active: true, currentWindow: true }, async tabs => { servicesHelper.redirectAsync(url, "main_frame", null, true).then(r => { if (r) { document.getElementById("redirect_div").style.display = "" + hr.style.display = "" document.getElementById("redirect").addEventListener("click", () => browser.runtime.sendMessage("redirectTab") ) diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug index d7ebdd49..ed4c7319 100644 --- a/src/pages/popup/popup.pug +++ b/src/pages/popup/popup.pug @@ -30,7 +30,7 @@ html(lang="en") svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") path(d="M 17,20 V 11 Q 17,10.175 16.412,9.587 15.825,9 15,9 H 6.8 L 8.4,7.4 7,6 3,10 7,14 8.4,12.6 6.8,11 H 15 v 9 z" id="path2") - hr + hr(id="hr" style="display: none") div(id="current_site") include /src/pages/popup/switches -- cgit 1.4.1 From c4331d18204a9229ab37e483bc5053058e7b19ae Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 14 Mar 2024 13:28:47 +0300 Subject: Made Settings page more responsive --- src/pages/stylesheets/styles.css | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/pages') diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 2aa52d57..5de72477 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -375,19 +375,27 @@ input:disabled { cursor: not-allowed; } - @media (max-width: 1250px) { body.option { flex-direction: column; - width: 750px; + width: 95vw; align-items: center; + padding: 40px 0px; } section.links { flex-direction: row; - width: 750px; + width: 95vw; padding: 0 55px; } + + section.block-option { + width: 95vw; + } + + div.checklist div x { + overflow: hidden; + } } html.mobile img, -- cgit 1.4.1 From b9b2a53fd38a6573231ceee86b2c9ab2b55003e7 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 14 Mar 2024 14:03:10 +0300 Subject: Added Soprano https://github.com/libredirect/browser_extension/issues/888 --- src/assets/images/tenor-icon.svg | 51 ++++++++++++++++++++++++++++++++++++++ src/assets/javascripts/services.js | 1 + src/config.json | 20 +++++++++++++++ src/pages/stylesheets/styles.css | 2 +- 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/assets/images/tenor-icon.svg (limited to 'src/pages') diff --git a/src/assets/images/tenor-icon.svg b/src/assets/images/tenor-icon.svg new file mode 100644 index 00000000..8cdc1214 --- /dev/null +++ b/src/assets/images/tenor-icon.svg @@ -0,0 +1,51 @@ + +TENOR_VECTORCreated with Sketch. diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 96595fda..dceb1c2d 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -718,6 +718,7 @@ const defaultInstances = { 'wikiless': ['https://wikiless.org'], 'suds': ['https://sd.vern.cc'], 'unfunny': ['https://uf.vern.cc'], + 'soprano': ['https://sp.vern.cc'], 'waybackClassic': ['https://wayback-classic.net'], 'gothub': ['https://gh.odyssey346.dev'], 'mikuInvidious': ['https://mikuinv.resrv.org'], diff --git a/src/config.json b/src/config.json index 808a32b9..cf4ed558 100644 --- a/src/config.json +++ b/src/config.json @@ -737,6 +737,26 @@ "imageType": "svg", "url": "https://ifunny.co" }, + "tenor": { + "frontends": { + "soprano": { + "name": "Soprano", + "instanceList": true, + "url": "https://git.vern.cc/cobra/Soprano" + } + }, + "targets": [ + "^https?:\\/{2}(www\\.)?tenor\\.com\\/" + ], + "name": "Tenor", + "options": { + "enabled": false, + "unsupportedUrls": "bypass", + "frontend": "soprano" + }, + "imageType": "svg", + "url": "https://tenor.com" + }, "urbanDictionary": { "frontends": { "ruralDictionary": { diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 5de72477..e3212a66 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -131,7 +131,7 @@ section.links { flex-wrap: wrap; flex-direction: column; width: 350px; - max-height: 930px; + max-height: 970px; } section.links div { -- cgit 1.4.1 From 9d750897ec4b36766ca876549c0af31746f9c05b Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 20 May 2024 13:57:31 +0300 Subject: Cleaning code --- src/assets/javascripts/services.js | 174 +++++++++++------------------------ src/assets/javascripts/utils.js | 23 +---- src/pages/options/index.js | 6 +- src/pages/options/widgets/general.js | 5 +- 4 files changed, 63 insertions(+), 145 deletions(-) (limited to 'src/pages') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index e51a1d43..e5a57890 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -5,12 +5,9 @@ window.browser = window.browser || window.chrome let config, options -function init() { - return new Promise(async resolve => { - options = await utils.getOptions() - config = await utils.getConfig() - resolve() - }) +async function init() { + options = await utils.getOptions() + config = await utils.getConfig() } init() @@ -69,38 +66,26 @@ async function redirectAsync(url, type, initiator, forceRedirection) { */ function rewrite(url, frontend, randomInstance) { switch (frontend) { - case "hyperpipe": { + case "hyperpipe": return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/")) - } case "searx": - case "searxng": { + case "searxng": return `${randomInstance}/${url.search}` - } - case "whoogle": { + case "whoogle": return `${randomInstance}/search${url.search}` - } case "4get": { const s = url.searchParams.get("q") - if (s !== null) { - return `${randomInstance}/web?s=${encodeURIComponent(s)}` - } + if (s !== null) return `${randomInstance}/web?s=${encodeURIComponent(s)}` return randomInstance } - case "librey": { + case "librey": return `${randomInstance}/search.php${url.search}` - } - case "send": { - return randomInstance - } - case "yattee": { + case "yattee": return url.href.replace(/^https?:\/{2}/, "yattee://") - } - case "freetube": { + case "freetube": return 'freetube://' + url.href - } - case "freetubePwa": { + case "freetubePwa": return 'freetube://' + url.href - } case "poketube": { if (url.pathname.startsWith('/channel')) { const reg = /\/channel\/(.*)\/?$/.exec(url.pathname) @@ -123,19 +108,13 @@ function rewrite(url, frontend, randomInstance) { } return `${randomInstance}${url.pathname}${url.search}` } - case "simplyTranslate": { + case "simplyTranslate": return `${randomInstance}/${url.search}` - } - case "mozhi": { - return `${randomInstance}` - } - case "libreTranslate": { - let search = url.search - .replace("sl", "source") - .replace("tl", "target") - .replace("text", "q") - return `${randomInstance}/${search}` - } + case "send": + case "mozhi": + return randomInstance + case "libreTranslate": + return `${randomInstance}/${url.search.replace("sl", "source").replace("tl", "target").replace("text", "q")}` case "osm": { const placeRegex = /\/place\/(.*?)\// function convertMapCentre(url) { @@ -249,12 +228,9 @@ function rewrite(url, frontend, randomInstance) { } return `${randomInstance}${wiki}${urlpath}${url.search}` } - case "rimgo": { - if (url.href.search(/^https?:\/{2}(?:[im]\.)?stack\./) > -1) { - return `${randomInstance}/stack${url.pathname}${url.search}` - } + case "rimgo": + if (url.href.search(/^https?:\/{2}(?:[im]\.)?stack\./) > -1) return `${randomInstance}/stack${url.pathname}${url.search}` return `${randomInstance}${url.pathname}${url.search}` - } case "redlib": case "libreddit": { const subdomain = url.hostname.match(/^(?:(?:external-)?preview|i)(?=\.redd\.it)/) @@ -269,13 +245,12 @@ function rewrite(url, frontend, randomInstance) { } return randomInstance } - case "teddit": { + case "teddit": if (/^(?:(?:external-)?preview|i)\.redd\.it/.test(url.hostname)) { if (url.search == "") return `${randomInstance}${url.pathname}?teddit_proxy=${url.hostname}` else return `${randomInstance}${url.pathname}${url.search}&teddit_proxy=${url.hostname}` } return `${randomInstance}${url.pathname}${url.search}` - } case "neuters": { const p = url.pathname if (p.startsWith('/article/') || p.startsWith('/pf/') || p.startsWith('/arc/') || p.startsWith('/resizer/')) { @@ -283,19 +258,14 @@ function rewrite(url, frontend, randomInstance) { } return `${randomInstance}${p}` } - case "dumb": { - if (url.pathname.endsWith('-lyrics')) { - return `${randomInstance}${url.pathname}` - } + case "dumb": + if (url.pathname.endsWith('-lyrics')) return `${randomInstance}${url.pathname}` return `${randomInstance}${url.pathname}${url.search}` - } - case "intellectual": { + case "intellectual": return `${randomInstance}${url.pathname}${url.search}` - } - case "ruralDictionary": { + case "ruralDictionary": if (!url.pathname.includes('/define.php') && !url.pathname.includes('/random.php') && url.pathname != '/') return randomInstance return `${randomInstance}${url.pathname}${url.search}` - } case "anonymousOverflow": { if (url.hostname == "stackoverflow.com") { const threadID = /^\/a\/(\d+)\/?/.exec(url.pathname) @@ -317,9 +287,8 @@ function rewrite(url, frontend, randomInstance) { } return `${randomInstance}${url.pathname}${url.search}` } - case "biblioReads": { + case "biblioReads": return `${randomInstance}${url.pathname}${url.search}` - } case "wikiless": { let hostSplit = url.host.split(".") // wikiless doesn't have mobile view support yet @@ -330,10 +299,9 @@ function rewrite(url, frontend, randomInstance) { } return `${randomInstance}${url.pathname}${url.search}${url.hash}` } - case "proxiTok": { + case "proxiTok": if (url.pathname.startsWith('/email')) return randomInstance return `${randomInstance}${url.pathname}${url.search}` - } case "waybackClassic": { const regex = /^\/\web\/(?:[0-9]+)?\*\/(.*)/.exec(url.pathname) if (regex) { @@ -348,19 +316,13 @@ function rewrite(url, frontend, randomInstance) { } return } - case "gothub": { + case "gothub": if (url.hostname == "gist.github.com") return `${randomInstance}/gist${url.pathname}${url.search}` if (url.hostname == "raw.githubusercontent.com") return `${randomInstance}/raw${url.pathname}${url.search}` return `${randomInstance}${url.pathname}${url.search}` - } - case "mikuInvidious": { - if (url.hostname == "bilibili.com" || url.hostname == "www.bilibili.com" || url.hostname == 'b23.tv') { - return `${randomInstance}${url.pathname}${url.search}` - } - if (url.hostname == "space.bilibili.com") { - return `${randomInstance}/space${url.pathname}${url.search}` - } - } + case "mikuInvidious": + if (url.hostname == "bilibili.com" || url.hostname == "www.bilibili.com" || url.hostname == 'b23.tv') return `${randomInstance}${url.pathname}${url.search}` + if (url.hostname == "space.bilibili.com") return `${randomInstance}/space${url.pathname}${url.search}` case "tent": { if (url.hostname == 'bandcamp.com' && url.pathname == '/search') { const query = url.searchParams.get('q') @@ -396,9 +358,8 @@ function rewrite(url, frontend, randomInstance) { } } } - case "binternet": { + case "binternet": if (url.hostname == "i.pinimg.com") return `${randomInstance}/image_proxy.php?url=${url.href}` - } case "laboratory": { let path = url.pathname if (path == "/") path = "" @@ -446,68 +407,44 @@ function rewrite(url, frontend, randomInstance) { } return `${randomInstance}${url.pathname}${url.search}` } - case "tuboYoutube": { - if (url.pathname.startsWith("/channel")) { - return `${randomInstance}/channel?url=${encodeURIComponent(url.href)}` - } - if (url.pathname.startsWith("/watch")) { - return `${randomInstance}/stream?url=${encodeURIComponent(url.href)}` - } - return `${randomInstance}` - } - case "tuboSoundcloud": { + case "tuboYoutube": + if (url.pathname.startsWith("/channel")) return `${randomInstance}/channel?url=${encodeURIComponent(url.href)}` + if (url.pathname.startsWith("/watch")) return `${randomInstance}/stream?url=${encodeURIComponent(url.href)}` + return randomInstance + case "tuboSoundcloud": if (url.pathname == '/') return `${randomInstance}?kiosk?serviceId=1` - if (url.pathname.match(/^\/[^\/]+(\/$|$)/)) { - return `${randomInstance}/channel?url=${encodeURIComponent(url.href)}` - } - if (url.pathname.match(/^\/[^\/]+\/[^\/]+/)) { - return `${randomInstance}/stream?url=${encodeURIComponent(url.href)}` - } - return `${randomInstance}` - } + if (url.pathname.match(/^\/[^\/]+(\/$|$)/)) return `${randomInstance}/channel?url=${encodeURIComponent(url.href)}` + if (url.pathname.match(/^\/[^\/]+\/[^\/]+/)) return `${randomInstance}/stream?url=${encodeURIComponent(url.href)}` + return randomInstance case "twineo": - case "safetwitch": { - if (url.hostname.startsWith("clips.")) { - return `${randomInstance}/clip${url.pathname}${url.search}` - } + case "safetwitch": + if (url.hostname.startsWith("clips.")) return `${randomInstance}/clip${url.pathname}${url.search}` return `${randomInstance}${url.pathname}${url.search}` - } - case "tekstoLibre": { + + case "tekstoLibre": return `${randomInstance}/?${url.pathname.slice(1)}`; - } - case "skyview": { + case "skyview": if (url.pathname == '/') return randomInstance return `${randomInstance}?url=${encodeURIComponent(url.href)}` - } case "priviblur": { - if (url.hostname == "www.tumblr.com") - return `${randomInstance}${url.pathname}${url.search}` - - if (url.hostname.startsWith("assets")) - return `${randomInstance}/tblr/assets${url.pathname}${url.search}` - - if (url.hostname.startsWith("static")) - return `${randomInstance}/tblr/static${url.pathname}${url.search}` + if (url.hostname == "www.tumblr.com") return `${randomInstance}${url.pathname}${url.search}` + if (url.hostname.startsWith("assets")) return `${randomInstance}/tblr/assets${url.pathname}${url.search}` + if (url.hostname.startsWith("static")) return `${randomInstance}/tblr/static${url.pathname}${url.search}` const reg = /^([0-9]+)\.media\.tumblr\.com/.exec(url.hostname) // *.media.tumblr.com - if (reg) - return `${randomInstance}/tblr/media/${reg[1]}${url.pathname}${url.search}` + if (reg) return `${randomInstance}/tblr/media/${reg[1]}${url.pathname}${url.search}` const blogregex = /^(?:www\.)?([a-z\d-]+)\.tumblr\.com/.exec(url.hostname) // .tumblr.com if (blogregex) { const blog_name = blogregex[1]; // Under the .tumblr.com domain posts are under a /post path - if (url.pathname.startsWith("/post")) { - return `${randomInstance}/${blog_name}${url.pathname.slice(5)}${url.search}` - } else { - return `${randomInstance}/${blog_name}${url.pathname}${url.search}`; - } + if (url.pathname.startsWith("/post")) return `${randomInstance}/${blog_name}${url.pathname.slice(5)}${url.search}` + else return `${randomInstance}/${blog_name}${url.pathname}${url.search}`; } return `${randomInstance}${url.pathname}${url.search}`; } - default: { + default: return `${randomInstance}${url.pathname}${url.search}` - } } } @@ -657,10 +594,11 @@ async function reverse(url) { case "quora": case "medium": return `${config.services[service].url}${url.pathname}${url.search}` - case "fandom": + case "fandom": { let regex = url.pathname.match(/^\/([a-zA-Z0-9-]+)\/wiki\/(.*)/) if (regex) return `https://${regex[1]}.fandom.com/wiki/${regex[2]}` return + } case "wikipedia": { const lang = url.searchParams.get("lang") if (lang != null) { @@ -678,9 +616,8 @@ async function reverse(url) { } return } - case "tekstowo": { + case "tekstowo": return `${config.services[service].url}/${url.search.slice(1)}` - } default: return } @@ -875,8 +812,7 @@ function isException(url) { if (exceptions.url) { for (let item of exceptions.url) { item = new URL(item) - item = item.href - item = item.replace(/^http:\/\//, 'https://') + item = item.href.replace(/^http:\/\//, 'https://') if (item == url.href) return true } } diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index fe08e576..af972d22 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -15,13 +15,8 @@ function getRandomInstance(instances) { */ function getNextInstance(currentInstanceUrl, instances) { const currentInstanceIndex = instances.indexOf(currentInstanceUrl); - - if (currentInstanceIndex === -1){ - return getRandomInstance(instances); - } - + if (currentInstanceIndex === -1) return getRandomInstance(instances); const nextInstanceIndex = (currentInstanceIndex + 1) % instances.length; - return instances[nextInstanceIndex]; } @@ -101,12 +96,8 @@ function getPingCache() { function getBlacklist(options) { return new Promise(resolve => { let url - if (options.fetchInstances == 'github') { - url = 'https://raw.githubusercontent.com/libredirect/instances/main/blacklist.json' - } - else if (options.fetchInstances == 'codeberg') { - url = 'https://codeberg.org/LibRedirect/instances/raw/branch/main/blacklist.json' - } + if (options.fetchInstances == 'github') url = 'https://raw.githubusercontent.com/libredirect/instances/main/blacklist.json' + else if (options.fetchInstances == 'codeberg') url = 'https://codeberg.org/LibRedirect/instances/raw/branch/main/blacklist.json' else { resolve('disabled') return @@ -134,12 +125,8 @@ function getBlacklist(options) { function getList(options) { return new Promise(resolve => { let url - if (options.fetchInstances == 'github') { - url = 'https://raw.githubusercontent.com/libredirect/instances/main/data.json' - } - else if (options.fetchInstances == 'codeberg') { - url = 'https://codeberg.org/LibRedirect/instances/raw/branch/main/data.json' - } + if (options.fetchInstances == 'github') url = 'https://raw.githubusercontent.com/libredirect/instances/main/data.json' + else if (options.fetchInstances == 'codeberg') url = 'https://codeberg.org/LibRedirect/instances/raw/branch/main/data.json' else { resolve('disabled') return diff --git a/src/pages/options/index.js b/src/pages/options/index.js index fcc51298..ec47f3c5 100644 --- a/src/pages/options/index.js +++ b/src/pages/options/index.js @@ -260,7 +260,7 @@ async function processCustomInstances(frontend, document) { /** * @param {string} frontend * @param {*} networks - * @param {*} document + * @param {Document} document * @param {*} redirects * @param {*} blacklist */ @@ -393,7 +393,5 @@ function processTime(time) { color = "red" text = 'Server not found' } - return { - color, text - } + return { color, text } } diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 8322a378..64172287 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -206,10 +206,7 @@ document.getElementById("custom-exceptions-instance-form").addEventListener("sub if (val) { options = await utils.getOptions() options.exceptions = exceptionsCustomInstances - browser.storage.local.set({ options }, () => - nameCustomInstanceInput.value = "" - ) - + browser.storage.local.set({ options }, () => nameCustomInstanceInput.value = "") } calcExceptionsCustomInstances() }) -- cgit 1.4.1 From abcd566305d0ede82bf81c4809fd59ea7c67591c Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 20 May 2024 14:34:18 +0300 Subject: Removed ?si= from youtube frontends https://github.com/libredirect/browser_extension/issues/922 --- src/assets/javascripts/services.js | 11 +++++++++++ src/pages/background/background.js | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/pages') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index b78cbb99..4f9fdac1 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -81,12 +81,16 @@ function rewrite(url, frontend, randomInstance) { case "librey": return `${randomInstance}/search.php${url.search}` case "yattee": + url.searchParams.delete("si") return url.href.replace(/^https?:\/{2}/, "yattee://") case "freetube": + url.searchParams.delete("si") return 'freetube://' + url.href case "freetubePwa": + url.searchParams.delete("si") return 'freetube://' + url.href case "poketube": { + url.searchParams.delete("si") if (url.pathname.startsWith('/channel')) { const reg = /\/channel\/(.*)\/?$/.exec(url.pathname) if (reg) { @@ -383,6 +387,7 @@ function rewrite(url, frontend, randomInstance) { return `${randomInstance}${url.pathname}${url.search}` } case "invidious": { + url.searchParams.delete("si") if (url.hostname == "youtu.be" || url.hostname.endsWith("youtube.com") && url.pathname.startsWith("/live")) { const watch = url.pathname.substring(url.pathname.lastIndexOf('/') + 1) return `${randomInstance}/watch?v=${watch}${url.search.replace("?", "&")}` @@ -407,6 +412,7 @@ function rewrite(url, frontend, randomInstance) { return `${randomInstance}${url.pathname}${url.search}` } case "tuboYoutube": + url.searchParams.delete("si") if (url.pathname.startsWith("/channel")) return `${randomInstance}/channel?url=${encodeURIComponent(url.href)}` if (url.pathname.startsWith("/watch")) return `${randomInstance}/stream?url=${encodeURIComponent(url.href)}` return randomInstance @@ -442,6 +448,11 @@ function rewrite(url, frontend, randomInstance) { } return `${randomInstance}${url.pathname}${url.search}`; } + case "piped": + case "pipedMaterial": + case "cloudtube": + case "viewtube": + url.searchParams.delete("si") default: return `${randomInstance}${url.pathname}${url.search}` } diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 3df43b52..0754f8a5 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -32,6 +32,7 @@ let tabIdRedirects = {} browser.webRequest.onBeforeRequest.addListener( details => { const url = new URL(details.url) + const old_href = url.href if (new RegExp(/^chrome-extension:\/{2}.*\/instances\/.*.json$/).test(url.href) && details.type == "xmlhttprequest") return let initiator try { @@ -71,7 +72,7 @@ browser.webRequest.onBeforeRequest.addListener( if (tabIdRedirects[details.tabId] != false) tabIdRedirects[details.tabId] = false return null } - console.log("Redirecting", url.href, "=>", newUrl) + console.log("Redirecting", old_href, "=>", newUrl) return { redirectUrl: newUrl } } return null -- cgit 1.4.1 From 73f85a005eeb28e999839e90077874defc16d00b Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 20 May 2024 22:55:33 +0300 Subject: Added custom label to instances not from the public list https://github.com/libredirect/browser_extension/issues/907. Cleaned code --- src/pages/options/index.js | 59 +++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 24 deletions(-) (limited to 'src/pages') diff --git a/src/pages/options/index.js b/src/pages/options/index.js index ec47f3c5..9274023f 100644 --- a/src/pages/options/index.js +++ b/src/pages/options/index.js @@ -2,6 +2,8 @@ import utils from "../../assets/javascripts/utils.js" let config, options, + blacklist, + redirects, divs = {} for (const a of document.getElementById("links").getElementsByTagName("a")) { @@ -148,20 +150,11 @@ async function loadPage(path) { changeFrontendsSettings(service) - for (const frontend in config.services[service].frontends) { - if (config.services[service].frontends[frontend].instanceList) { - processCustomInstances(frontend, document) - document.getElementById(`ping-${frontend}`).addEventListener("click", async () => { - document.getElementById(`ping-${frontend}`).getElementsByTagName('x')[0].innerHTML = "Pinging..." - await ping(frontend) - document.getElementById(`ping-${frontend}`).getElementsByTagName('x')[0].innerHTML = "Ping instances" - }) - } - } + !async function () { - const blacklist = await utils.getBlacklist(options) - const redirects = await utils.getList(options) + blacklist = await utils.getBlacklist(options) + redirects = await utils.getList(options) for (const frontend in config.services[service].frontends) { if (config.services[service].frontends[frontend].instanceList) { @@ -177,10 +170,21 @@ async function loadPage(path) { .innerHTML = 'Could not fetch instances.' } else { - createList(frontend, config.networks, document, redirects, blacklist) + createList(frontend) } } } + + for (const frontend in config.services[service].frontends) { + if (config.services[service].frontends[frontend].instanceList) { + processCustomInstances(frontend) + document.getElementById(`ping-${frontend}`).addEventListener("click", async () => { + document.getElementById(`ping-${frontend}`).getElementsByTagName('x')[0].innerHTML = "Pinging..." + await ping(frontend) + document.getElementById(`ping-${frontend}`).getElementsByTagName('x')[0].innerHTML = "Ping instances" + }) + } + } }() } } @@ -199,10 +203,12 @@ async function calcCustomInstances(frontend) { const { color, text } = processTime(time) timeText = `${text}` } + const custom = isCustomInstance(frontend, x) ? "" : `custom` return `
${x} ${timeText} + ${custom}

` - }) - .join("\n") - for (const item of customInstances) { - document.getElementById(frontend).getElementsByClassName(`clear-${item}`)[0].addEventListener("click", async () => { - const index = customInstances.indexOf(item) - if (index > -1) customInstances.splice(index, 1) - options = await utils.getOptions() - options[frontend] = customInstances - browser.storage.local.set({ options }, async () => { - calcCustomInstances(frontend) - createList(frontend) - }) - }) - } + }) + .join("\n") + for (const item of customInstances) { + document + .getElementById(frontend) + .getElementsByClassName(`clear-${item}`)[0] + .addEventListener("click", async () => { + const index = customInstances.indexOf(item) + if (index > -1) customInstances.splice(index, 1) + options = await utils.getOptions() + options[frontend] = customInstances + browser.storage.local.set({ options }, async () => { + calcCustomInstances(frontend) + createList(frontend) + }) + }) + } } async function processCustomInstances(frontend) { - calcCustomInstances(frontend) - document.getElementById(frontend).getElementsByClassName("custom-instance-form")[0].addEventListener("submit", async event => { - event.preventDefault() - let options = await utils.getOptions() - let customInstances = options[frontend] - let frontendCustomInstanceInput = document.getElementById(frontend).getElementsByClassName("custom-instance")[0] - try { - var url = new URL(frontendCustomInstanceInput.value) - } catch (error) { - return - } - let protocolHostVar = utils.protocolHost(url) - if (frontendCustomInstanceInput.validity.valid) { - if (!customInstances.includes(protocolHostVar)) { - customInstances.push(protocolHostVar) - options = await utils.getOptions() - options[frontend] = customInstances - browser.storage.local.set({ options }, () => { - frontendCustomInstanceInput.value = "" - calcCustomInstances(frontend) - }) - } - } - }) + calcCustomInstances(frontend) + document + .getElementById(frontend) + .getElementsByClassName("custom-instance-form")[0] + .addEventListener("submit", async event => { + event.preventDefault() + let options = await utils.getOptions() + let customInstances = options[frontend] + let frontendCustomInstanceInput = document.getElementById(frontend).getElementsByClassName("custom-instance")[0] + try { + var url = new URL(frontendCustomInstanceInput.value) + } catch (error) { + return + } + let protocolHostVar = utils.protocolHost(url) + if (frontendCustomInstanceInput.validity.valid) { + if (!customInstances.includes(protocolHostVar)) { + customInstances.push(protocolHostVar) + options = await utils.getOptions() + options[frontend] = customInstances + browser.storage.local.set({ options }, () => { + frontendCustomInstanceInput.value = "" + calcCustomInstances(frontend) + }) + } + } + }) } /** * @param {string} frontend */ async function createList(frontend) { - const pingCache = await utils.getPingCache() - const options = await utils.getOptions() - for (const network in config.networks) { - const checklist = document.getElementById(frontend).getElementsByClassName(network)[0].getElementsByClassName("checklist")[0] - - if (!redirects[frontend]) { - checklist.innerHTML = '
No instances found.
' - break - } - - const instances = redirects[frontend][network] - if (!instances || instances.length === 0) continue - - document.getElementById(frontend).getElementsByClassName("custom-instance")[0].placeholder = redirects[frontend].clearnet[0] - - instances.sort((a, b) => blacklist.cloudflare.includes(a) && !blacklist.cloudflare.includes(b)) - const content = instances - .map(x => { - const cloudflare = blacklist.cloudflare.includes(x) ? - ` + const pingCache = await utils.getPingCache() + const options = await utils.getOptions() + for (const network in config.networks) { + const checklist = document + .getElementById(frontend) + .getElementsByClassName(network)[0] + .getElementsByClassName("checklist")[0] + + if (!redirects[frontend]) { + checklist.innerHTML = '
No instances found.
' + break + } + + const instances = redirects[frontend][network] + if (!instances || instances.length === 0) continue + + document.getElementById(frontend).getElementsByClassName("custom-instance")[0].placeholder = + redirects[frontend].clearnet[0] + + instances.sort((a, b) => blacklist.cloudflare.includes(a) && !blacklist.cloudflare.includes(b)) + const content = instances.map(x => { + const cloudflare = blacklist.cloudflare.includes(x) + ? `
cloudflare - ` : "" + ` + : "" - let time = pingCache[x] - let timeText = "" - if (time) { - const { color, text } = processTime(time) - timeText = `${text}` - } + let time = pingCache[x] + let timeText = "" + if (time) { + const { color, text } = processTime(time) + timeText = `${text}` + } - const chosen = options[frontend].includes(x) ? `chosen` : "" + const chosen = options[frontend].includes(x) ? `chosen` : "" - const warnings = [cloudflare, timeText, chosen].join(" ") - return `
+ const warnings = [cloudflare, timeText, chosen].join(" ") + return `
${x} ${warnings} @@ -300,30 +310,29 @@ async function createList(frontend) {
` - }) + }) - checklist.innerHTML = [ - `
+ checklist.innerHTML = [ + `
`, - ...content, - "
" - ].join("\n
\n") - - for (const instance of instances) { - checklist.getElementsByClassName(`add-${instance}`)[0] - .addEventListener("click", async () => { - let options = await utils.getOptions() - if (!options[frontend].includes(instance)) { - options[frontend].push(instance) - browser.storage.local.set({ options }, () => { - calcCustomInstances(frontend) - createList(frontend) - }) - } - }) - } - } + ...content, + "
", + ].join("\n
\n") + + for (const instance of instances) { + checklist.getElementsByClassName(`add-${instance}`)[0].addEventListener("click", async () => { + let options = await utils.getOptions() + if (!options[frontend].includes(instance)) { + options[frontend].push(instance) + browser.storage.local.set({ options }, () => { + calcCustomInstances(frontend) + createList(frontend) + }) + } + }) + } + } } const r = window.location.href.match(/#(.*)/) @@ -334,59 +343,57 @@ else loadPage("general") * @param {string} frontend */ async function ping(frontend) { - const instanceElements = [ - ...document.getElementById(frontend).getElementsByClassName("custom-checklist")[0].getElementsByTagName('x'), - ...document.getElementById(frontend).getElementsByClassName('clearnet')[0].getElementsByTagName('x') - ] - - let pingCache = await utils.getPingCache() - let redundancyList = {} - for (const element of instanceElements) { - let span = element.getElementsByClassName('ping')[0] - if (!span) span = document.createElement('span') - span.classList = ['ping'] - span.innerHTML = 'pinging...' - element.appendChild(span) - const href = element.getElementsByTagName('a')[0].href - const innerHTML = element.getElementsByTagName('a')[0].innerHTML - const time = redundancyList[innerHTML] ?? await utils.ping(href) - const { color, text } = processTime(time) - span.innerHTML = `${text}` - pingCache[innerHTML] = time - redundancyList[innerHTML] = time - - browser.storage.local.set({ pingCache }) - } + const instanceElements = [ + ...document.getElementById(frontend).getElementsByClassName("custom-checklist")[0].getElementsByTagName("x"), + ...document.getElementById(frontend).getElementsByClassName("clearnet")[0].getElementsByTagName("x"), + ] + + let pingCache = await utils.getPingCache() + let redundancyList = {} + for (const element of instanceElements) { + let span = element.getElementsByClassName("ping")[0] + if (!span) span = document.createElement("span") + span.classList = ["ping"] + span.innerHTML = 'pinging...' + element.appendChild(span) + const href = element.getElementsByTagName("a")[0].href + const innerHTML = element.getElementsByTagName("a")[0].innerHTML + const time = redundancyList[innerHTML] ?? (await utils.ping(href)) + const { color, text } = processTime(time) + span.innerHTML = `${text}` + pingCache[innerHTML] = time + redundancyList[innerHTML] = time + + browser.storage.local.set({ pingCache }) + } } /** * @param {number} time */ function processTime(time) { - let text - let color - if (time < 5000) { - text = `${time}ms` - if (time <= 1000) color = "green" - else if (time <= 2000) color = "orange" - } - else if (time >= 5000) { - color = "red" - if (time == 5000) text = "5000ms+" - if (time > 5000) text = `Error: ${time - 5000}` - } - else { - color = "red" - text = 'Server not found' - } - return { color, text } + let text + let color + if (time < 5000) { + text = `${time}ms` + if (time <= 1000) color = "green" + else if (time <= 2000) color = "orange" + } else if (time >= 5000) { + color = "red" + if (time == 5000) text = "5000ms+" + if (time > 5000) text = `Error: ${time - 5000}` + } else { + color = "red" + text = "Server not found" + } + return { color, text } } function isCustomInstance(frontend, instance) { - for (const network in config.networks) { - if (!redirects[frontend]) return false; - const instances = redirects[frontend][network] - if (instances.includes(instance)) return true - } - return false -} \ No newline at end of file + for (const network in config.networks) { + if (!redirects[frontend]) return false + const instances = redirects[frontend][network] + if (instances.includes(instance)) return true + } + return false +} diff --git a/src/pages/options/init.js b/src/pages/options/init.js index baf3eebe..07da1859 100644 --- a/src/pages/options/init.js +++ b/src/pages/options/init.js @@ -5,46 +5,46 @@ import utils from "../../assets/javascripts/utils.js" import servicesHelper from "../../assets/javascripts/services.js" if (!(await utils.getOptions())) { - await servicesHelper.initDefaults() + await servicesHelper.initDefaults() } async function changeTheme() { - switch ((await utils.getOptions()).theme) { - case "dark": - document.body.classList.add("dark-theme") - document.body.classList.remove("light-theme") - for (const element of document.body.getElementsByClassName('dark')) { - element.style.display = 'none'; - } - break - case "light": - document.body.classList.add("light-theme") - document.body.classList.remove("dark-theme") - for (const element of document.body.getElementsByClassName('light')) { - element.style.display = 'none'; - } - break - default: - if (matchMedia("(prefers-color-scheme: light)").matches) { - document.body.classList.add("light-theme") - document.body.classList.remove("dark-theme") - for (const element of document.body.getElementsByClassName('light')) { - element.style.display = 'none'; - } - } else { - document.body.classList.add("dark-theme") - document.body.classList.remove("light-theme") - for (const element of document.body.getElementsByClassName('dark')) { - element.style.display = 'none'; - } - } - } + switch ((await utils.getOptions()).theme) { + case "dark": + document.body.classList.add("dark-theme") + document.body.classList.remove("light-theme") + for (const element of document.body.getElementsByClassName("dark")) { + element.style.display = "none" + } + break + case "light": + document.body.classList.add("light-theme") + document.body.classList.remove("dark-theme") + for (const element of document.body.getElementsByClassName("light")) { + element.style.display = "none" + } + break + default: + if (matchMedia("(prefers-color-scheme: light)").matches) { + document.body.classList.add("light-theme") + document.body.classList.remove("dark-theme") + for (const element of document.body.getElementsByClassName("light")) { + element.style.display = "none" + } + } else { + document.body.classList.add("dark-theme") + document.body.classList.remove("light-theme") + for (const element of document.body.getElementsByClassName("dark")) { + element.style.display = "none" + } + } + } } changeTheme() if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) { - document.getElementsByTagName("body")[0].classList.add("rtl") - document.getElementsByTagName("body")[0].dir = "rtl" + document.getElementsByTagName("body")[0].classList.add("rtl") + document.getElementsByTagName("body")[0].dir = "rtl" } localise.localisePage() diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 30a8a0c8..b9ddfd08 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -7,29 +7,29 @@ import servicesHelper from "../../../assets/javascripts/services.js" const isChrome = browser.runtime.getBrowserInfo === undefined async function setOption(option, type, event) { - let options = await utils.getOptions() - switch (type) { - case "select": - options[option] = event.target.options[event.target.options.selectedIndex].value - break; - case "checkbox": - options[option] = event.target.checked - break; - case "range": - options[option] = event.target.value - break; - } - browser.storage.local.set({ options }) + let options = await utils.getOptions() + switch (type) { + case "select": + options[option] = event.target.options[event.target.options.selectedIndex].value + break + case "checkbox": + options[option] = event.target.checked + break + case "range": + options[option] = event.target.value + break + } + browser.storage.local.set({ options }) } const exportSettingsElement = document.getElementById("export-settings") async function exportSettings() { - const options = await utils.getOptions() - options.version = browser.runtime.getManifest().version - let resultString = JSON.stringify(options, null, " ") - exportSettingsElement.href = "data:application/json;base64," + btoa(resultString) - exportSettingsElement.download = `libredirect-settings-v${options.version}.json` - return + const options = await utils.getOptions() + options.version = browser.runtime.getManifest().version + let resultString = JSON.stringify(options, null, " ") + exportSettingsElement.href = "data:application/json;base64," + btoa(resultString) + exportSettingsElement.download = `libredirect-settings-v${options.version}.json` + return } exportSettings() document.getElementById("general_page").onclick = exportSettings @@ -37,35 +37,32 @@ document.getElementById("general_page").onclick = exportSettings const importSettingsElement = document.getElementById("import-settings") const importSettingsElementText = document.getElementById("import_settings_text") importSettingsElement.addEventListener("change", () => { - function importError() { - const oldHTML = importSettingsElementText.innerHTML - importSettingsElementText.innerHTML = 'Error!' - setTimeout(() => (importSettingsElementText.innerHTML = oldHTML), 1000) - } - importSettingsElementText.innerHTML = "..." - let file = importSettingsElement.files[0] - const reader = new FileReader() - reader.readAsText(file) - reader.onload = async () => { - const data = JSON.parse(reader.result) - if ( - "theme" in data - && data.version == browser.runtime.getManifest().version - ) { - browser.storage.local.clear(async () => { - browser.storage.local.set({ options: data }, () => { - location.reload() - }) - }) - } else { - console.log("incompatible settings") - importError() - } - } - reader.onerror = error => { - console.log("error", error) - importError() - } + function importError() { + const oldHTML = importSettingsElementText.innerHTML + importSettingsElementText.innerHTML = 'Error!' + setTimeout(() => (importSettingsElementText.innerHTML = oldHTML), 1000) + } + importSettingsElementText.innerHTML = "..." + let file = importSettingsElement.files[0] + const reader = new FileReader() + reader.readAsText(file) + reader.onload = async () => { + const data = JSON.parse(reader.result) + if ("theme" in data && data.version == browser.runtime.getManifest().version) { + browser.storage.local.clear(async () => { + browser.storage.local.set({ options: data }, () => { + location.reload() + }) + }) + } else { + console.log("incompatible settings") + importError() + } + } + reader.onerror = error => { + console.log("error", error) + importError() + } }) const exportSettingsSync = document.getElementById("export-settings-sync") @@ -73,58 +70,57 @@ const importSettingsSync = document.getElementById("import-settings-sync") const importSettingsSyncText = document.getElementById("import_settings_sync_text") exportSettingsSync.addEventListener("click", async () => { - let options = await utils.getOptions() - options.version = browser.runtime.getManifest().version - browser.storage.sync.set({ options }, () => location.reload()) + let options = await utils.getOptions() + options.version = browser.runtime.getManifest().version + browser.storage.sync.set({ options }, () => location.reload()) }) importSettingsSync.addEventListener("click", () => { - function importError() { - importSettingsSyncText.innerHTML = 'Error!' - setTimeout(() => (importSettingsSyncText.innerHTML = oldHTML), 1000) - } - const oldHTML = importSettingsSyncText.innerHTML - importSettingsSyncText.innerHTML = "..." - browser.storage.sync.get({ options }, r => { - const options = r.options - if (options.version == browser.runtime.getManifest().version) { - browser.storage.local.set({ options }, () => location.reload()) - } else { - importError() - } - }) + function importError() { + importSettingsSyncText.innerHTML = 'Error!' + setTimeout(() => (importSettingsSyncText.innerHTML = oldHTML), 1000) + } + const oldHTML = importSettingsSyncText.innerHTML + importSettingsSyncText.innerHTML = "..." + browser.storage.sync.get({ options }, r => { + const options = r.options + if (options.version == browser.runtime.getManifest().version) { + browser.storage.local.set({ options }, () => location.reload()) + } else { + importError() + } + }) }) const resetSettings = document.getElementById("reset-settings") resetSettings.addEventListener("click", async () => { - resetSettings.innerHTML = "..." - await servicesHelper.initDefaults() - location.reload() + resetSettings.innerHTML = "..." + await servicesHelper.initDefaults() + location.reload() }) -const fetchInstancesElement = document.getElementById('fetch-instances') -fetchInstancesElement.addEventListener('change', event => { - setOption('fetchInstances', 'select', event) - location.reload() +const fetchInstancesElement = document.getElementById("fetch-instances") +fetchInstancesElement.addEventListener("change", event => { + setOption("fetchInstances", "select", event) + location.reload() }) -const redirectOnlyInIncognitoElement = document.getElementById('redirectOnlyInIncognito') -redirectOnlyInIncognitoElement.addEventListener('change', event => { - setOption('redirectOnlyInIncognito', 'checkbox', event) +const redirectOnlyInIncognitoElement = document.getElementById("redirectOnlyInIncognito") +redirectOnlyInIncognitoElement.addEventListener("change", event => { + setOption("redirectOnlyInIncognito", "checkbox", event) }) -const bookmarksMenuElement = document.getElementById('bookmarksMenu') -bookmarksMenuElement.addEventListener('change', async event => { - if (event.target.checked) - browser.permissions.request({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = r) - else - browser.permissions.remove({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = !r) +const bookmarksMenuElement = document.getElementById("bookmarksMenu") +bookmarksMenuElement.addEventListener("change", async event => { + if (event.target.checked) + browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksMenuElement.checked = r)) + else browser.permissions.remove({ permissions: ["bookmarks"] }, r => (bookmarksMenuElement.checked = !r)) }) let themeElement = document.getElementById("theme") themeElement.addEventListener("change", event => { - setOption("theme", "select", event) - location.reload() + setOption("theme", "select", event) + location.reload() }) let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance") @@ -134,40 +130,44 @@ let instanceType = "url" let config = await utils.getConfig() for (const service in config.services) { - document.getElementById(service).addEventListener("change", async event => { - let options = await utils.getOptions() - if (event.target.checked && !options.popupServices.includes(service)) options.popupServices.push(service) - else if (options.popupServices.includes(service)) { - var index = options.popupServices.indexOf(service) - if (index !== -1) options.popupServices.splice(index, 1) - } - browser.storage.local.set({ options }) - }) + document.getElementById(service).addEventListener("change", async event => { + let options = await utils.getOptions() + if (event.target.checked && !options.popupServices.includes(service)) options.popupServices.push(service) + else if (options.popupServices.includes(service)) { + var index = options.popupServices.indexOf(service) + if (index !== -1) options.popupServices.splice(index, 1) + } + browser.storage.local.set({ options }) + }) } let options = await utils.getOptions() themeElement.value = options.theme fetchInstancesElement.value = options.fetchInstances redirectOnlyInIncognitoElement.checked = options.redirectOnlyInIncognito -browser.permissions.contains({ permissions: ["bookmarks"] }, r => bookmarksMenuElement.checked = r) -for (const service in config.services) document.getElementById(service).checked = options.popupServices.includes(service) +browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksMenuElement.checked = r)) +for (const service in config.services) + document.getElementById(service).checked = options.popupServices.includes(service) instanceTypeElement.addEventListener("change", event => { - instanceType = event.target.options[instanceTypeElement.selectedIndex].value - if (instanceType == "url") { - nameCustomInstanceInput.setAttribute("type", "url") - nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com") - } else if (instanceType == "regex") { - nameCustomInstanceInput.setAttribute("type", "text") - nameCustomInstanceInput.setAttribute("placeholder", "https?://(www.|)youtube.com/") - } + instanceType = event.target.options[instanceTypeElement.selectedIndex].value + if (instanceType == "url") { + nameCustomInstanceInput.setAttribute("type", "url") + nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com") + } else if (instanceType == "regex") { + nameCustomInstanceInput.setAttribute("type", "text") + nameCustomInstanceInput.setAttribute("placeholder", "https?://(www.|)youtube.com/") + } }) let exceptionsCustomInstances = options.exceptions function calcExceptionsCustomInstances() { - document.getElementById("exceptions-custom-checklist").innerHTML = [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex] - .map( - x => `
+ document.getElementById("exceptions-custom-checklist").innerHTML = [ + ...exceptionsCustomInstances.url, + ...exceptionsCustomInstances.regex, + ] + .map( + x => `
${x}

` - ) - .join("\n") - - for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) { - document.getElementById(`clear-${x}`).addEventListener("click", async () => { - let index - index = exceptionsCustomInstances.url.indexOf(x) - if (index > -1) exceptionsCustomInstances.url.splice(index, 1) - else { - index = exceptionsCustomInstances.regex.indexOf(x) - if (index > -1) exceptionsCustomInstances.regex.splice(index, 1) - } - options = await utils.getOptions() - options.exceptions = exceptionsCustomInstances - browser.storage.local.set({ options }) - calcExceptionsCustomInstances() - }) - } + ) + .join("\n") + + for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) { + document.getElementById(`clear-${x}`).addEventListener("click", async () => { + let index + index = exceptionsCustomInstances.url.indexOf(x) + if (index > -1) exceptionsCustomInstances.url.splice(index, 1) + else { + index = exceptionsCustomInstances.regex.indexOf(x) + if (index > -1) exceptionsCustomInstances.regex.splice(index, 1) + } + options = await utils.getOptions() + options.exceptions = exceptionsCustomInstances + browser.storage.local.set({ options }) + calcExceptionsCustomInstances() + }) + } } calcExceptionsCustomInstances() document.getElementById("custom-exceptions-instance-form").addEventListener("submit", async event => { - event.preventDefault() - let val - if (instanceType == "url" && nameCustomInstanceInput.validity.valid) { - val = nameCustomInstanceInput.value - if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val) - } else if (instanceType == "regex") { - val = nameCustomInstanceInput.value - if (val.trim() != "" && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val) - } - if (val) { - options = await utils.getOptions() - options.exceptions = exceptionsCustomInstances - browser.storage.local.set({ options }, () => nameCustomInstanceInput.value = "") - } - calcExceptionsCustomInstances() + event.preventDefault() + let val + if (instanceType == "url" && nameCustomInstanceInput.validity.valid) { + val = nameCustomInstanceInput.value + if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val) + } else if (instanceType == "regex") { + val = nameCustomInstanceInput.value + if (val.trim() != "" && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val) + } + if (val) { + options = await utils.getOptions() + options.exceptions = exceptionsCustomInstances + browser.storage.local.set({ options }, () => (nameCustomInstanceInput.value = "")) + } + calcExceptionsCustomInstances() }) diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 485ec0e0..77a43000 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -5,15 +5,15 @@ import servicesHelper from "../../assets/javascripts/services.js" import utils from "../../assets/javascripts/utils.js" document.getElementById("more-options").href = browser.runtime.getURL("pages/options/index.html") -document.getElementById("more-options").setAttribute('target', '_blank') +document.getElementById("more-options").setAttribute("target", "_blank") await browser.runtime.getPlatformInfo(r => { - switch (r.os) { - case "fuchsia": - case "ios": - case "android": - document.getElementsByTagName("html")[0].classList.add("mobile") - } + switch (r.os) { + case "fuchsia": + case "ios": + case "android": + document.getElementsByTagName("html")[0].classList.add("mobile") + } }) const allSites = document.getElementById("all_sites") @@ -24,94 +24,96 @@ const config = await utils.getConfig() const divs = {} for (const service in config.services) { - divs[service] = {} - - divs[service].all = allSites.getElementsByClassName(service)[0] - divs[service].current = currSite.getElementsByClassName(service)[0] - - divs[service].all_toggle = allSites.getElementsByClassName(`${service}-enabled`)[0] - divs[service].all_toggle.addEventListener("change", async () => { - const options = await utils.getOptions() - options[service].enabled = divs[service].all_toggle.checked - browser.storage.local.set({ options }) - }) - - allSites.getElementsByClassName(`${service}-change_instance`)[0].addEventListener("click", () => { - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - browser.tabs.update({ url: await servicesHelper.switchInstance(url, service) }) - } - }) - }) - - divs[service].current_toggle = currSite.getElementsByClassName(`${service}-enabled`)[0] - divs[service].current_toggle.addEventListener("change", async () => { - const options = await utils.getOptions() - options[service].enabled = divs[service].current_toggle.checked - browser.storage.local.set({ options }) - }) - - currSite.getElementsByClassName(`${service}-change_instance`)[0].addEventListener("click", () => { - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - browser.tabs.update({ url: await servicesHelper.switchInstance(url, service) }) - } - }) - }) + divs[service] = {} + + divs[service].all = allSites.getElementsByClassName(service)[0] + divs[service].current = currSite.getElementsByClassName(service)[0] + + divs[service].all_toggle = allSites.getElementsByClassName(`${service}-enabled`)[0] + divs[service].all_toggle.addEventListener("change", async () => { + const options = await utils.getOptions() + options[service].enabled = divs[service].all_toggle.checked + browser.storage.local.set({ options }) + }) + + allSites.getElementsByClassName(`${service}-change_instance`)[0].addEventListener("click", () => { + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + if (tabs[0].url) { + const url = new URL(tabs[0].url) + browser.tabs.update({ url: await servicesHelper.switchInstance(url, service) }) + } + }) + }) + + divs[service].current_toggle = currSite.getElementsByClassName(`${service}-enabled`)[0] + divs[service].current_toggle.addEventListener("change", async () => { + const options = await utils.getOptions() + options[service].enabled = divs[service].current_toggle.checked + browser.storage.local.set({ options }) + }) + + currSite.getElementsByClassName(`${service}-change_instance`)[0].addEventListener("click", () => { + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + if (tabs[0].url) { + const url = new URL(tabs[0].url) + browser.tabs.update({ url: await servicesHelper.switchInstance(url, service) }) + } + }) + }) } browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - // Set visibility of control buttons - if (tabs[0].url) { - const hr = document.getElementById("hr") - var url = new URL(tabs[0].url) - servicesHelper.switchInstance(url).then(r => { - if (r) { - document.getElementById("change_instance_div").style.display = "" - hr.style.display = "" - document.getElementById("change_instance").addEventListener("click", async () => - browser.tabs.update({ url: await servicesHelper.switchInstance(url) }) - ) - } - }) - servicesHelper.reverse(url).then(r => { - if (r) { - hr.style.display = "" - - document.getElementById("copy_original_div").style.display = "" - document.getElementById("copy_original").addEventListener("click", () => servicesHelper.copyRaw(url)) - - document.getElementById("redirect_to_original_div").style.display = "" - document.getElementById("redirect_to_original").addEventListener("click", () => browser.runtime.sendMessage("reverseTab")) - } - }) - servicesHelper.redirectAsync(url, "main_frame", null, true).then(r => { - if (r) { - document.getElementById("redirect_div").style.display = "" - hr.style.display = "" - document.getElementById("redirect").addEventListener("click", () => browser.runtime.sendMessage("redirectTab")) - } - }) - } - - const options = await utils.getOptions() - - // Set visibility of all service buttons - for (const service of options.popupServices) { - divs[service].all.classList.remove("hide") - divs[service].all_toggle.checked = options[service].enabled - } - - // Set visibility of current page service button - if (url) { - const service = await servicesHelper.computeService(url) - if (service) { - divs[service].all.classList.add("hide") - divs[service].current.classList.remove("hide") - divs[service].current_toggle.checked = options[service].enabled - currentSiteDivider.style.display = "" - } - } -}) \ No newline at end of file + // Set visibility of control buttons + if (tabs[0].url) { + const hr = document.getElementById("hr") + var url = new URL(tabs[0].url) + servicesHelper.switchInstance(url).then(r => { + if (r) { + document.getElementById("change_instance_div").style.display = "" + hr.style.display = "" + document + .getElementById("change_instance") + .addEventListener("click", async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) })) + } + }) + servicesHelper.reverse(url).then(r => { + if (r) { + hr.style.display = "" + + document.getElementById("copy_original_div").style.display = "" + document.getElementById("copy_original").addEventListener("click", () => servicesHelper.copyRaw(url)) + + document.getElementById("redirect_to_original_div").style.display = "" + document + .getElementById("redirect_to_original") + .addEventListener("click", () => browser.runtime.sendMessage("reverseTab")) + } + }) + servicesHelper.redirectAsync(url, "main_frame", null, true).then(r => { + if (r) { + document.getElementById("redirect_div").style.display = "" + hr.style.display = "" + document.getElementById("redirect").addEventListener("click", () => browser.runtime.sendMessage("redirectTab")) + } + }) + } + + const options = await utils.getOptions() + + // Set visibility of all service buttons + for (const service of options.popupServices) { + divs[service].all.classList.remove("hide") + divs[service].all_toggle.checked = options[service].enabled + } + + // Set visibility of current page service button + if (url) { + const service = await servicesHelper.computeService(url) + if (service) { + divs[service].all.classList.add("hide") + divs[service].current.classList.remove("hide") + divs[service].current_toggle.checked = options[service].enabled + currentSiteDivider.style.display = "" + } + } +}) diff --git a/src/pages/popup/style.css b/src/pages/popup/style.css index 5e39b4ed..41510615 100644 --- a/src/pages/popup/style.css +++ b/src/pages/popup/style.css @@ -1,65 +1,65 @@ body { - width: 270px; - min-height: auto; + width: 270px; + min-height: auto; } html, body { - margin: 0; + margin: 0; } .hide { - display: none !important; + display: none !important; } .button { - display: flex; - margin: 0 auto; - justify-content: space-between; + display: flex; + margin: 0 auto; + justify-content: space-between; } .button svg { - width: 26px; - height: 26px; + width: 26px; + height: 26px; } .bottom-button { - width: 100%; + width: 100%; } .space { - height: 10px; + height: 10px; } input { - height: 23px; - width: 46px; + height: 23px; + width: 46px; } div.block label { - margin: 0; - font-size: 18px; - font-weight: bold; - max-width: 180px; + margin: 0; + font-size: 18px; + font-weight: bold; + max-width: 180px; } div.block label:hover { - cursor: pointer; + cursor: pointer; } div.block div { - display: flex; + display: flex; } html.mobile body { - width: 100%; + width: 100%; } html.mobile div.block label { - font-size: 24px; + font-size: 24px; } html.mobile .button svg { - width: 30px; - height: 30px; -} \ No newline at end of file + width: 30px; + height: 30px; +} diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index b220efdb..ca6f0dca 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -1,450 +1,449 @@ body { - --text: #fff; - --bg-main: #121212; - --bg-secondary: #202020; - --active: #fbc117; - --danger: #f04141; - --light-grey: #c3c3c3; + --text: #fff; + --bg-main: #121212; + --bg-secondary: #202020; + --active: #fbc117; + --danger: #f04141; + --light-grey: #c3c3c3; } @font-face { - font-family: "Inter"; - src: url("Inter-VariableFont_slnt,wght.ttf"); - font-weight: normal; - font-style: normal; + font-family: "Inter"; + src: url("Inter-VariableFont_slnt,wght.ttf"); + font-weight: normal; + font-style: normal; } @font-face { - font-family: "Vazirmatn"; - src: url("Vazirmatn-VariableFont_wght.ttf"); - font-weight: normal; - font-style: normal; + font-family: "Vazirmatn"; + src: url("Vazirmatn-VariableFont_wght.ttf"); + font-weight: normal; + font-style: normal; } body { - margin: auto; - padding: 0; - font-family: "Inter"; - font-size: 16px; - background-color: var(--bg-main); - color: var(--text); + margin: auto; + padding: 0; + font-family: "Inter"; + font-size: 16px; + background-color: var(--bg-main); + color: var(--text); } body * { - font-family: "Inter"; + font-family: "Inter"; } body.rtl { - font-family: "Vazirmatn"; + font-family: "Vazirmatn"; } body.rtl * { - font-family: "Vazirmatn"; + font-family: "Vazirmatn"; } div.block input[type="checkbox"] { - appearance: none; - -moz-appearance: none; - -webkit-appearance: none; + appearance: none; + -moz-appearance: none; + -webkit-appearance: none; } .title { - display: flex; - align-items: center; - text-decoration: none; - width: min-content; - color: var(--text); - transition: .1s; + display: flex; + align-items: center; + text-decoration: none; + width: min-content; + color: var(--text); + transition: 0.1s; } .title:hover { - opacity: 1 !important; + opacity: 1 !important; } .title:hover a { - color: var(--active); + color: var(--active); } img, svg { - margin-right: 10px; - height: 26px; - width: 26px; - color: var(--text); + margin-right: 10px; + height: 26px; + width: 26px; + color: var(--text); } body.rtl img, body.rtl svg { - margin-right: 0px; - margin-left: 10px; + margin-right: 0px; + margin-left: 10px; } input[type="url"], input[type="text"], select { - font-weight: bold; - box-sizing: border-box; - border-style: solid; - border-color: #767676; - color: var(--text); - font-size: 16px; - padding: 8px; - background-color: var(--bg-secondary); - border: none; - margin: 0; - max-width: 500px; - border-radius: 3px; + font-weight: bold; + box-sizing: border-box; + border-style: solid; + border-color: #767676; + color: var(--text); + font-size: 16px; + padding: 8px; + background-color: var(--bg-secondary); + border: none; + margin: 0; + max-width: 500px; + border-radius: 3px; } input[type="url"], input[type="text"] { - width: 400px; - cursor: text; + width: 400px; + cursor: text; } input:invalid { - color: var(--danger); + color: var(--danger); } .button svg { - height: 18px; - width: 18px; + height: 18px; + width: 18px; } section.block-option { - width: 750px; - margin: 0 50px; + width: 750px; + margin: 0 50px; } section.block-option h2 { - margin: 0; + margin: 0; } body.option { - display: flex; - padding: 40px; - width: 1160px; + display: flex; + padding: 40px; + width: 1160px; } section.links { - display: flex; - flex-wrap: wrap; - flex-direction: column; - width: 350px; - max-height: 1030px; + display: flex; + flex-wrap: wrap; + flex-direction: column; + width: 350px; + max-height: 1030px; } section.links div { - margin: 10px; - width: max-content; + margin: 10px; + width: max-content; } a { - text-decoration: none; - color: var(--text); - transition: 0.1s; + text-decoration: none; + color: var(--text); + transition: 0.1s; } a:hover { - color: var(--active); + color: var(--active); } section.links a { - display: flex; - align-items: center; - font-size: 18px; - text-decoration: none; - color: white; - transition: 0.1s; + display: flex; + align-items: center; + font-size: 18px; + text-decoration: none; + color: white; + transition: 0.1s; } section.links a:hover, section.links .selected { - opacity: 1 !important; + opacity: 1 !important; } section.links .selected a { - color: var(--active); + color: var(--active); } ::placeholder { - color: var(--text); - opacity: 0.7; + color: var(--text); + opacity: 0.7; } hr { - height: 2px; - margin: 0 15px; - background-color: rgb(77, 77, 77); - border: none; + height: 2px; + margin: 0 15px; + background-color: rgb(77, 77, 77); + border: none; } div.block { - padding: 0 15px; - justify-content: space-between; - display: flex; - align-items: center; - margin-top: 10px; - margin-bottom: 10px; + padding: 0 15px; + justify-content: space-between; + display: flex; + align-items: center; + margin-top: 10px; + margin-bottom: 10px; } div.block-option { - margin: 30px 0; + margin: 30px 0; } div.block-option label { - margin-right: 5px; - width: 80%; - min-width: 150px; - font-size: 18px; + margin-right: 5px; + width: 80%; + min-width: 150px; + font-size: 18px; } div.block-option h1 { - margin: 0; - font-size: 28px; - color: var(--text); + margin: 0; + font-size: 28px; + color: var(--text); } div.block-option div { - text-align: center; + text-align: center; } div.block input[type="checkbox"] { - width: 46px; - height: 24px; - background-color: var(--light-grey); - border-radius: 50px; - transition: 0.4s; - cursor: pointer; + width: 46px; + height: 24px; + background-color: var(--light-grey); + border-radius: 50px; + transition: 0.4s; + cursor: pointer; } div.block input[type="checkbox"]:checked { - background-color: var(--active); + background-color: var(--active); } div.block input[type="checkbox"]::before { - content: ""; - display: inline-block; - width: 18px; - height: 18px; - box-sizing: border-box; - position: relative; - top: 2.5px; - left: 3.5px; - background-color: white; - border-radius: 50%; - transition: 0.3s; + content: ""; + display: inline-block; + width: 18px; + height: 18px; + box-sizing: border-box; + position: relative; + top: 2.5px; + left: 3.5px; + background-color: white; + border-radius: 50%; + transition: 0.3s; } body.rtl div.block input[type="checkbox"]::before { - left: auto; - right: 4px; + left: auto; + right: 4px; } div.block input[type="checkbox"]:checked::before { - left: 24px; + left: 24px; } body.rtl div.block input[type="checkbox"]:checked::before { - left: auto; - right: 24px; + left: auto; + right: 24px; } div.buttons { - display: flex; - margin: 0 15px; - margin-bottom: 15px; - margin-top: 15px; - flex-wrap: wrap; - align-items: center; - justify-content: start; + display: flex; + margin: 0 15px; + margin-bottom: 15px; + margin-top: 15px; + flex-wrap: wrap; + align-items: center; + justify-content: start; } .button { - color: var(--text); - font-size: 16px; - font-weight: bold; - text-decoration: none; - cursor: pointer; - transition-duration: 0.1s; + color: var(--text); + font-size: 16px; + font-weight: bold; + text-decoration: none; + cursor: pointer; + transition-duration: 0.1s; } .button:hover { - color: var(--active); + color: var(--active); } .button svg { - width: auto; - height: auto; - padding: 0; - margin-right: 5px; + width: auto; + height: auto; + padding: 0; + margin-right: 5px; } .button:hover svg { - color: var(--active); + color: var(--active); } .button-inline { - display: inline-flex; - align-items: center; - margin: 7.5px 0; - background-color: var(--bg-secondary); - border-radius: 5px; - padding: 10px; + display: inline-flex; + align-items: center; + margin: 7.5px 0; + background-color: var(--bg-secondary); + border-radius: 5px; + padding: 10px; } .button:active { - transform: translateY(1px); + transform: translateY(1px); } button svg { - color: var(--text); + color: var(--text); } div.checklist div { - justify-content: space-between; - margin: 5px 15px; - padding: 10px 0; - word-wrap: break-word; - display: flex; + justify-content: space-between; + margin: 5px 15px; + padding: 10px 0; + word-wrap: break-word; + display: flex; } div.checklist a { - text-decoration: none; - color: var(--text); + text-decoration: none; + color: var(--text); } div.checklist a:hover { - text-decoration: underline; + text-decoration: underline; } div.custom-checklist x a { - color: var(--active); + color: var(--active); } button.add { - background-color: transparent; - border: none; - padding: 0; - margin: 0; - text-decoration: none; - display: inline-block; - cursor: pointer; + background-color: transparent; + border: none; + padding: 0; + margin: 0; + text-decoration: none; + display: inline-block; + cursor: pointer; } body.light-theme { - --text: black; - --bg-main: white; - --bg-secondary: #e4e4e4; - --active: #fb9817; + --text: black; + --bg-main: white; + --bg-secondary: #e4e4e4; + --active: #fb9817; } body.light-theme select { - border: 1px solid black; + border: 1px solid black; } body.light-theme a { - color: black; + color: black; } body.light-theme a:hover { - color: var(--active) + color: var(--active); } button { - background-color: transparent; - color: var(--text); - border: none; - text-decoration: none; - display: inline-block; - cursor: pointer; - border-radius: 5px; + background-color: transparent; + color: var(--text); + border: none; + text-decoration: none; + display: inline-block; + cursor: pointer; + border-radius: 5px; } body div section { - display: none; + display: none; } select:disabled { - opacity: 0.6; - cursor: not-allowed; + opacity: 0.6; + cursor: not-allowed; } input:disabled { - opacity: 0.6; - cursor: not-allowed; + opacity: 0.6; + cursor: not-allowed; } @media (max-width: 1250px) { - body.option { - flex-direction: column; - width: 95vw; - align-items: center; - padding: 40px 0px; - } + body.option { + flex-direction: column; + width: 95vw; + align-items: center; + padding: 40px 0px; + } - section.links { - flex-direction: row; - width: 95vw; - padding: 0 55px; - } + section.links { + flex-direction: row; + width: 95vw; + padding: 0 55px; + } - section.block-option { - width: 95vw; - } + section.block-option { + width: 95vw; + } - div.checklist div x { - overflow: hidden; - } + div.checklist div x { + overflow: hidden; + } } html.mobile img, html.mobile svg { - margin-right: 10px; - height: 30px; - width: 30px; - color: var(--text); + margin-right: 10px; + height: 30px; + width: 30px; + color: var(--text); } html.mobile div.block { - padding: 0 15px; - justify-content: space-between; - display: flex; - align-items: center; - margin-top: 20px; - margin-bottom: 20px; + padding: 0 15px; + justify-content: space-between; + display: flex; + align-items: center; + margin-top: 20px; + margin-bottom: 20px; } html.mobile div.block input[type="checkbox"] { - width: 58px; - height: 30px; + width: 58px; + height: 30px; } html.mobile div.block input[type="checkbox"]::before { - width: 24px; - height: 24px; - top: 3px; - left: 3.5px; + width: 24px; + height: 24px; + top: 3px; + left: 3.5px; } html.mobile div.block input[type="checkbox"]:checked::before { - left: 30px; + left: 30px; } html.mobile body.option { - flex-direction: column; - width: 100%; - padding: 0; - align-items: center; + flex-direction: column; + width: 100%; + padding: 0; + align-items: center; } - html.mobile section.links { - flex-direction: row; - width: 100%; - padding: 0 55px; + flex-direction: row; + width: 100%; + padding: 0 55px; } html.mobile section.block-option { - width: 100%; -} \ No newline at end of file + width: 100%; +} diff --git a/test-conditions.md b/test-conditions.md index 843b263e..7909a1a2 100644 --- a/test-conditions.md +++ b/test-conditions.md @@ -16,11 +16,11 @@ YouTube Music (Tested with YouTube turned off) Homepage - [https://music.youtube.com](https://music.youtube.com) Page - [https://hyperpipe.surge.sh/channel/UCPC0L1d253x-KuMNwa05TpA](https://hyperpipe.surge.sh/channel/UCPC0L1d253x-KuMNwa05TpA) Explore - [https://hyperpipe.surge.sh/explore/](https://hyperpipe.surge.sh/explore/) - + YT Embeds - [https://famiboards.com/threads/nintendo-switch-sports-announced-launches-april-29th-update-main-theme-in-threadmarks.1907/](https://famiboards.com/threads/nintendo-switch-sports-announced-launches-april-29th-update-main-theme-in-threadmarks.1907/) Twitch -[https://www.twitch.tv/pokimane](https://www.twitch.tv/pokimane) - + TikTok - [https://www.tiktok.com/@zoecolletti?lang=en](https://www.tiktok.com/@zoecolletti?lang=en) Reddit & Imgur `(Embeds)` - [https://www.reddit.com/61ns2w/](https://www.reddit.com/61ns2w/) @@ -32,22 +32,22 @@ Quora - [https://www.quora.com/What-is-the-equivalent-weight-of-hydrocloric-acid Pinterest - [https://www.pinterest.com/aldiukstores/aldi-recipes/](https://www.pinterest.com/aldiukstores/aldi-recipes/) IMDb - [https://www.imdb.com/title/tt23556786/](https://www.imdb.com/title/tt23556786/) **[Check if new URL schemes are supported by the Dev.]** - + Fandom - [https://naruto.fandom.com](https://naruto.fandom.com) - + Genius - [https://genius.com/Doja-cat-demons-lyrics](https://genius.com/Doja-cat-demons-lyrics) - + Urbandictionary - [https://urbandictionary.com/define.php?term=Roads](https://urbandictionary.com/define.php?term=Roads) - + Stackoverflow - [https://stackoverflow.com/questions/16330404/how-to-remove-remote-origin-from-a-git-repository](https://stackoverflow.com/questions/16330404/how-to-remove-remote-origin-from-a-git-repository) - + Goodreads - [https://www.goodreads.com/book/show/3869.A_Brief_History_of_Time](https://www.goodreads.com/book/show/3869.A_Brief_History_of_Time) - + Bandcamp - [https://thorwegian.bandcamp.com/track/just-because](https://thorwegian.bandcamp.com/track/just-because) - + Instructables - [https://instructables.com/DIY-Arduino-Obstacle-Avoiding-Car-at-Home/](https://instructables.com/DIY-Arduino-Obstacle-Avoiding-Car-at-Home/) - -Web archive - [https://web.archive.org/web/20230131222432if_/https://www.dailymail.co.uk/news/article-11687675/Army-spied-lockdown-critics-Sceptics-including-Peter-Hitchens-suspected-watched.html](https://web.archive.org/web/20230131222432if_/https://www.dailymail.co.uk/news/article-11687675/Army-spied-lockdown-critics-Sceptics-including-Peter-Hitchens-suspected-watched.html) + +Web archive - [https://web.archive.org/web/20230131222432if\_/https://www.dailymail.co.uk/news/article-11687675/Army-spied-lockdown-critics-Sceptics-including-Peter-Hitchens-suspected-watched.html](https://web.archive.org/web/20230131222432if_/https://www.dailymail.co.uk/news/article-11687675/Army-spied-lockdown-critics-Sceptics-including-Peter-Hitchens-suspected-watched.html) --- -- cgit 1.4.1 From 5be3c07ebf228b5595d872a7733371fe59675443 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 24 Jul 2024 12:20:49 +0300 Subject: Migrating UI to Svelte --- .gitignore | 1 + package.json | 13 +- rollup.config.js | 35 +++ src/pages/options/index.js | 399 --------------------------- src/pages/options/index.pug | 10 - src/pages/options/widgets/general.js | 216 --------------- src/pages/options/widgets/general.pug | 88 ------ src/pages/options/widgets/services.pug | 83 ------ src/pages/src/App.svelte | 118 ++++++++ src/pages/src/General/Exceptions.svelte | 108 ++++++++ src/pages/src/General/General.svelte | 70 +++++ src/pages/src/General/SettingsButtons.svelte | 118 ++++++++ src/pages/src/Services/Instances.svelte | 234 ++++++++++++++++ src/pages/src/Services/RedirectType.svelte | 84 ++++++ src/pages/src/Services/Services.svelte | 119 ++++++++ src/pages/src/Sidebar.svelte | 43 +++ src/pages/src/components/Button.svelte | 29 ++ src/pages/src/components/Checkbox.svelte | 52 ++++ src/pages/src/components/Input.svelte | 41 +++ src/pages/src/components/Label.svelte | 18 ++ src/pages/src/components/Row.svelte | 12 + src/pages/src/components/RowCheckbox.svelte | 14 + src/pages/src/components/RowSelect.svelte | 19 ++ src/pages/src/components/Select.svelte | 34 +++ src/pages/src/icons/AboutIcon.svelte | 11 + src/pages/src/icons/AddIcon.svelte | 3 + src/pages/src/icons/CloseIcon.svelte | 3 + src/pages/src/icons/ExportIcon.svelte | 5 + src/pages/src/icons/GeneralIcon.svelte | 13 + src/pages/src/icons/ImportIcon.svelte | 5 + src/pages/src/icons/PingIcon.svelte | 5 + src/pages/src/icons/ResetIcon.svelte | 15 + src/pages/src/icons/ServicesIcon.svelte | 11 + src/pages/src/main.js | 7 + src/pages/src/stores.js | 5 + src/pages/widgets/head.pug | 7 - src/pages/widgets/links.pug | 22 -- 37 files changed, 1243 insertions(+), 827 deletions(-) create mode 100644 rollup.config.js delete mode 100644 src/pages/options/index.js delete mode 100644 src/pages/options/index.pug delete mode 100644 src/pages/options/widgets/general.js delete mode 100644 src/pages/options/widgets/general.pug delete mode 100644 src/pages/options/widgets/services.pug create mode 100644 src/pages/src/App.svelte create mode 100644 src/pages/src/General/Exceptions.svelte create mode 100644 src/pages/src/General/General.svelte create mode 100644 src/pages/src/General/SettingsButtons.svelte create mode 100644 src/pages/src/Services/Instances.svelte create mode 100644 src/pages/src/Services/RedirectType.svelte create mode 100644 src/pages/src/Services/Services.svelte create mode 100644 src/pages/src/Sidebar.svelte create mode 100644 src/pages/src/components/Button.svelte create mode 100644 src/pages/src/components/Checkbox.svelte create mode 100644 src/pages/src/components/Input.svelte create mode 100644 src/pages/src/components/Label.svelte create mode 100644 src/pages/src/components/Row.svelte create mode 100644 src/pages/src/components/RowCheckbox.svelte create mode 100644 src/pages/src/components/RowSelect.svelte create mode 100644 src/pages/src/components/Select.svelte create mode 100644 src/pages/src/icons/AboutIcon.svelte create mode 100644 src/pages/src/icons/AddIcon.svelte create mode 100644 src/pages/src/icons/CloseIcon.svelte create mode 100644 src/pages/src/icons/ExportIcon.svelte create mode 100644 src/pages/src/icons/GeneralIcon.svelte create mode 100644 src/pages/src/icons/ImportIcon.svelte create mode 100644 src/pages/src/icons/PingIcon.svelte create mode 100644 src/pages/src/icons/ResetIcon.svelte create mode 100644 src/pages/src/icons/ServicesIcon.svelte create mode 100644 src/pages/src/main.js create mode 100644 src/pages/src/stores.js delete mode 100644 src/pages/widgets/head.pug delete mode 100644 src/pages/widgets/links.pug (limited to 'src/pages') diff --git a/.gitignore b/.gitignore index b1b53216..7ca34ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ package-lock.json src/pages/options/index.html src/pages/popup/popup.html pnpm-lock.yaml +src/pages/options/build \ No newline at end of file diff --git a/package.json b/package.json index dba432a5..234dd5e1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "libredirect", + "type": "module", "description": "Redirects YouTube, Twitter, TikTok and more to privacy friendly frontends.", "engines": { "node": ">=16.13.1", @@ -11,7 +12,7 @@ "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix", "build": "web-ext build", "test": "web-ext lint", - "html": "pug --basedir ./ --obj ./src/config.json src/pages/options/index.pug --out src/pages/options/ && pug --basedir ./ --obj ./src/config.json src/pages/popup/popup.pug --out src/pages/popup/" + "html": "rollup -c" }, "repository": { "type": "git", @@ -24,8 +25,16 @@ }, "homepage": "https://libredirect.github.io", "devDependencies": { + "prettier": "3.3.3", "pug-cli": "^1.0.0-alpha6", - "web-ext": "^7.2.0" + "web-ext": "^7.2.0", + "@rollup/plugin-commonjs": "^24.0.0", + "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-terser": "^0.4.0", + "rollup": "^3.15.0", + "rollup-plugin-css-only": "^4.3.0", + "rollup-plugin-svelte": "^7.1.2", + "svelte": "^3.55.0" }, "webExt": { "sourceDir": "./src/", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..71222de8 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,35 @@ +import svelte from "rollup-plugin-svelte" +import commonjs from "@rollup/plugin-commonjs" +import terser from "@rollup/plugin-terser" +import resolve from "@rollup/plugin-node-resolve" +import css from "rollup-plugin-css-only" + +const production = !process.env.ROLLUP_WATCH + +export default { + input: "src/pages/src/main.js", + output: { + sourcemap: true, + format: "iife", + name: "app", + file: "src/pages/options/build/bundle.js", + }, + plugins: [ + svelte({ + compilerOptions: { + dev: !production, + }, + }), + css({ output: "bundle.css" }), + resolve({ + browser: true, + dedupe: ["svelte"], + exportConditions: ["svelte"], + }), + commonjs(), + // production && terser(), + ], + watch: { + clearScreen: false, + }, +} diff --git a/src/pages/options/index.js b/src/pages/options/index.js deleted file mode 100644 index 8d5676e0..00000000 --- a/src/pages/options/index.js +++ /dev/null @@ -1,399 +0,0 @@ -import utils from "../../assets/javascripts/utils.js" - -let config, - options, - blacklist, - redirects, - divs = {} - -for (const a of document.getElementById("links").getElementsByTagName("a")) { - if (!a.href.includes("https://")) { - a.addEventListener("click", e => { - const path = a.getAttribute("href").replace("#", "") - loadPage(path) - e.preventDefault() - }) - } -} - -config = await utils.getConfig() -options = await utils.getOptions() - -/** - * @param {string} service - */ -async function changeFrontendsSettings(service) { - options = await utils.getOptions() - const opacityDiv = document.getElementById(`${service}-opacity`) - if (document.getElementById(`${service}-enabled`).checked) { - opacityDiv.style.pointerEvents = "auto" - opacityDiv.style.opacity = 1 - opacityDiv.style.userSelect = "auto" - } else { - opacityDiv.style.pointerEvents = "none" - opacityDiv.style.opacity = 0.4 - opacityDiv.style.userSelect = "none" - } - for (const frontend in config.services[service].frontends) { - if (config.services[service].frontends[frontend].instanceList) { - const frontendDiv = document.getElementById(frontend) - if (typeof divs[service].frontend !== "undefined") { - if ( - frontend == divs[service].frontend.value || - (config.services[service].frontends[divs[service].frontend.value].desktopApp && - divs[service].embedFrontend && - frontend == divs[service].embedFrontend.value) - ) { - frontendDiv.style.display = "" - if (config.services[service].frontends[frontend].localhost === true) { - document.getElementById(`${service}-instance-div`).style.display = "" - - if (options[service].instance == "localhost") { - frontendDiv.style.display = "none" - } - } else { - document.getElementById(`${service}-instance-div`).style.display = "none" - } - } else { - frontendDiv.style.display = "none" - } - } - } - } - if (document.getElementById(`${service}-redirectType`)) { - const frontend = options[service].frontend - if (config.services[service].frontends[frontend].embeddable) { - document.getElementById(`${service}-redirectType`).innerHTML = ` - - - ` - } else if ( - config.services[service].frontends[frontend].desktopApp && - Object.values(config.services[service].frontends).some(frontend => frontend.embeddable) - ) { - document.getElementById(`${service}-redirectType`).innerHTML = ` - - ` - if (options[service].redirectType == "sub_frame") { - options[service].redirectType = "main_frame" - browser.storage.local.set({ options }) - } - } else { - document.getElementById(`${service}-redirectType`).innerHTML = - '' - options[service].redirectType = "main_frame" - - browser.storage.local.set({ options }) - } - document.getElementById(`${service}-redirectType`).value = options[service].redirectType - if (config.services[service].frontends[frontend].desktopApp && options[service].redirectType != "main_frame") { - document.getElementById(`${service}-embedFrontend-div`).style.display = "" - document.getElementById(divs[service].embedFrontend.value).style.display = "" - } else if ( - config.services[service].frontends[frontend].desktopApp && - options[service].redirectType == "main_frame" - ) { - document.getElementById(`${service}-embedFrontend-div`).style.display = "none" - document.getElementById(divs[service].embedFrontend.value).style.display = "none" - } else { - document.getElementById(`${service}-embedFrontend-div`).style.display = "none" - } - } - const frontend_name_element = document.getElementById(`${service}_page`).getElementsByClassName("frontend_name")[0] - frontend_name_element.href = config.services[service].frontends[divs[service].frontend.value].url -} - -/** - * @param {string} path - */ -async function loadPage(path) { - options = await utils.getOptions() - for (const section of document.getElementById("pages").getElementsByTagName("section")) section.style.display = "none" - document.getElementById(`${path}_page`).style.display = "block" - - for (const element of document.getElementsByClassName("title")) { - const a = element.getElementsByTagName("a")[0] - if (a.getAttribute("href") == `#${path}`) { - element.classList.add("selected") - } else { - element.classList.remove("selected") - } - } - - for (const service in config.services) { - if (options[service].enabled) { - document.getElementById(`${service}-link`).style.opacity = 1 - } else { - document.getElementById(`${service}-link`).style.opacity = 0.4 - } - } - - window.history.pushState({ id: "100" }, "Page 2", `/pages/options/index.html#${path}`) - - if (path != "general") { - const service = path - divs[service] = {} - for (const option in config.services[service].options) { - divs[service][option] = document.getElementById(`${service}-${option}`) - if (typeof config.services[service].options[option] == "boolean") - divs[service][option].checked = options[service][option] - else divs[service][option].value = options[service][option] - divs[service][option].addEventListener("change", async () => { - let options = await utils.getOptions() - if (typeof config.services[service].options[option] == "boolean") - options[service][option] = divs[service][option].checked - else options[service][option] = divs[service][option].value - browser.storage.local.set({ options }) - changeFrontendsSettings(service) - }) - } - changeFrontendsSettings(service) - - blacklist = await utils.getBlacklist(options) - redirects = await utils.getList(options) - for (const frontend in config.services[service].frontends) { - if (config.services[service].frontends[frontend].instanceList) { - if (redirects == "disabled" || blacklist == "disabled") { - document.getElementById(frontend).getElementsByClassName("clearnet")[0].style.display = "none" - document.getElementById(frontend).getElementsByClassName("ping")[0].style.display = "none" - } else if (!redirects || !blacklist) { - document - .getElementById(frontend) - .getElementsByClassName("clearnet")[0] - .getElementsByClassName("checklist")[0] - .getElementsByClassName("loading")[0].innerHTML = "Could not fetch instances." - } else { - createList(frontend) - } - } - } - - for (const frontend in config.services[service].frontends) { - if (config.services[service].frontends[frontend].instanceList) { - processCustomInstances(frontend) - document.getElementById(`ping-${frontend}`).addEventListener("click", async () => { - document.getElementById(`ping-${frontend}`).getElementsByTagName("x")[0].innerHTML = "Pinging..." - await ping(frontend) - document.getElementById(`ping-${frontend}`).getElementsByTagName("x")[0].innerHTML = "Ping instances" - }) - } - } - } -} - -async function calcCustomInstances(frontend) { - let options = await utils.getOptions() - let customInstances = options[frontend] - const pingCache = await utils.getPingCache() - - document.getElementById(frontend).getElementsByClassName("custom-checklist")[0].innerHTML = customInstances - .map(x => { - const time = pingCache[x] - if (time) { - var { color, text } = processTime(time) - } - const timeText = time ? `${text}` : "" - const custom = isCustomInstance(frontend, x) ? "" : `custom` - return `
- - ${x} - ${timeText} - ${custom} - - -
-
` - }) - .join("\n") - for (const item of customInstances) { - document - .getElementById(frontend) - .getElementsByClassName(`clear-${item}`)[0] - .addEventListener("click", async () => { - const index = customInstances.indexOf(item) - if (index > -1) customInstances.splice(index, 1) - options = await utils.getOptions() - options[frontend] = customInstances - browser.storage.local.set({ options }, async () => { - calcCustomInstances(frontend) - createList(frontend) - }) - }) - } -} - -async function processCustomInstances(frontend) { - calcCustomInstances(frontend) - document - .getElementById(frontend) - .getElementsByClassName("custom-instance-form")[0] - .addEventListener("submit", async event => { - event.preventDefault() - let options = await utils.getOptions() - let customInstances = options[frontend] - let frontendCustomInstanceInput = document.getElementById(frontend).getElementsByClassName("custom-instance")[0] - try { - var url = new URL(frontendCustomInstanceInput.value) - } catch (error) { - return - } - let protocolHostVar = utils.protocolHost(url) - if (frontendCustomInstanceInput.validity.valid) { - if (!customInstances.includes(protocolHostVar)) { - customInstances.push(protocolHostVar) - options = await utils.getOptions() - options[frontend] = customInstances - browser.storage.local.set({ options }, () => { - frontendCustomInstanceInput.value = "" - calcCustomInstances(frontend) - }) - } - } - }) -} - -/** - * @param {string} frontend - */ -async function createList(frontend) { - const pingCache = await utils.getPingCache() - const options = await utils.getOptions() - for (const network in config.networks) { - const checklist = document - .getElementById(frontend) - .getElementsByClassName(network)[0] - .getElementsByClassName("checklist")[0] - - if (!redirects[frontend]) { - checklist.innerHTML = '
No instances found.
' - break - } - - const instances = redirects[frontend][network] - if (!instances || instances.length === 0) continue - - document.getElementById(frontend).getElementsByClassName("custom-instance")[0].placeholder = - redirects[frontend].clearnet[0] - - instances.sort((a, b) => blacklist.cloudflare.includes(a) && !blacklist.cloudflare.includes(b)) - const content = instances.map(x => { - const cloudflare = blacklist.cloudflare.includes(x) - ? ` - cloudflare - ` - : "" - - let time = pingCache[x] - let timeText = "" - if (time) { - const { color, text } = processTime(time) - timeText = `${text}` - } - - const chosen = options[frontend].includes(x) ? `chosen` : "" - - const warnings = [cloudflare, timeText, chosen].join(" ") - return `
- - ${x} - ${warnings} - - -
` - }) - - checklist.innerHTML = [ - `
- -
`, - ...content, - "
", - ].join("\n
\n") - - for (const instance of instances) { - checklist.getElementsByClassName(`add-${instance}`)[0].addEventListener("click", async () => { - let options = await utils.getOptions() - if (!options[frontend].includes(instance)) { - options[frontend].push(instance) - browser.storage.local.set({ options }, () => { - calcCustomInstances(frontend) - createList(frontend) - }) - } - }) - } - } -} - -const r = window.location.href.match(/#(.*)/) -if (r) loadPage(r[1]) -else loadPage("general") - -/** - * @param {string} frontend - */ -async function ping(frontend) { - const instanceElements = [ - ...document.getElementById(frontend).getElementsByClassName("custom-checklist")[0].getElementsByTagName("x"), - ...document.getElementById(frontend).getElementsByClassName("clearnet")[0].getElementsByTagName("x"), - ] - - let pingCache = await utils.getPingCache() - let redundancyList = {} - for (const element of instanceElements) { - let span = element.getElementsByClassName("ping")[0] - if (!span) span = document.createElement("span") - span.classList = ["ping"] - span.innerHTML = 'pinging...' - element.appendChild(span) - const href = element.getElementsByTagName("a")[0].href - const innerHTML = element.getElementsByTagName("a")[0].innerHTML - const time = redundancyList[innerHTML] ?? (await utils.ping(href)) - const { color, text } = processTime(time) - span.innerHTML = `${text}` - pingCache[innerHTML] = time - redundancyList[innerHTML] = time - - browser.storage.local.set({ pingCache }) - } -} - -/** - * @param {number} time - */ -function processTime(time) { - let text - let color - if (time < 5000) { - text = `${time}ms` - if (time <= 1000) color = "green" - else if (time <= 2000) color = "orange" - } else if (time >= 5000) { - color = "red" - if (time == 5000) text = "5000ms+" - if (time > 5000) text = `Error: ${time - 5000}` - } else { - color = "red" - text = "Server not found" - } - return { color, text } -} - -function isCustomInstance(frontend, instance) { - for (const network in config.networks) { - if (!redirects[frontend]) return false - const instances = redirects[frontend][network] - if (instances.includes(instance)) return true - } - return false -} diff --git a/src/pages/options/index.pug b/src/pages/options/index.pug deleted file mode 100644 index 4e19b087..00000000 --- a/src/pages/options/index.pug +++ /dev/null @@ -1,10 +0,0 @@ -doctype html -html(id="elementToShowWithJavaScript" lang="en") - include /src/pages/widgets/head - body(class="option" dir="auto") - include /src/pages/widgets/links - div#pages - include /src/pages/options/widgets/general - include /src/pages/options/widgets/services - script(type="module" src="./index.js") - \ No newline at end of file diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js deleted file mode 100644 index b9ddfd08..00000000 --- a/src/pages/options/widgets/general.js +++ /dev/null @@ -1,216 +0,0 @@ -"use strict" -window.browser = window.browser || window.chrome - -import utils from "../../../assets/javascripts/utils.js" -import servicesHelper from "../../../assets/javascripts/services.js" - -const isChrome = browser.runtime.getBrowserInfo === undefined - -async function setOption(option, type, event) { - let options = await utils.getOptions() - switch (type) { - case "select": - options[option] = event.target.options[event.target.options.selectedIndex].value - break - case "checkbox": - options[option] = event.target.checked - break - case "range": - options[option] = event.target.value - break - } - browser.storage.local.set({ options }) -} - -const exportSettingsElement = document.getElementById("export-settings") -async function exportSettings() { - const options = await utils.getOptions() - options.version = browser.runtime.getManifest().version - let resultString = JSON.stringify(options, null, " ") - exportSettingsElement.href = "data:application/json;base64," + btoa(resultString) - exportSettingsElement.download = `libredirect-settings-v${options.version}.json` - return -} -exportSettings() -document.getElementById("general_page").onclick = exportSettings - -const importSettingsElement = document.getElementById("import-settings") -const importSettingsElementText = document.getElementById("import_settings_text") -importSettingsElement.addEventListener("change", () => { - function importError() { - const oldHTML = importSettingsElementText.innerHTML - importSettingsElementText.innerHTML = 'Error!' - setTimeout(() => (importSettingsElementText.innerHTML = oldHTML), 1000) - } - importSettingsElementText.innerHTML = "..." - let file = importSettingsElement.files[0] - const reader = new FileReader() - reader.readAsText(file) - reader.onload = async () => { - const data = JSON.parse(reader.result) - if ("theme" in data && data.version == browser.runtime.getManifest().version) { - browser.storage.local.clear(async () => { - browser.storage.local.set({ options: data }, () => { - location.reload() - }) - }) - } else { - console.log("incompatible settings") - importError() - } - } - reader.onerror = error => { - console.log("error", error) - importError() - } -}) - -const exportSettingsSync = document.getElementById("export-settings-sync") -const importSettingsSync = document.getElementById("import-settings-sync") -const importSettingsSyncText = document.getElementById("import_settings_sync_text") - -exportSettingsSync.addEventListener("click", async () => { - let options = await utils.getOptions() - options.version = browser.runtime.getManifest().version - browser.storage.sync.set({ options }, () => location.reload()) -}) - -importSettingsSync.addEventListener("click", () => { - function importError() { - importSettingsSyncText.innerHTML = 'Error!' - setTimeout(() => (importSettingsSyncText.innerHTML = oldHTML), 1000) - } - const oldHTML = importSettingsSyncText.innerHTML - importSettingsSyncText.innerHTML = "..." - browser.storage.sync.get({ options }, r => { - const options = r.options - if (options.version == browser.runtime.getManifest().version) { - browser.storage.local.set({ options }, () => location.reload()) - } else { - importError() - } - }) -}) - -const resetSettings = document.getElementById("reset-settings") -resetSettings.addEventListener("click", async () => { - resetSettings.innerHTML = "..." - await servicesHelper.initDefaults() - location.reload() -}) - -const fetchInstancesElement = document.getElementById("fetch-instances") -fetchInstancesElement.addEventListener("change", event => { - setOption("fetchInstances", "select", event) - location.reload() -}) - -const redirectOnlyInIncognitoElement = document.getElementById("redirectOnlyInIncognito") -redirectOnlyInIncognitoElement.addEventListener("change", event => { - setOption("redirectOnlyInIncognito", "checkbox", event) -}) - -const bookmarksMenuElement = document.getElementById("bookmarksMenu") -bookmarksMenuElement.addEventListener("change", async event => { - if (event.target.checked) - browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksMenuElement.checked = r)) - else browser.permissions.remove({ permissions: ["bookmarks"] }, r => (bookmarksMenuElement.checked = !r)) -}) - -let themeElement = document.getElementById("theme") -themeElement.addEventListener("change", event => { - setOption("theme", "select", event) - location.reload() -}) - -let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance") -let instanceTypeElement = document.getElementById("exceptions-custom-instance-type") -let instanceType = "url" - -let config = await utils.getConfig() - -for (const service in config.services) { - document.getElementById(service).addEventListener("change", async event => { - let options = await utils.getOptions() - if (event.target.checked && !options.popupServices.includes(service)) options.popupServices.push(service) - else if (options.popupServices.includes(service)) { - var index = options.popupServices.indexOf(service) - if (index !== -1) options.popupServices.splice(index, 1) - } - browser.storage.local.set({ options }) - }) -} - -let options = await utils.getOptions() -themeElement.value = options.theme -fetchInstancesElement.value = options.fetchInstances -redirectOnlyInIncognitoElement.checked = options.redirectOnlyInIncognito -browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksMenuElement.checked = r)) -for (const service in config.services) - document.getElementById(service).checked = options.popupServices.includes(service) - -instanceTypeElement.addEventListener("change", event => { - instanceType = event.target.options[instanceTypeElement.selectedIndex].value - if (instanceType == "url") { - nameCustomInstanceInput.setAttribute("type", "url") - nameCustomInstanceInput.setAttribute("placeholder", "https://www.google.com") - } else if (instanceType == "regex") { - nameCustomInstanceInput.setAttribute("type", "text") - nameCustomInstanceInput.setAttribute("placeholder", "https?://(www.|)youtube.com/") - } -}) - -let exceptionsCustomInstances = options.exceptions -function calcExceptionsCustomInstances() { - document.getElementById("exceptions-custom-checklist").innerHTML = [ - ...exceptionsCustomInstances.url, - ...exceptionsCustomInstances.regex, - ] - .map( - x => `
- ${x} - -
-
` - ) - .join("\n") - - for (const x of [...exceptionsCustomInstances.url, ...exceptionsCustomInstances.regex]) { - document.getElementById(`clear-${x}`).addEventListener("click", async () => { - let index - index = exceptionsCustomInstances.url.indexOf(x) - if (index > -1) exceptionsCustomInstances.url.splice(index, 1) - else { - index = exceptionsCustomInstances.regex.indexOf(x) - if (index > -1) exceptionsCustomInstances.regex.splice(index, 1) - } - options = await utils.getOptions() - options.exceptions = exceptionsCustomInstances - browser.storage.local.set({ options }) - calcExceptionsCustomInstances() - }) - } -} -calcExceptionsCustomInstances() -document.getElementById("custom-exceptions-instance-form").addEventListener("submit", async event => { - event.preventDefault() - let val - if (instanceType == "url" && nameCustomInstanceInput.validity.valid) { - val = nameCustomInstanceInput.value - if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val) - } else if (instanceType == "regex") { - val = nameCustomInstanceInput.value - if (val.trim() != "" && !exceptionsCustomInstances.regex.includes(val)) exceptionsCustomInstances.regex.push(val) - } - if (val) { - options = await utils.getOptions() - options.exceptions = exceptionsCustomInstances - browser.storage.local.set({ options }, () => (nameCustomInstanceInput.value = "")) - } - calcExceptionsCustomInstances() -}) diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug deleted file mode 100644 index 1388584a..00000000 --- a/src/pages/options/widgets/general.pug +++ /dev/null @@ -1,88 +0,0 @@ -section(class="block-option" id="general_page") - div(class="block block-option") - h1(data-localise="__MSG_general__") General - hr - - div(class="block block-option") - label(data-localise="__MSG_theme__") Theme - select(id="theme" aria-label="select theme") - option(value="detect" data-localise="__MSG_auto__") Auto - option(value="light" data-localise="__MSG_light__") Light - option(value="dark" data-localise="__MSG_dark__") Dark - - div(class="block block-option") - label(data-localise="__MSG_fetchPublicInstances__") Fetch public instances - select(id="fetch-instances" aria-label="Select fetch public instances") - option(value="github") GitHub - option(value="codeberg") Codeberg - option(value="disable" data-localise="__MSG_disable__") Disable - - div(class="block block-option") - label(for='redirectOnlyInIncognito' data-localise="__MSG_redirectOnlyInIncognito__") Redirect Only in Incognito - input(id='redirectOnlyInIncognito' type="checkbox") - - div(class="block block-option") - label(for='bookmarksMenu' data-localise="__MSG_bookmarksMenu__") Bookmarks menu - input(id='bookmarksMenu' type="checkbox") - - div(class="block block-option") - label(data-localise="__MSG_excludeFromRedirecting__") Excluded from redirecting - - form(id="custom-exceptions-instance-form") - div(class="block block-option") - div(class="block" style="padding: 0") - input(id="exceptions-custom-instance" placeholder="https://www.google.com" type="url" aria-label="Add url exception input") - |  - select(id="exceptions-custom-instance-type") - option(value="url") URL - option(value="regex") Regex - |  - button(class="add" id="exceptions-add-instance" type="submit" aria-label="Add the url exception") - svg(xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor") - path(d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z") - - hr - - div(class="checklist" id="exceptions-custom-checklist") - - div(class="buttons") - label(class="button button-inline" id="import_settings_text" for="import-settings") - 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") - |  - x(data-localise="__MSG_importSettings__") Import Settings - input(id="import-settings" type="file" accept=".json" style="display: none") - - |   - - a(class="button button-inline" id="export-settings") - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z") - |  - x(data-localise="__MSG_exportSettings__") Export Settings - - |   - - button(class="button button-inline" id="export-settings-sync") - svg(xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z") - |  - x() Export Settings to Sync - - |   - - button(class="button button-inline" id="import-settings-sync") - 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") - |  - x(id="import_settings_sync_text") Import Settings from Sync - - |   - - button(class="button button-inline" id="reset-settings") - svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") - path(d="M12,5V2L8,6l4,4V7c3.31,0,6,2.69,6,6c0,2.97-2.17,5.43-5,5.91v2.02c3.95-0.49,7-3.85,7-7.93C20,8.58,16.42,5,12,5z") - path(d="M6,13c0-1.65,0.67-3.15,1.76-4.24L6.34,7.34C4.9,8.79,4,10.79,4,13c0,4.08,3.05,7.44,7,7.93v-2.02 C8.17,18.43,6,15.97,6,13z") - x(data-localise="__MSG_resetSettings__") Reset Settings - - script(type="module" src="./widgets/general.js") \ No newline at end of file diff --git a/src/pages/options/widgets/services.pug b/src/pages/options/widgets/services.pug deleted file mode 100644 index e08bb001..00000000 --- a/src/pages/options/widgets/services.pug +++ /dev/null @@ -1,83 +0,0 @@ -each val, service in services - section(class="block-option" id=service+"_page") - div(class="block block-option") - h1 - a(target="_blank" href=services[service].url)=services[service].name - - hr - - div(class="block block-option") - label(for=`${service}-enabled` data-localise="__MSG_enable__") Enable - input(id=`${service}-enabled` type="checkbox") - - div(class="block block-option") - label(for=service data-localise="__MSG_showInPopup__") Show in popup - input(id=service type="checkbox") - - div(id=service+"-opacity") - - div(class="block block-option") - label(for=`${service}-frontend`) - a(class="frontend_name" target="_blank" data-localise="__MSG_frontend__") Frontend - select(id=`${service}-frontend`) - each val, frontend in services[service].frontends - option(value=frontend)=services[service].frontends[frontend].name - - div(class="block block-option" id=service+"-instance-div") - label(for=`${service}-instance`) Instance Type - select(id=`${service}-instance`) - option(value="localhost") localhost - option(value="public") public instances - - div(class="block block-option") - label(for=`${service}-redirectType` data-localise="__MSG_redirectType__") Redirect Type - select(id=`${service}-redirectType`) - - - div(id=`${service}-embedFrontend-div` class="block block-option") - label(for=`${service}-embedFrontend` data-localise="__MSG_embedFrontend__") Embed Frontend - select(id=`${service}-embedFrontend`) - each val, frontend in services[service].frontends - if services[service].frontends[frontend].embeddable && services[service].frontends[frontend].instanceList - option(value=frontend)=services[service].frontends[frontend].name - - - div(class="block block-option") - label(for=`${service}-unsupportedUrls` data-localise="__MSG_unsupportedIframesHandling__") Unsupported iframes handling - select(id=`${service}-unsupportedUrls`) - option(value="bypass") bypass - option(value="block") block - - if (service == 'search') - div(class="block block-option") - label Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here. - - - each val, frontend in services[service].frontends - if services[service].frontends[frontend].instanceList - div(id=frontend dir="ltr") - hr - div(dir="auto" class="block block-option") - label(data-localise="__MSG_addYourFavoriteInstances__") Add your favorite instances - - form(class="custom-instance-form") - div(class="block block-option") - input(class="custom-instance" type="url" placeholder="https://instance.com" aria-label="Add instance input") - button(class="add add-instance" type="submit" aria-label="Add the instance") - 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") - - div(class="checklist custom-checklist") - - div(class="ping block") - button(class="button button-inline" id=`ping-${frontend}`) - svg(xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 0 24 24" width="20px" fill="currentColor") - path(d="M10.45 15.5q.6.6 1.55.587.95-.012 1.4-.687L19 7l-8.4 5.6q-.675.45-.712 1.375-.038.925.562 1.525ZM12 4q1.475 0 2.838.412Q16.2 4.825 17.4 5.65l-1.9 1.2q-.825-.425-1.712-.637Q12.9 6 12 6 8.675 6 6.338 8.337 4 10.675 4 14q0 1.05.287 2.075Q4.575 17.1 5.1 18h13.8q.575-.95.838-1.975Q20 15 20 13.9q0-.9-.212-1.75-.213-.85-.638-1.65l1.2-1.9q.75 1.175 1.188 2.5.437 1.325.462 2.75.025 1.425-.325 2.725-.35 1.3-1.025 2.475-.275.45-.75.7-.475.25-1 .25H5.1q-.525 0-1-.25t-.75-.7q-.65-1.125-1-2.387Q2 15.4 2 14q0-2.075.788-3.888.787-1.812 2.15-3.175Q6.3 5.575 8.125 4.787 9.95 4 12 4Zm.175 7.825Z") - |  - x() Ping instances - - each val, network in networks - div(class=network) - div(class="checklist") - if (network == 'clearnet') - div(class="block block-option loading") Loading... \ No newline at end of file diff --git a/src/pages/src/App.svelte b/src/pages/src/App.svelte new file mode 100644 index 00000000..8cceb5d1 --- /dev/null +++ b/src/pages/src/App.svelte @@ -0,0 +1,118 @@ + + +{#if _options && _config} +
+ + {#if _page == "general"} + + {:else if _page == "services"} + + {/if} +
+{:else} +

Loading...

+{/if} + + diff --git a/src/pages/src/General/Exceptions.svelte b/src/pages/src/General/Exceptions.svelte new file mode 100644 index 00000000..e43afaf6 --- /dev/null +++ b/src/pages/src/General/Exceptions.svelte @@ -0,0 +1,108 @@ + + +
+ + + + +
+ { + if (e.key === "Enter") addException() + }} + /> + + + + + + + + + +
diff --git a/src/pages/src/Services/Instances.svelte b/src/pages/src/Services/Instances.svelte new file mode 100644 index 00000000..3c9b1ccf --- /dev/null +++ b/src/pages/src/Services/Instances.svelte @@ -0,0 +1,234 @@ + + +{#if serviceConf.frontends[serviceOptions.frontend].instanceList && redirects && blacklist} +
+
+
+ +
+ + + + + + + { + if (e.key === "Enter") addInstance() + }} + /> + + + + {#each _options[serviceOptions.frontend] as instance} + + + {instance} + {#if isCustomInstance(instance)} + custom + {/if} + {#if pingCache && pingCache[instance]} + {pingCache[instance].value} + {/if} + + + +
+ {/each} + + + {#if redirects !== "disabled" && blacklist !== "disabled"} + {#if redirects[serviceOptions.frontend] && redirects[serviceOptions.frontend]["clearnet"]} + {#each Object.entries(_config.networks) as [networkName, network]} + {#if redirects[serviceOptions.frontend] && redirects[serviceOptions.frontend][networkName]} + +
+ {#each redirects[serviceOptions.frontend][networkName] as instance} + + + {instance} + {#if blacklist.cloudflare.includes(instance)} + + cloudflare + + {/if} + {#if _options[serviceOptions.frontend].includes(instance)} + chosen + {/if} + {#if pingCache && pingCache[instance]} + {pingCache[instance].value} + {/if} + + + +
+ {/each} + {/if} + {/each} + {:else} + + {/if} + {/if} +
+{/if} + + diff --git a/src/pages/src/Services/RedirectType.svelte b/src/pages/src/Services/RedirectType.svelte new file mode 100644 index 00000000..92b8c6d1 --- /dev/null +++ b/src/pages/src/Services/RedirectType.svelte @@ -0,0 +1,84 @@ + + + { + serviceOptions.redirectType = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + {values} +/> + +{#if serviceConf.frontends[frontendName].desktopApp && serviceOptions.redirectType != "main_frame"} + { + serviceOptions.embedFrontend = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + values={embeddableFrontends} + /> +{/if} diff --git a/src/pages/src/Services/Services.svelte b/src/pages/src/Services/Services.svelte new file mode 100644 index 00000000..b5d9285c --- /dev/null +++ b/src/pages/src/Services/Services.svelte @@ -0,0 +1,119 @@ + + +
+ + + ({ + value: frontendId, + name: frontend.name, + })), + ]} + onChange={e => { + serviceOptions.frontend = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + /> + + + + + { + serviceOptions.unsupportedUrls = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + values={[ + { value: "bypass", name: "Bypass" }, + { value: "block", name: "Block" }, + ]} + /> + + {#if selectedService == "search"} +
+ Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click + here. +
+ {/if} + + +
+
diff --git a/src/pages/src/Sidebar.svelte b/src/pages/src/Sidebar.svelte new file mode 100644 index 00000000..be59a731 --- /dev/null +++ b/src/pages/src/Sidebar.svelte @@ -0,0 +1,43 @@ + + + + + diff --git a/src/pages/src/components/Button.svelte b/src/pages/src/components/Button.svelte new file mode 100644 index 00000000..3405c2ea --- /dev/null +++ b/src/pages/src/components/Button.svelte @@ -0,0 +1,29 @@ + + + diff --git a/src/pages/src/components/Checkbox.svelte b/src/pages/src/components/Checkbox.svelte new file mode 100644 index 00000000..f5245045 --- /dev/null +++ b/src/pages/src/components/Checkbox.svelte @@ -0,0 +1,52 @@ + + + + + diff --git a/src/pages/src/components/Input.svelte b/src/pages/src/components/Input.svelte new file mode 100644 index 00000000..d963233c --- /dev/null +++ b/src/pages/src/components/Input.svelte @@ -0,0 +1,41 @@ + + + + + diff --git a/src/pages/src/components/Label.svelte b/src/pages/src/components/Label.svelte new file mode 100644 index 00000000..39930cd1 --- /dev/null +++ b/src/pages/src/components/Label.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/src/pages/src/components/Row.svelte b/src/pages/src/components/Row.svelte new file mode 100644 index 00000000..4f23cffa --- /dev/null +++ b/src/pages/src/components/Row.svelte @@ -0,0 +1,12 @@ +
+ +
+ + diff --git a/src/pages/src/components/RowCheckbox.svelte b/src/pages/src/components/RowCheckbox.svelte new file mode 100644 index 00000000..b7ccab93 --- /dev/null +++ b/src/pages/src/components/RowCheckbox.svelte @@ -0,0 +1,14 @@ + + + + + + diff --git a/src/pages/src/components/RowSelect.svelte b/src/pages/src/components/RowSelect.svelte new file mode 100644 index 00000000..d685803e --- /dev/null +++ b/src/pages/src/components/RowSelect.svelte @@ -0,0 +1,19 @@ + + + + + + {#each values as option} + + {/each} + + + diff --git a/src/pages/src/icons/AboutIcon.svelte b/src/pages/src/icons/AboutIcon.svelte new file mode 100644 index 00000000..e113dd68 --- /dev/null +++ b/src/pages/src/icons/AboutIcon.svelte @@ -0,0 +1,11 @@ + diff --git a/src/pages/src/icons/AddIcon.svelte b/src/pages/src/icons/AddIcon.svelte new file mode 100644 index 00000000..ab26f078 --- /dev/null +++ b/src/pages/src/icons/AddIcon.svelte @@ -0,0 +1,3 @@ + + + diff --git a/src/pages/src/icons/CloseIcon.svelte b/src/pages/src/icons/CloseIcon.svelte new file mode 100644 index 00000000..ddfb29cb --- /dev/null +++ b/src/pages/src/icons/CloseIcon.svelte @@ -0,0 +1,3 @@ + diff --git a/src/pages/src/icons/ExportIcon.svelte b/src/pages/src/icons/ExportIcon.svelte new file mode 100644 index 00000000..196726a8 --- /dev/null +++ b/src/pages/src/icons/ExportIcon.svelte @@ -0,0 +1,5 @@ + + + diff --git a/src/pages/src/icons/GeneralIcon.svelte b/src/pages/src/icons/GeneralIcon.svelte new file mode 100644 index 00000000..b9429021 --- /dev/null +++ b/src/pages/src/icons/GeneralIcon.svelte @@ -0,0 +1,13 @@ + + + diff --git a/src/pages/src/icons/ImportIcon.svelte b/src/pages/src/icons/ImportIcon.svelte new file mode 100644 index 00000000..f022b4f0 --- /dev/null +++ b/src/pages/src/icons/ImportIcon.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/src/pages/src/icons/PingIcon.svelte b/src/pages/src/icons/PingIcon.svelte new file mode 100644 index 00000000..8fcfe27b --- /dev/null +++ b/src/pages/src/icons/PingIcon.svelte @@ -0,0 +1,5 @@ + + diff --git a/src/pages/src/icons/ResetIcon.svelte b/src/pages/src/icons/ResetIcon.svelte new file mode 100644 index 00000000..0900aef8 --- /dev/null +++ b/src/pages/src/icons/ResetIcon.svelte @@ -0,0 +1,15 @@ + + + + diff --git a/src/pages/src/icons/ServicesIcon.svelte b/src/pages/src/icons/ServicesIcon.svelte new file mode 100644 index 00000000..ec24259b --- /dev/null +++ b/src/pages/src/icons/ServicesIcon.svelte @@ -0,0 +1,11 @@ + diff --git a/src/pages/src/main.js b/src/pages/src/main.js new file mode 100644 index 00000000..c4012f4a --- /dev/null +++ b/src/pages/src/main.js @@ -0,0 +1,7 @@ +import App from "./App.svelte" + +const app = new App({ + target: document.body, +}) + +export default app diff --git a/src/pages/src/stores.js b/src/pages/src/stores.js new file mode 100644 index 00000000..782f6064 --- /dev/null +++ b/src/pages/src/stores.js @@ -0,0 +1,5 @@ +import { writable } from "svelte/store" + +export const options = writable(null) +export const config = writable(null) +export const page = writable("general") diff --git a/src/pages/widgets/head.pug b/src/pages/widgets/head.pug deleted file mode 100644 index 0c6e9fdb..00000000 --- a/src/pages/widgets/head.pug +++ /dev/null @@ -1,7 +0,0 @@ -head - meta(charset="utf-8") - meta(name="viewport" content="width=device-width, initial-scale=1") - link(rel="icon" type="image/x-icon" href="../../../assets/images/libredirect.svg") - link(href="../stylesheets/styles.css" rel="stylesheet") - title Settings - script(type="module" src="./init.js") \ No newline at end of file diff --git a/src/pages/widgets/links.pug b/src/pages/widgets/links.pug deleted file mode 100644 index 318c72f9..00000000 --- a/src/pages/widgets/links.pug +++ /dev/null @@ -1,22 +0,0 @@ -section(class="links" id="links") - div(class="title") - a(href="#general") - include /src/assets/images/general-icon.svg - span(data-localise="__MSG_general__") General - - each val, key in services - div(class="title" id=`${key}-link`) - a(href="#"+key) - if services[key].imageType == 'svgMono' - img(class='dark' src=`/assets/images/${key}-icon.svg`) - img(class='light' src=`/assets/images/${key}-icon-light.svg`) - else - img(src=`/assets/images/${key}-icon.${services[key].imageType}`) - span=services[key].name - - div(class="title") - a(target="_blank" href="https://libredirect.github.io") - img(class='dark' src="/assets/images/about-icon.svg") - img(class='light' src="/assets/images/about-icon-light.svg") - - span(data-localise="__MSG_about__") About -- cgit 1.4.1 From 1f6859e4e67195df2dafa8ea179d253735ceb471 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 24 Jul 2024 16:37:15 +0300 Subject: Made Select Services searchable and with iconsk --- package.json | 11 ++-- src/pages/src/App.svelte | 1 - src/pages/src/Services/Instances.svelte | 49 ++++++++-------- src/pages/src/Services/RedirectType.svelte | 20 +++---- src/pages/src/Services/ServiceIcon.svelte | 37 ++++++++++++ src/pages/src/Services/Services.svelte | 92 ++++++++++++++++++++++++------ src/pages/src/Sidebar.svelte | 2 +- src/pages/src/components/Select.svelte | 2 +- 8 files changed, 152 insertions(+), 62 deletions(-) create mode 100644 src/pages/src/Services/ServiceIcon.svelte (limited to 'src/pages') diff --git a/package.json b/package.json index 234dd5e1..cff52274 100644 --- a/package.json +++ b/package.json @@ -25,16 +25,16 @@ }, "homepage": "https://libredirect.github.io", "devDependencies": { - "prettier": "3.3.3", - "pug-cli": "^1.0.0-alpha6", - "web-ext": "^7.2.0", "@rollup/plugin-commonjs": "^24.0.0", "@rollup/plugin-node-resolve": "^15.0.0", "@rollup/plugin-terser": "^0.4.0", + "prettier": "3.3.3", + "pug-cli": "^1.0.0-alpha6", "rollup": "^3.15.0", "rollup-plugin-css-only": "^4.3.0", "rollup-plugin-svelte": "^7.1.2", - "svelte": "^3.55.0" + "svelte": "^3.55.0", + "web-ext": "^7.2.0" }, "webExt": { "sourceDir": "./src/", @@ -44,5 +44,8 @@ "build": { "overwriteDest": true } + }, + "dependencies": { + "svelte-select": "^5.8.3" } } diff --git a/src/pages/src/App.svelte b/src/pages/src/App.svelte index 8cceb5d1..f24b43e0 100644 --- a/src/pages/src/App.svelte +++ b/src/pages/src/App.svelte @@ -29,7 +29,6 @@ onMount(async () => { let opts = await utils.getOptions() if (!opts) { - console.log("init defulats") await servicesHelper.initDefaults() opts = await utils.getOptions() } diff --git a/src/pages/src/Services/Instances.svelte b/src/pages/src/Services/Instances.svelte index 3c9b1ccf..39d61f26 100644 --- a/src/pages/src/Services/Instances.svelte +++ b/src/pages/src/Services/Instances.svelte @@ -13,6 +13,7 @@ import utils from "../../../assets/javascripts/utils" export let selectedService + export let selectedFrontend let _options let _config @@ -34,10 +35,10 @@ $: { allInstances = [] - if (_options[serviceOptions.frontend]) allInstances.push(..._options[serviceOptions.frontend]) - if (redirects && redirects[serviceOptions.frontend]) { - for (const network in redirects[serviceOptions.frontend]) { - allInstances.push(...redirects[serviceOptions.frontend][network]) + if (_options[selectedFrontend]) allInstances.push(..._options[selectedFrontend]) + if (redirects && redirects[selectedFrontend]) { + for (const network in redirects[selectedFrontend]) { + allInstances.push(...redirects[selectedFrontend][network]) } } } @@ -48,12 +49,12 @@ } function isCustomInstance(instance) { - if (redirects[serviceOptions.frontend]) { - for (const network in redirects[serviceOptions.frontend]) { - if (redirects[serviceOptions.frontend][network].includes(instance)) return true + if (redirects[selectedFrontend]) { + for (const network in redirects[selectedFrontend]) { + if (redirects[selectedFrontend][network].includes(instance)) return false } } - return false + return true } async function pingInstances() { @@ -92,15 +93,15 @@ let addInstanceValue function addInstance() { const instance = utils.protocolHost(new URL(addInstanceValue)) - if (!_options[serviceOptions.frontend].includes(instance)) { - _options[serviceOptions.frontend].push(instance) + if (!_options[selectedFrontend].includes(instance)) { + _options[selectedFrontend].push(instance) addInstanceValue = "" options.set(_options) } } -{#if serviceConf.frontends[serviceOptions.frontend].instanceList && redirects && blacklist} +{#if serviceConf.frontends[selectedFrontend].instanceList && redirects && blacklist}
@@ -120,16 +121,14 @@ type="url" placeholder="https://instance.com" aria-label="Add instance input" - on:keydown={e => { - if (e.key === "Enter") addInstance() - }} + on:keydown={e => e.key === "Enter" && addInstance()} /> - {#each _options[serviceOptions.frontend] as instance} + {#each _options[selectedFrontend] as instance} {instance} @@ -144,9 +143,9 @@ class="add" aria-label="Remove Instance" on:click={() => { - const index = _options[serviceOptions.frontend].indexOf(instance) + const index = _options[selectedFrontend].indexOf(instance) if (index > -1) { - _options[serviceOptions.frontend].splice(index, 1) + _options[selectedFrontend].splice(index, 1) options.set(_options) } }} @@ -156,15 +155,15 @@
{/each} - {#if redirects !== "disabled" && blacklist !== "disabled"} - {#if redirects[serviceOptions.frontend] && redirects[serviceOptions.frontend]["clearnet"]} + {#if redirects[selectedFrontend] && redirects[selectedFrontend]["clearnet"]} {#each Object.entries(_config.networks) as [networkName, network]} - {#if redirects[serviceOptions.frontend] && redirects[serviceOptions.frontend][networkName]} + {#if redirects[selectedFrontend] && redirects[selectedFrontend][networkName] && redirects[selectedFrontend][networkName].length > 0} +
- {#each redirects[serviceOptions.frontend][networkName] as instance} + {#each redirects[selectedFrontend][networkName] as instance} {instance} @@ -178,7 +177,7 @@ cloudflare {/if} - {#if _options[serviceOptions.frontend].includes(instance)} + {#if _options[selectedFrontend].includes(instance)} chosen {/if} {#if pingCache && pingCache[instance]} @@ -189,9 +188,9 @@ class="add" aria-label="Add instance" on:click={() => { - if (_options[serviceOptions.frontend]) { - if (!_options[serviceOptions.frontend].includes(instance)) { - _options[serviceOptions.frontend].push(instance) + if (_options[selectedFrontend]) { + if (!_options[selectedFrontend].includes(instance)) { + _options[selectedFrontend].push(instance) options.set(_options) } } diff --git a/src/pages/src/Services/RedirectType.svelte b/src/pages/src/Services/RedirectType.svelte index 92b8c6d1..8cddeafb 100644 --- a/src/pages/src/Services/RedirectType.svelte +++ b/src/pages/src/Services/RedirectType.svelte @@ -46,19 +46,17 @@ } let embeddableFrontends = [] - $: (() => { - if (serviceConf) { - embeddableFrontends = [] - for (const [frontendId, frontendConf] of Object.entries(serviceConf.frontends)) { - if (frontendConf.embeddable && frontendConf.instanceList) { - embeddableFrontends.push({ - value: frontendId, - name: frontendConf.name, - }) - } + $: if (serviceConf) { + embeddableFrontends = [] + for (const [frontendId, frontendConf] of Object.entries(serviceConf.frontends)) { + if (frontendConf.embeddable && frontendConf.instanceList) { + embeddableFrontends.push({ + value: frontendId, + name: frontendConf.name, + }) } } - })() + } + import { onDestroy } from "svelte" + export let details + import { config, options } from "../stores" + let _options + let _config + + const unsubscribeOptions = options.subscribe(val => (_options = val)) + const unsubscribeConfig = config.subscribe(val => (_config = val)) + onDestroy(() => { + unsubscribeOptions() + unsubscribeConfig() + }) + + let theme + $: if (_options) { + if (_options.theme == "dark") { + theme = "dark" + } else if (_options.theme == "light") { + theme = "light" + } else if (window.matchMedia("(prefers-color-scheme: dark)").matches) { + theme = "dark" + } else { + theme = "light" + } + } + + +{#if _config.services[details.value].imageType == "svgMono"} + {#if theme == "dark"} + {details.label} + {:else} + {details.label} + {/if} +{:else} + {details.label} +{/if} diff --git a/src/pages/src/Services/Services.svelte b/src/pages/src/Services/Services.svelte index b5d9285c..7ce12ac6 100644 --- a/src/pages/src/Services/Services.svelte +++ b/src/pages/src/Services/Services.svelte @@ -1,6 +1,4 @@
@@ -33,15 +33,26 @@ Service: {serviceConf.url} - { serviceOptions.unsupportedUrls = e.target.options[e.target.options.selectedIndex].value @@ -108,12 +119,55 @@ /> {#if selectedService == "search"} -
- Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click - here. -
+ + + {/if} - + + +
+ + diff --git a/src/pages/src/Sidebar.svelte b/src/pages/src/Sidebar.svelte index be59a731..a05ac631 100644 --- a/src/pages/src/Sidebar.svelte +++ b/src/pages/src/Sidebar.svelte @@ -12,7 +12,7 @@ page.set("services")} style={$page == "services" && "color: var(--active);"}> - Services + Services diff --git a/src/pages/src/components/Select.svelte b/src/pages/src/components/Select.svelte index a0939d1f..7829c53e 100644 --- a/src/pages/src/components/Select.svelte +++ b/src/pages/src/components/Select.svelte @@ -5,7 +5,7 @@ export let ariaLabel - {#each values as option} {/each} -- cgit 1.4.1 From e6a58409ff93f9a335653bedf9870bb1f78919ce Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 25 Jul 2024 12:37:41 +0300 Subject: Made Select Frontend searchable and with icons --- src/config.json | 5 ++-- src/pages/src/App.svelte | 2 +- src/pages/src/Services/FrontendIcon.svelte | 43 ++++++++++++++++++++++++++++++ src/pages/src/Services/RedirectType.svelte | 37 ++++++++++++++++++------- src/pages/src/Services/Services.svelte | 33 ++++++++++++++++------- 5 files changed, 98 insertions(+), 22 deletions(-) create mode 100644 src/pages/src/Services/FrontendIcon.svelte (limited to 'src/pages') diff --git a/src/config.json b/src/config.json index 3f58ea95..9728cdc3 100644 --- a/src/config.json +++ b/src/config.json @@ -917,14 +917,15 @@ "simplyTranslate": { "name": "SimplyTranslate", "instanceList": true, - "url": "https://git.sr.ht/~metalune/simplytranslate_web", + "url": "https://codeberg.org/ManeraKai/simplytranslate", "localhost": true }, "mozhi": { "name": "Mozhi", "instanceList": true, "url": "https://codeberg.org/aryak/mozhi", - "localhost": false + "localhost": false, + "imageType": "svg" }, "libreTranslate": { "name": "LibreTranslate", diff --git a/src/pages/src/App.svelte b/src/pages/src/App.svelte index f24b43e0..c96d72df 100644 --- a/src/pages/src/App.svelte +++ b/src/pages/src/App.svelte @@ -103,7 +103,7 @@ div { height: 100%; display: grid; - grid-template-columns: min-content 700px; + grid-template-columns: min-content 800px; margin: 0; padding-top: 50px; justify-content: center; diff --git a/src/pages/src/Services/FrontendIcon.svelte b/src/pages/src/Services/FrontendIcon.svelte new file mode 100644 index 00000000..24942fd6 --- /dev/null +++ b/src/pages/src/Services/FrontendIcon.svelte @@ -0,0 +1,43 @@ + + +{#if imageType} + {#if imageType == "svgMono"} + {#if theme == "dark"} + {details.label} + {:else} + {details.label} + {/if} + {:else} + {details.label} + {/if} +{/if} diff --git a/src/pages/src/Services/RedirectType.svelte b/src/pages/src/Services/RedirectType.svelte index 8cddeafb..16b99083 100644 --- a/src/pages/src/Services/RedirectType.svelte +++ b/src/pages/src/Services/RedirectType.svelte @@ -2,7 +2,11 @@ import { onDestroy } from "svelte" import RowSelect from "../components/RowSelect.svelte" + import SvelteSelect from "svelte-select" import { options, config } from "../stores" + import Row from "../components/Row.svelte" + import Label from "../components/Label.svelte" + import FrontendIcon from "./FrontendIcon.svelte" let _options let _config @@ -52,7 +56,7 @@ if (frontendConf.embeddable && frontendConf.instanceList) { embeddableFrontends.push({ value: frontendId, - name: frontendConf.name, + label: frontendConf.name, }) } } @@ -70,13 +74,26 @@ /> {#if serviceConf.frontends[frontendName].desktopApp && serviceOptions.redirectType != "main_frame"} - { - serviceOptions.embedFrontend = e.target.options[e.target.options.selectedIndex].value - options.set(_options) - }} - values={embeddableFrontends} - /> + + + { + serviceOptions.embedFrontend = e.detail.value + options.set(_options) + }} + items={embeddableFrontends} + > +
+ + {item.label} +
+
+ + {selection.label} +
+
+
{/if} diff --git a/src/pages/src/Services/Services.svelte b/src/pages/src/Services/Services.svelte index 7ce12ac6..22a82195 100644 --- a/src/pages/src/Services/Services.svelte +++ b/src/pages/src/Services/Services.svelte @@ -10,6 +10,7 @@ import Instances from "./Instances.svelte" import SvelteSelect from "svelte-select" import ServiceIcon from "./ServiceIcon.svelte" + import FrontendIcon from "./FrontendIcon.svelte" let _options let _config @@ -88,19 +89,31 @@ {frontendWebsite}
- + + diff --git a/src/pages/components/Input.svelte b/src/pages/components/Input.svelte new file mode 100644 index 00000000..d963233c --- /dev/null +++ b/src/pages/components/Input.svelte @@ -0,0 +1,41 @@ + + + + + diff --git a/src/pages/components/Label.svelte b/src/pages/components/Label.svelte new file mode 100644 index 00000000..39930cd1 --- /dev/null +++ b/src/pages/components/Label.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/src/pages/components/Row.svelte b/src/pages/components/Row.svelte new file mode 100644 index 00000000..68b528e3 --- /dev/null +++ b/src/pages/components/Row.svelte @@ -0,0 +1,12 @@ +
+ +
+ + diff --git a/src/pages/components/RowCheckbox.svelte b/src/pages/components/RowCheckbox.svelte new file mode 100644 index 00000000..b7ccab93 --- /dev/null +++ b/src/pages/components/RowCheckbox.svelte @@ -0,0 +1,14 @@ + + + + + + diff --git a/src/pages/components/RowSelect.svelte b/src/pages/components/RowSelect.svelte new file mode 100644 index 00000000..d685803e --- /dev/null +++ b/src/pages/components/RowSelect.svelte @@ -0,0 +1,19 @@ + + + + + + {#each values as option} + + {/each} + + + diff --git a/src/pages/icons/AboutIcon.svelte b/src/pages/icons/AboutIcon.svelte new file mode 100644 index 00000000..e113dd68 --- /dev/null +++ b/src/pages/icons/AboutIcon.svelte @@ -0,0 +1,11 @@ + diff --git a/src/pages/icons/AddIcon.svelte b/src/pages/icons/AddIcon.svelte new file mode 100644 index 00000000..ab26f078 --- /dev/null +++ b/src/pages/icons/AddIcon.svelte @@ -0,0 +1,3 @@ + + + diff --git a/src/pages/icons/CloseIcon.svelte b/src/pages/icons/CloseIcon.svelte new file mode 100644 index 00000000..ddfb29cb --- /dev/null +++ b/src/pages/icons/CloseIcon.svelte @@ -0,0 +1,3 @@ + diff --git a/src/pages/icons/CopyIcon.svelte b/src/pages/icons/CopyIcon.svelte new file mode 100644 index 00000000..37c13f98 --- /dev/null +++ b/src/pages/icons/CopyIcon.svelte @@ -0,0 +1,12 @@ + + + diff --git a/src/pages/icons/ExportIcon.svelte b/src/pages/icons/ExportIcon.svelte new file mode 100644 index 00000000..196726a8 --- /dev/null +++ b/src/pages/icons/ExportIcon.svelte @@ -0,0 +1,5 @@ + + + diff --git a/src/pages/icons/GeneralIcon.svelte b/src/pages/icons/GeneralIcon.svelte new file mode 100644 index 00000000..b9429021 --- /dev/null +++ b/src/pages/icons/GeneralIcon.svelte @@ -0,0 +1,13 @@ + + + diff --git a/src/pages/icons/ImportIcon.svelte b/src/pages/icons/ImportIcon.svelte new file mode 100644 index 00000000..f022b4f0 --- /dev/null +++ b/src/pages/icons/ImportIcon.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/src/pages/icons/PingIcon.svelte b/src/pages/icons/PingIcon.svelte new file mode 100644 index 00000000..8fcfe27b --- /dev/null +++ b/src/pages/icons/PingIcon.svelte @@ -0,0 +1,5 @@ + + diff --git a/src/pages/icons/RedirectIcon.svelte b/src/pages/icons/RedirectIcon.svelte new file mode 100644 index 00000000..9392762a --- /dev/null +++ b/src/pages/icons/RedirectIcon.svelte @@ -0,0 +1,10 @@ + + + diff --git a/src/pages/icons/RedirectToOriginalIcon.svelte b/src/pages/icons/RedirectToOriginalIcon.svelte new file mode 100644 index 00000000..aad5c48e --- /dev/null +++ b/src/pages/icons/RedirectToOriginalIcon.svelte @@ -0,0 +1,13 @@ + + + diff --git a/src/pages/icons/ResetIcon.svelte b/src/pages/icons/ResetIcon.svelte new file mode 100644 index 00000000..0900aef8 --- /dev/null +++ b/src/pages/icons/ResetIcon.svelte @@ -0,0 +1,15 @@ + + + + diff --git a/src/pages/icons/ServicesIcon.svelte b/src/pages/icons/ServicesIcon.svelte new file mode 100644 index 00000000..ec24259b --- /dev/null +++ b/src/pages/icons/ServicesIcon.svelte @@ -0,0 +1,11 @@ + diff --git a/src/pages/icons/SettingsIcon.svelte b/src/pages/icons/SettingsIcon.svelte new file mode 100644 index 00000000..f47d078a --- /dev/null +++ b/src/pages/icons/SettingsIcon.svelte @@ -0,0 +1,12 @@ + + + diff --git a/src/pages/icons/SwitchInstanceIcon.svelte b/src/pages/icons/SwitchInstanceIcon.svelte new file mode 100644 index 00000000..6a1f96ac --- /dev/null +++ b/src/pages/icons/SwitchInstanceIcon.svelte @@ -0,0 +1,15 @@ + + + diff --git a/src/pages/options/index.html b/src/pages/options/index.html new file mode 100644 index 00000000..c3dcff71 --- /dev/null +++ b/src/pages/options/index.html @@ -0,0 +1,16 @@ + + + + + + + + Settings + + + + + + + + \ No newline at end of file diff --git a/src/pages/options/init.js b/src/pages/options/init.js index 07da1859..5a7ffb6e 100644 --- a/src/pages/options/init.js +++ b/src/pages/options/init.js @@ -1,51 +1,8 @@ window.browser = window.browser || window.chrome - import localise from "../../assets/javascripts/localise.js" -import utils from "../../assets/javascripts/utils.js" -import servicesHelper from "../../assets/javascripts/services.js" - -if (!(await utils.getOptions())) { - await servicesHelper.initDefaults() -} -async function changeTheme() { - switch ((await utils.getOptions()).theme) { - case "dark": - document.body.classList.add("dark-theme") - document.body.classList.remove("light-theme") - for (const element of document.body.getElementsByClassName("dark")) { - element.style.display = "none" - } - break - case "light": - document.body.classList.add("light-theme") - document.body.classList.remove("dark-theme") - for (const element of document.body.getElementsByClassName("light")) { - element.style.display = "none" - } - break - default: - if (matchMedia("(prefers-color-scheme: light)").matches) { - document.body.classList.add("light-theme") - document.body.classList.remove("dark-theme") - for (const element of document.body.getElementsByClassName("light")) { - element.style.display = "none" - } - } else { - document.body.classList.add("dark-theme") - document.body.classList.remove("light-theme") - for (const element of document.body.getElementsByClassName("dark")) { - element.style.display = "none" - } - } - } -} - -changeTheme() if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) { document.getElementsByTagName("body")[0].classList.add("rtl") document.getElementsByTagName("body")[0].dir = "rtl" } -localise.localisePage() - -window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", changeTheme) +localise.localisePage() \ No newline at end of file diff --git a/src/pages/options_src/App.svelte b/src/pages/options_src/App.svelte new file mode 100644 index 00000000..6bbacb9b --- /dev/null +++ b/src/pages/options_src/App.svelte @@ -0,0 +1,118 @@ + + +{#if _options && _config} +
+ + {#if _page == "general"} + + {:else if _page == "services"} + + {/if} +
+{:else} +

Loading...

+{/if} + + diff --git a/src/pages/options_src/General/Exceptions.svelte b/src/pages/options_src/General/Exceptions.svelte new file mode 100644 index 00000000..4ef5591b --- /dev/null +++ b/src/pages/options_src/General/Exceptions.svelte @@ -0,0 +1,108 @@ + + +
+ + + + +
+ { + if (e.key === "Enter") addException() + }} + /> + + + + + + + + + +
diff --git a/src/pages/options_src/Services/FrontendIcon.svelte b/src/pages/options_src/Services/FrontendIcon.svelte new file mode 100644 index 00000000..24942fd6 --- /dev/null +++ b/src/pages/options_src/Services/FrontendIcon.svelte @@ -0,0 +1,43 @@ + + +{#if imageType} + {#if imageType == "svgMono"} + {#if theme == "dark"} + {details.label} + {:else} + {details.label} + {/if} + {:else} + {details.label} + {/if} +{/if} diff --git a/src/pages/options_src/Services/Instances.svelte b/src/pages/options_src/Services/Instances.svelte new file mode 100644 index 00000000..892e395b --- /dev/null +++ b/src/pages/options_src/Services/Instances.svelte @@ -0,0 +1,233 @@ + + +{#if serviceConf.frontends[selectedFrontend].instanceList && redirects && blacklist} +
+
+
+ +
+ + + + + + + e.key === "Enter" && addInstance()} + /> + + + + {#each _options[selectedFrontend] as instance} + + + {instance} + {#if isCustomInstance(instance)} + custom + {/if} + {#if pingCache && pingCache[instance]} + {pingCache[instance].value} + {/if} + + + +
+ {/each} + + {#if redirects !== "disabled" && blacklist !== "disabled"} + {#if redirects[selectedFrontend] && redirects[selectedFrontend]["clearnet"]} + {#each Object.entries(_config.networks) as [networkName, network]} + {#if redirects[selectedFrontend] && redirects[selectedFrontend][networkName] && redirects[selectedFrontend][networkName].length > 0} + + +
+ {#each redirects[selectedFrontend][networkName] as instance} + + + {instance} + {#if blacklist.cloudflare.includes(instance)} + + cloudflare + + {/if} + {#if _options[selectedFrontend].includes(instance)} + chosen + {/if} + {#if pingCache && pingCache[instance]} + {pingCache[instance].value} + {/if} + + + +
+ {/each} + {/if} + {/each} + {:else} + + {/if} + {/if} +
+{/if} + + diff --git a/src/pages/options_src/Services/RedirectType.svelte b/src/pages/options_src/Services/RedirectType.svelte new file mode 100644 index 00000000..7f7a2843 --- /dev/null +++ b/src/pages/options_src/Services/RedirectType.svelte @@ -0,0 +1,99 @@ + + + { + serviceOptions.redirectType = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + {values} +/> + +{#if serviceConf.frontends[frontendName].desktopApp && serviceOptions.redirectType != "main_frame"} + + + { + serviceOptions.embedFrontend = e.detail.value + options.set(_options) + }} + items={embeddableFrontends} + > +
+ + {item.label} +
+
+ + {selection.label} +
+
+
+{/if} diff --git a/src/pages/options_src/Services/ServiceIcon.svelte b/src/pages/options_src/Services/ServiceIcon.svelte new file mode 100644 index 00000000..89393cf6 --- /dev/null +++ b/src/pages/options_src/Services/ServiceIcon.svelte @@ -0,0 +1,40 @@ + + +{#if imageType} + {#if imageType == "svgMono"} + {#if theme == "dark"} + {details.label} + {:else} + {details.label} + {/if} + {:else} + {details.label} + {/if} +{/if} diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte new file mode 100644 index 00000000..cb1efacb --- /dev/null +++ b/src/pages/options_src/Services/Services.svelte @@ -0,0 +1,188 @@ + + +
+ + + (selectedService = e.detail.value)} + items={[ + ...Object.entries(_config.services).map(([serviceKey, service]) => { + return { value: serviceKey, label: service.name } + }), + ]} + > +
+ + {item.label} +
+
+ + {selection.label} +
+
+
+ +
+ + { + serviceOptions.enabled = e.target.checked + options.set(_options) + }} + /> + +
+ { + if (e.target.checked && !_options.popupServices.includes(selectedService)) { + _options.popupServices.push(selectedService) + } else if (_options.popupServices.includes(selectedService)) { + const index = _options.popupServices.indexOf(selectedService) + if (index !== -1) _options.popupServices.splice(index, 1) + } + options.set(_options) + }} + /> + + + + + { + serviceOptions.frontend = e.detail.value + options.set(_options) + }} + items={[ + ...Object.entries(serviceConf.frontends).map(([frontendId, frontend]) => ({ + value: frontendId, + label: frontend.name, + })), + ]} + > +
+ + {item.label} +
+
+ + {selection.label} +
+
+
+ + + + { + serviceOptions.unsupportedUrls = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + values={[ + { value: "bypass", name: "Bypass" }, + { value: "block", name: "Block" }, + ]} + /> + + {#if selectedService == "search"} + + + + {/if} + + + + +
+
+ + diff --git a/src/pages/options_src/Sidebar.svelte b/src/pages/options_src/Sidebar.svelte new file mode 100644 index 00000000..ff44995f --- /dev/null +++ b/src/pages/options_src/Sidebar.svelte @@ -0,0 +1,43 @@ + + + + + diff --git a/src/pages/options_src/main.js b/src/pages/options_src/main.js new file mode 100644 index 00000000..c4012f4a --- /dev/null +++ b/src/pages/options_src/main.js @@ -0,0 +1,7 @@ +import App from "./App.svelte" + +const app = new App({ + target: document.body, +}) + +export default app diff --git a/src/pages/options_src/stores.js b/src/pages/options_src/stores.js new file mode 100644 index 00000000..782f6064 --- /dev/null +++ b/src/pages/options_src/stores.js @@ -0,0 +1,5 @@ +import { writable } from "svelte/store" + +export const options = writable(null) +export const config = writable(null) +export const page = writable("general") diff --git a/src/pages/popup/index.html b/src/pages/popup/index.html new file mode 100644 index 00000000..5c589bf7 --- /dev/null +++ b/src/pages/popup/index.html @@ -0,0 +1,17 @@ + + + + + + + + Settings + + + + + + + + + \ No newline at end of file diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js deleted file mode 100644 index 77a43000..00000000 --- a/src/pages/popup/popup.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict" -window.browser = window.browser || window.chrome - -import servicesHelper from "../../assets/javascripts/services.js" -import utils from "../../assets/javascripts/utils.js" - -document.getElementById("more-options").href = browser.runtime.getURL("pages/options/index.html") -document.getElementById("more-options").setAttribute("target", "_blank") - -await browser.runtime.getPlatformInfo(r => { - switch (r.os) { - case "fuchsia": - case "ios": - case "android": - document.getElementsByTagName("html")[0].classList.add("mobile") - } -}) - -const allSites = document.getElementById("all_sites") -const currSite = document.getElementById("current_site") -const currentSiteDivider = document.getElementById("current_site_divider") - -const config = await utils.getConfig() -const divs = {} - -for (const service in config.services) { - divs[service] = {} - - divs[service].all = allSites.getElementsByClassName(service)[0] - divs[service].current = currSite.getElementsByClassName(service)[0] - - divs[service].all_toggle = allSites.getElementsByClassName(`${service}-enabled`)[0] - divs[service].all_toggle.addEventListener("change", async () => { - const options = await utils.getOptions() - options[service].enabled = divs[service].all_toggle.checked - browser.storage.local.set({ options }) - }) - - allSites.getElementsByClassName(`${service}-change_instance`)[0].addEventListener("click", () => { - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - browser.tabs.update({ url: await servicesHelper.switchInstance(url, service) }) - } - }) - }) - - divs[service].current_toggle = currSite.getElementsByClassName(`${service}-enabled`)[0] - divs[service].current_toggle.addEventListener("change", async () => { - const options = await utils.getOptions() - options[service].enabled = divs[service].current_toggle.checked - browser.storage.local.set({ options }) - }) - - currSite.getElementsByClassName(`${service}-change_instance`)[0].addEventListener("click", () => { - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - browser.tabs.update({ url: await servicesHelper.switchInstance(url, service) }) - } - }) - }) -} - -browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - // Set visibility of control buttons - if (tabs[0].url) { - const hr = document.getElementById("hr") - var url = new URL(tabs[0].url) - servicesHelper.switchInstance(url).then(r => { - if (r) { - document.getElementById("change_instance_div").style.display = "" - hr.style.display = "" - document - .getElementById("change_instance") - .addEventListener("click", async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) })) - } - }) - servicesHelper.reverse(url).then(r => { - if (r) { - hr.style.display = "" - - document.getElementById("copy_original_div").style.display = "" - document.getElementById("copy_original").addEventListener("click", () => servicesHelper.copyRaw(url)) - - document.getElementById("redirect_to_original_div").style.display = "" - document - .getElementById("redirect_to_original") - .addEventListener("click", () => browser.runtime.sendMessage("reverseTab")) - } - }) - servicesHelper.redirectAsync(url, "main_frame", null, true).then(r => { - if (r) { - document.getElementById("redirect_div").style.display = "" - hr.style.display = "" - document.getElementById("redirect").addEventListener("click", () => browser.runtime.sendMessage("redirectTab")) - } - }) - } - - const options = await utils.getOptions() - - // Set visibility of all service buttons - for (const service of options.popupServices) { - divs[service].all.classList.remove("hide") - divs[service].all_toggle.checked = options[service].enabled - } - - // Set visibility of current page service button - if (url) { - const service = await servicesHelper.computeService(url) - if (service) { - divs[service].all.classList.add("hide") - divs[service].current.classList.remove("hide") - divs[service].current_toggle.checked = options[service].enabled - currentSiteDivider.style.display = "" - } - } -}) diff --git a/src/pages/popup/popup.pug b/src/pages/popup/popup.pug deleted file mode 100644 index ed4c7319..00000000 --- a/src/pages/popup/popup.pug +++ /dev/null @@ -1,53 +0,0 @@ -doctype html -html(lang="en") - head - meta(charset="UTF-8") - meta(name="viewport" content="width=device-width, initial-scale=1.0") - link(href="../stylesheets/styles.css" rel="stylesheet") - link(href="./style.css" rel="stylesheet") - body(dir="auto") - div(class="block" id="change_instance_div" style="display: none") - button(class="title button bottom-button" id="change_instance") - label(data-localise="__MSG_switchInstance__") Switch Instance - svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") - path(d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z") - - div(class="block" id="copy_original_div" title="Copy the original redirected link" style="display: none") - button(class="title button bottom-button" id="copy_original") - label() Copy Original - svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") - path(d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z") - - div(class="block" id="redirect_div" style="display: none") - button(class="title button bottom-button" id="redirect") - label Redirect - svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") - path(d="M7 20v-9q0-.825.588-1.413Q8.175 9 9 9h8.2l-1.6-1.6L17 6l4 4-4 4-1.4-1.4 1.6-1.6H9v9Z") - - div(class="block" id="redirect_to_original_div" style="display: none") - button(class="title button bottom-button" id="redirect_to_original") - label Redirect To Original - svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") - path(d="M 17,20 V 11 Q 17,10.175 16.412,9.587 15.825,9 15,9 H 6.8 L 8.4,7.4 7,6 3,10 7,14 8.4,12.6 6.8,11 H 15 v 9 z" id="path2") - - hr(id="hr" style="display: none") - - div(id="current_site") - include /src/pages/popup/switches - div(id="current_site_divider" style="display: none") - hr - - div(id="all_sites") - include /src/pages/popup/switches - - hr - - div(class="block") - a(class="title button bottom-button" id="more-options") - label(data-localise="__MSG_settings__") Settings - svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") - path(d="m9.25 22-.4-3.2q-.325-.125-.612-.3-.288-.175-.563-.375L4.7 19.375l-2.75-4.75 2.575-1.95Q4.5 12.5 4.5 12.337v-.675q0-.162.025-.337L1.95 9.375l2.75-4.75 2.975 1.25q.275-.2.575-.375.3-.175.6-.3l.4-3.2h5.5l.4 3.2q.325.125.613.3.287.175.562.375l2.975-1.25 2.75 4.75-2.575 1.95q.025.175.025.337v.675q0 .163-.05.338l2.575 1.95-2.75 4.75-2.95-1.25q-.275.2-.575.375-.3.175-.6.3l-.4 3.2Zm2.8-6.5q1.45 0 2.475-1.025Q15.55 13.45 15.55 12q0-1.45-1.025-2.475Q13.5 8.5 12.05 8.5q-1.475 0-2.488 1.025Q8.55 10.55 8.55 12q0 1.45 1.012 2.475Q10.575 15.5 12.05 15.5Z") - - div(class="space") - script(type="module" src="../options/init.js") - script(type="module" src="./popup.js") diff --git a/src/pages/popup/style.css b/src/pages/popup/style.css deleted file mode 100644 index 41510615..00000000 --- a/src/pages/popup/style.css +++ /dev/null @@ -1,65 +0,0 @@ -body { - width: 270px; - min-height: auto; -} - -html, -body { - margin: 0; -} - -.hide { - display: none !important; -} - -.button { - display: flex; - margin: 0 auto; - justify-content: space-between; -} - -.button svg { - width: 26px; - height: 26px; -} - -.bottom-button { - width: 100%; -} - -.space { - height: 10px; -} - -input { - height: 23px; - width: 46px; -} - -div.block label { - margin: 0; - font-size: 18px; - font-weight: bold; - max-width: 180px; -} - -div.block label:hover { - cursor: pointer; -} - -div.block div { - display: flex; -} - -html.mobile body { - width: 100%; -} - -html.mobile div.block label { - font-size: 24px; -} - -html.mobile .button svg { - width: 30px; - height: 30px; -} diff --git a/src/pages/popup/switches.pug b/src/pages/popup/switches.pug deleted file mode 100644 index 20ed8c61..00000000 --- a/src/pages/popup/switches.pug +++ /dev/null @@ -1,14 +0,0 @@ -each _, service in services - div(class=`${service} block hide`) - a(class="title" href=services[service].url) - if services[service].imageType == 'svgMono' - img(class='dark' src=`/assets/images/${service}-icon.svg`) - img(class='light' src=`/assets/images/${service}-icon-light.svg`) - else - img(src=`/assets/images/${service}-icon.${services[service].imageType}`) - label=services[service].name - div - input(class=`${service}-enabled` type="checkbox" aria-label=`toggle ${services[service].name}`) - button(class=`${service}-change_instance title button` aria-label=`change instance for ${services[service].name}`) - svg(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" preserveAspectRatio="xMinYMin meet" fill="currentColor") - path(d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z") \ No newline at end of file diff --git a/src/pages/popup_src/App.svelte b/src/pages/popup_src/App.svelte new file mode 100644 index 00000000..cf88234d --- /dev/null +++ b/src/pages/popup_src/App.svelte @@ -0,0 +1,114 @@ + + +{#if _options && _config} +
+ +
+{:else} +

Loading...

+{/if} + + diff --git a/src/pages/popup_src/Buttons.svelte b/src/pages/popup_src/Buttons.svelte new file mode 100644 index 00000000..39208c37 --- /dev/null +++ b/src/pages/popup_src/Buttons.svelte @@ -0,0 +1,158 @@ + + +{#if redirect} + browser.runtime.sendMessage("redirectTab")}> + + + +{/if} + +{#if switchInstance} + browser.tabs.update({ url: await servicesHelper.switchInstance(url) })}> + + + +{/if} + +{#if redirectToOriginal} + servicesHelper.copyRaw(url)}> + + + + browser.runtime.sendMessage("reverseTab")}> + + + +{/if} + +
+ +{#if currentService} + +
window.open(browser.runtime.getURL(_config.services[currentService].url), "_blank")} + > + + +
+
+ { + _options[currentService].enabled = e.target.checked + options.set(_options) + }} + /> + browser.tabs.update({ url: await servicesHelper.switchInstance(url, currentService) })} + /> +
+
+{/if} + +
+ +{#each _options.popupServices as serviceKey} + {#if currentService !== serviceKey} + +
window.open(browser.runtime.getURL(_config.services[serviceKey].url), "_blank")} + > + + +
+
+ { + console.log(e.target.checked) + _options[serviceKey].enabled = e.target.checked + options.set(_options) + }} + /> + browser.tabs.update({ url: await servicesHelper.switchInstance(url, serviceKey) })} + /> +
+
+ {/if} +{/each} + +
+ + window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> + + + + + diff --git a/src/pages/popup_src/components/PopupButton.svelte b/src/pages/popup_src/components/PopupButton.svelte new file mode 100644 index 00000000..9c4953c4 --- /dev/null +++ b/src/pages/popup_src/components/PopupButton.svelte @@ -0,0 +1,11 @@ + + + + + + diff --git a/src/pages/popup_src/components/Row.svelte b/src/pages/popup_src/components/Row.svelte new file mode 100644 index 00000000..a4d78f07 --- /dev/null +++ b/src/pages/popup_src/components/Row.svelte @@ -0,0 +1,13 @@ +
+ +
+ + + \ No newline at end of file diff --git a/src/pages/popup_src/components/ServiceIcon.svelte b/src/pages/popup_src/components/ServiceIcon.svelte new file mode 100644 index 00000000..89393cf6 --- /dev/null +++ b/src/pages/popup_src/components/ServiceIcon.svelte @@ -0,0 +1,40 @@ + + +{#if imageType} + {#if imageType == "svgMono"} + {#if theme == "dark"} + {details.label} + {:else} + {details.label} + {/if} + {:else} + {details.label} + {/if} +{/if} diff --git a/src/pages/popup_src/main.js b/src/pages/popup_src/main.js new file mode 100644 index 00000000..c4012f4a --- /dev/null +++ b/src/pages/popup_src/main.js @@ -0,0 +1,7 @@ +import App from "./App.svelte" + +const app = new App({ + target: document.body, +}) + +export default app diff --git a/src/pages/popup_src/stores.js b/src/pages/popup_src/stores.js new file mode 100644 index 00000000..782f6064 --- /dev/null +++ b/src/pages/popup_src/stores.js @@ -0,0 +1,5 @@ +import { writable } from "svelte/store" + +export const options = writable(null) +export const config = writable(null) +export const page = writable("general") diff --git a/src/pages/src/App.svelte b/src/pages/src/App.svelte deleted file mode 100644 index c96d72df..00000000 --- a/src/pages/src/App.svelte +++ /dev/null @@ -1,117 +0,0 @@ - - -{#if _options && _config} -
- - {#if _page == "general"} - - {:else if _page == "services"} - - {/if} -
-{:else} -

Loading...

-{/if} - - diff --git a/src/pages/src/General/Exceptions.svelte b/src/pages/src/General/Exceptions.svelte deleted file mode 100644 index e43afaf6..00000000 --- a/src/pages/src/General/Exceptions.svelte +++ /dev/null @@ -1,108 +0,0 @@ - - -
- - - - -
- { - if (e.key === "Enter") addException() - }} - /> - - - - - - - - - -
diff --git a/src/pages/src/Services/FrontendIcon.svelte b/src/pages/src/Services/FrontendIcon.svelte deleted file mode 100644 index 24942fd6..00000000 --- a/src/pages/src/Services/FrontendIcon.svelte +++ /dev/null @@ -1,43 +0,0 @@ - - -{#if imageType} - {#if imageType == "svgMono"} - {#if theme == "dark"} - {details.label} - {:else} - {details.label} - {/if} - {:else} - {details.label} - {/if} -{/if} diff --git a/src/pages/src/Services/Instances.svelte b/src/pages/src/Services/Instances.svelte deleted file mode 100644 index 39d61f26..00000000 --- a/src/pages/src/Services/Instances.svelte +++ /dev/null @@ -1,233 +0,0 @@ - - -{#if serviceConf.frontends[selectedFrontend].instanceList && redirects && blacklist} -
-
-
- -
- - - - - - - e.key === "Enter" && addInstance()} - /> - - - - {#each _options[selectedFrontend] as instance} - - - {instance} - {#if isCustomInstance(instance)} - custom - {/if} - {#if pingCache && pingCache[instance]} - {pingCache[instance].value} - {/if} - - - -
- {/each} - - {#if redirects !== "disabled" && blacklist !== "disabled"} - {#if redirects[selectedFrontend] && redirects[selectedFrontend]["clearnet"]} - {#each Object.entries(_config.networks) as [networkName, network]} - {#if redirects[selectedFrontend] && redirects[selectedFrontend][networkName] && redirects[selectedFrontend][networkName].length > 0} - - -
- {#each redirects[selectedFrontend][networkName] as instance} - - - {instance} - {#if blacklist.cloudflare.includes(instance)} - - cloudflare - - {/if} - {#if _options[selectedFrontend].includes(instance)} - chosen - {/if} - {#if pingCache && pingCache[instance]} - {pingCache[instance].value} - {/if} - - - -
- {/each} - {/if} - {/each} - {:else} - - {/if} - {/if} -
-{/if} - - diff --git a/src/pages/src/Services/RedirectType.svelte b/src/pages/src/Services/RedirectType.svelte deleted file mode 100644 index 16b99083..00000000 --- a/src/pages/src/Services/RedirectType.svelte +++ /dev/null @@ -1,99 +0,0 @@ - - - { - serviceOptions.redirectType = e.target.options[e.target.options.selectedIndex].value - options.set(_options) - }} - {values} -/> - -{#if serviceConf.frontends[frontendName].desktopApp && serviceOptions.redirectType != "main_frame"} - - - { - serviceOptions.embedFrontend = e.detail.value - options.set(_options) - }} - items={embeddableFrontends} - > -
- - {item.label} -
-
- - {selection.label} -
-
-
-{/if} diff --git a/src/pages/src/Services/ServiceIcon.svelte b/src/pages/src/Services/ServiceIcon.svelte deleted file mode 100644 index 0779c02b..00000000 --- a/src/pages/src/Services/ServiceIcon.svelte +++ /dev/null @@ -1,37 +0,0 @@ - - -{#if _config.services[details.value].imageType == "svgMono"} - {#if theme == "dark"} - {details.label} - {:else} - {details.label} - {/if} -{:else} - {details.label} -{/if} diff --git a/src/pages/src/Services/Services.svelte b/src/pages/src/Services/Services.svelte deleted file mode 100644 index 22a82195..00000000 --- a/src/pages/src/Services/Services.svelte +++ /dev/null @@ -1,188 +0,0 @@ - - -
- - - (selectedService = e.detail.value)} - items={[ - ...Object.entries(_config.services).map(([serviceKey, service]) => { - return { value: serviceKey, label: service.name } - }), - ]} - > -
- - {item.label} -
-
- - {selection.label} -
-
-
- -
- - { - serviceOptions.enabled = e.target.checked - options.set(_options) - }} - /> - -
- { - if (e.target.checked && !_options.popupServices.includes(selectedService)) { - _options.popupServices.push(selectedService) - } else if (_options.popupServices.includes(selectedService)) { - const index = _options.popupServices.indexOf(selectedService) - if (index !== -1) _options.popupServices.splice(index, 1) - } - options.set(_options) - }} - /> - - - - - { - serviceOptions.frontend = e.detail.value - options.set(_options) - }} - items={[ - ...Object.entries(serviceConf.frontends).map(([frontendId, frontend]) => ({ - value: frontendId, - label: frontend.name, - })), - ]} - > -
- - {item.label} -
-
- - {selection.label} -
-
-
- - - - { - serviceOptions.unsupportedUrls = e.target.options[e.target.options.selectedIndex].value - options.set(_options) - }} - values={[ - { value: "bypass", name: "Bypass" }, - { value: "block", name: "Block" }, - ]} - /> - - {#if selectedService == "search"} - - - - {/if} - - - - -
-
- - diff --git a/src/pages/src/Sidebar.svelte b/src/pages/src/Sidebar.svelte deleted file mode 100644 index a05ac631..00000000 --- a/src/pages/src/Sidebar.svelte +++ /dev/null @@ -1,43 +0,0 @@ - - - - - diff --git a/src/pages/src/components/Button.svelte b/src/pages/src/components/Button.svelte deleted file mode 100644 index 3405c2ea..00000000 --- a/src/pages/src/components/Button.svelte +++ /dev/null @@ -1,29 +0,0 @@ - - - diff --git a/src/pages/src/components/Checkbox.svelte b/src/pages/src/components/Checkbox.svelte deleted file mode 100644 index f5245045..00000000 --- a/src/pages/src/components/Checkbox.svelte +++ /dev/null @@ -1,52 +0,0 @@ - - - - - diff --git a/src/pages/src/components/Input.svelte b/src/pages/src/components/Input.svelte deleted file mode 100644 index d963233c..00000000 --- a/src/pages/src/components/Input.svelte +++ /dev/null @@ -1,41 +0,0 @@ - - - - - diff --git a/src/pages/src/components/Label.svelte b/src/pages/src/components/Label.svelte deleted file mode 100644 index 39930cd1..00000000 --- a/src/pages/src/components/Label.svelte +++ /dev/null @@ -1,18 +0,0 @@ - - - - - diff --git a/src/pages/src/components/Row.svelte b/src/pages/src/components/Row.svelte deleted file mode 100644 index 4f23cffa..00000000 --- a/src/pages/src/components/Row.svelte +++ /dev/null @@ -1,12 +0,0 @@ -
- -
- - diff --git a/src/pages/src/components/RowCheckbox.svelte b/src/pages/src/components/RowCheckbox.svelte deleted file mode 100644 index b7ccab93..00000000 --- a/src/pages/src/components/RowCheckbox.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - diff --git a/src/pages/src/components/RowSelect.svelte b/src/pages/src/components/RowSelect.svelte deleted file mode 100644 index d685803e..00000000 --- a/src/pages/src/components/RowSelect.svelte +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - {#each values as option} - - {/each} - - - diff --git a/src/pages/src/icons/AboutIcon.svelte b/src/pages/src/icons/AboutIcon.svelte deleted file mode 100644 index e113dd68..00000000 --- a/src/pages/src/icons/AboutIcon.svelte +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/src/pages/src/icons/AddIcon.svelte b/src/pages/src/icons/AddIcon.svelte deleted file mode 100644 index ab26f078..00000000 --- a/src/pages/src/icons/AddIcon.svelte +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/pages/src/icons/CloseIcon.svelte b/src/pages/src/icons/CloseIcon.svelte deleted file mode 100644 index ddfb29cb..00000000 --- a/src/pages/src/icons/CloseIcon.svelte +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/src/pages/src/icons/ExportIcon.svelte b/src/pages/src/icons/ExportIcon.svelte deleted file mode 100644 index 196726a8..00000000 --- a/src/pages/src/icons/ExportIcon.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/src/pages/src/icons/GeneralIcon.svelte b/src/pages/src/icons/GeneralIcon.svelte deleted file mode 100644 index b9429021..00000000 --- a/src/pages/src/icons/GeneralIcon.svelte +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/src/pages/src/icons/ImportIcon.svelte b/src/pages/src/icons/ImportIcon.svelte deleted file mode 100644 index f022b4f0..00000000 --- a/src/pages/src/icons/ImportIcon.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/src/pages/src/icons/PingIcon.svelte b/src/pages/src/icons/PingIcon.svelte deleted file mode 100644 index 8fcfe27b..00000000 --- a/src/pages/src/icons/PingIcon.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/src/pages/src/icons/ResetIcon.svelte b/src/pages/src/icons/ResetIcon.svelte deleted file mode 100644 index 0900aef8..00000000 --- a/src/pages/src/icons/ResetIcon.svelte +++ /dev/null @@ -1,15 +0,0 @@ - - - - diff --git a/src/pages/src/icons/ServicesIcon.svelte b/src/pages/src/icons/ServicesIcon.svelte deleted file mode 100644 index ec24259b..00000000 --- a/src/pages/src/icons/ServicesIcon.svelte +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/src/pages/src/main.js b/src/pages/src/main.js deleted file mode 100644 index c4012f4a..00000000 --- a/src/pages/src/main.js +++ /dev/null @@ -1,7 +0,0 @@ -import App from "./App.svelte" - -const app = new App({ - target: document.body, -}) - -export default app diff --git a/src/pages/src/stores.js b/src/pages/src/stores.js deleted file mode 100644 index 782f6064..00000000 --- a/src/pages/src/stores.js +++ /dev/null @@ -1,5 +0,0 @@ -import { writable } from "svelte/store" - -export const options = writable(null) -export const config = writable(null) -export const page = writable("general") diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index ca6f0dca..9e8fedb3 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -1,12 +1,3 @@ -body { - --text: #fff; - --bg-main: #121212; - --bg-secondary: #202020; - --active: #fbc117; - --danger: #f04141; - --light-grey: #c3c3c3; -} - @font-face { font-family: "Inter"; src: url("Inter-VariableFont_slnt,wght.ttf"); @@ -21,359 +12,7 @@ body { font-style: normal; } -body { - margin: auto; - padding: 0; - font-family: "Inter"; - font-size: 16px; - background-color: var(--bg-main); - color: var(--text); -} - -body * { - font-family: "Inter"; -} - -body.rtl { - font-family: "Vazirmatn"; -} - -body.rtl * { - font-family: "Vazirmatn"; -} - -div.block input[type="checkbox"] { - appearance: none; - -moz-appearance: none; - -webkit-appearance: none; -} - -.title { - display: flex; - align-items: center; - text-decoration: none; - width: min-content; - color: var(--text); - transition: 0.1s; -} - -.title:hover { - opacity: 1 !important; -} - -.title:hover a { - color: var(--active); -} - -img, -svg { - margin-right: 10px; - height: 26px; - width: 26px; - color: var(--text); -} - -body.rtl img, -body.rtl svg { - margin-right: 0px; - margin-left: 10px; -} - -input[type="url"], -input[type="text"], -select { - font-weight: bold; - box-sizing: border-box; - border-style: solid; - border-color: #767676; - color: var(--text); - font-size: 16px; - padding: 8px; - background-color: var(--bg-secondary); - border: none; - margin: 0; - max-width: 500px; - border-radius: 3px; -} - -input[type="url"], -input[type="text"] { - width: 400px; - cursor: text; -} - -input:invalid { - color: var(--danger); -} - -.button svg { - height: 18px; - width: 18px; -} - -section.block-option { - width: 750px; - margin: 0 50px; -} - -section.block-option h2 { - margin: 0; -} - -body.option { - display: flex; - padding: 40px; - width: 1160px; -} - -section.links { - display: flex; - flex-wrap: wrap; - flex-direction: column; - width: 350px; - max-height: 1030px; -} - -section.links div { - margin: 10px; - width: max-content; -} - -a { - text-decoration: none; - color: var(--text); - transition: 0.1s; -} - -a:hover { - color: var(--active); -} - -section.links a { - display: flex; - align-items: center; - font-size: 18px; - text-decoration: none; - color: white; - transition: 0.1s; -} - -section.links a:hover, -section.links .selected { - opacity: 1 !important; -} - -section.links .selected a { - color: var(--active); -} - -::placeholder { - color: var(--text); - opacity: 0.7; -} - -hr { - height: 2px; - margin: 0 15px; - background-color: rgb(77, 77, 77); - border: none; -} - -div.block { - padding: 0 15px; - justify-content: space-between; - display: flex; - align-items: center; - margin-top: 10px; - margin-bottom: 10px; -} - -div.block-option { - margin: 30px 0; -} - -div.block-option label { - margin-right: 5px; - width: 80%; - min-width: 150px; - font-size: 18px; -} - -div.block-option h1 { - margin: 0; - font-size: 28px; - color: var(--text); -} - -div.block-option div { - text-align: center; -} - -div.block input[type="checkbox"] { - width: 46px; - height: 24px; - background-color: var(--light-grey); - border-radius: 50px; - transition: 0.4s; - cursor: pointer; -} - -div.block input[type="checkbox"]:checked { - background-color: var(--active); -} - -div.block input[type="checkbox"]::before { - content: ""; - display: inline-block; - width: 18px; - height: 18px; - box-sizing: border-box; - position: relative; - top: 2.5px; - left: 3.5px; - background-color: white; - border-radius: 50%; - transition: 0.3s; -} - -body.rtl div.block input[type="checkbox"]::before { - left: auto; - right: 4px; -} - -div.block input[type="checkbox"]:checked::before { - left: 24px; -} - -body.rtl div.block input[type="checkbox"]:checked::before { - left: auto; - right: 24px; -} - -div.buttons { - display: flex; - margin: 0 15px; - margin-bottom: 15px; - margin-top: 15px; - flex-wrap: wrap; - align-items: center; - justify-content: start; -} - -.button { - color: var(--text); - font-size: 16px; - font-weight: bold; - text-decoration: none; - cursor: pointer; - transition-duration: 0.1s; -} - -.button:hover { - color: var(--active); -} - -.button svg { - width: auto; - height: auto; - padding: 0; - margin-right: 5px; -} - -.button:hover svg { - color: var(--active); -} - -.button-inline { - display: inline-flex; - align-items: center; - margin: 7.5px 0; - background-color: var(--bg-secondary); - border-radius: 5px; - padding: 10px; -} - -.button:active { - transform: translateY(1px); -} - -button svg { - color: var(--text); -} - -div.checklist div { - justify-content: space-between; - margin: 5px 15px; - padding: 10px 0; - word-wrap: break-word; - display: flex; -} - -div.checklist a { - text-decoration: none; - color: var(--text); -} - -div.checklist a:hover { - text-decoration: underline; -} - -div.custom-checklist x a { - color: var(--active); -} - -button.add { - background-color: transparent; - border: none; - padding: 0; - margin: 0; - text-decoration: none; - display: inline-block; - cursor: pointer; -} - -body.light-theme { - --text: black; - --bg-main: white; - --bg-secondary: #e4e4e4; - --active: #fb9817; -} - -body.light-theme select { - border: 1px solid black; -} - -body.light-theme a { - color: black; -} - -body.light-theme a:hover { - color: var(--active); -} - -button { - background-color: transparent; - color: var(--text); - border: none; - text-decoration: none; - display: inline-block; - cursor: pointer; - border-radius: 5px; -} - -body div section { - display: none; -} - -select:disabled { - opacity: 0.6; - cursor: not-allowed; -} - -input:disabled { - opacity: 0.6; - cursor: not-allowed; -} +/* @media (max-width: 1250px) { body.option { @@ -446,4 +85,4 @@ html.mobile section.links { html.mobile section.block-option { width: 100%; -} +} */ \ No newline at end of file -- cgit 1.4.1 From f047a1d02def5158cfa845f923da554f6649247e Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 25 Jul 2024 16:35:18 +0300 Subject: Improved code --- src/pages/popup_src/Buttons.svelte | 86 +++++------------------ src/pages/popup_src/components/PopupButton.svelte | 11 --- src/pages/popup_src/components/Switch.svelte | 58 +++++++++++++++ 3 files changed, 77 insertions(+), 78 deletions(-) delete mode 100644 src/pages/popup_src/components/PopupButton.svelte create mode 100644 src/pages/popup_src/components/Switch.svelte (limited to 'src/pages') diff --git a/src/pages/popup_src/Buttons.svelte b/src/pages/popup_src/Buttons.svelte index 39208c37..449404ba 100644 --- a/src/pages/popup_src/Buttons.svelte +++ b/src/pages/popup_src/Buttons.svelte @@ -9,10 +9,9 @@ import SwitchInstanceIcon from "../icons/SwitchInstanceIcon.svelte" import SettingsIcon from "../icons/SettingsIcon.svelte" import { options, config } from "./stores" - import ServiceIcon from "./components/ServiceIcon.svelte" import { onDestroy } from "svelte" import servicesHelper from "../../assets/javascripts/services" - import Checkbox from "../components/Checkbox.svelte" + import Switch from "./components/Switch.svelte" let _options let _config @@ -35,117 +34,70 @@ servicesHelper.switchInstance(url).then(r => (switchInstance = r)) servicesHelper.reverse(url).then(r => (redirectToOriginal = r)) servicesHelper.redirectAsync(url, "main_frame", null, true).then(r => (redirect = r)) - currentService = await servicesHelper.computeService(url) + servicesHelper.computeService(url).then(r => (currentService = r)) } }) {#if redirect} - browser.runtime.sendMessage("redirectTab")}> + browser.runtime.sendMessage("redirectTab")}> {/if} {#if switchInstance} - browser.tabs.update({ url: await servicesHelper.switchInstance(url) })}> + browser.tabs.update({ url: await servicesHelper.switchInstance(url) })} + > {/if} {#if redirectToOriginal} - servicesHelper.copyRaw(url)}> + servicesHelper.copyRaw(url)}> - browser.runtime.sendMessage("reverseTab")}> + browser.runtime.sendMessage("reverseTab")}> {/if} -
+{#if redirect || switchInstance || redirectToOriginal} +
+{/if} {#if currentService} - -
window.open(browser.runtime.getURL(_config.services[currentService].url), "_blank")} - > - - -
-
- { - _options[currentService].enabled = e.target.checked - options.set(_options) - }} - /> - browser.tabs.update({ url: await servicesHelper.switchInstance(url, currentService) })} - /> -
-
+ +
{/if} -
- {#each _options.popupServices as serviceKey} {#if currentService !== serviceKey} - -
window.open(browser.runtime.getURL(_config.services[serviceKey].url), "_blank")} - > - - -
-
- { - console.log(e.target.checked) - _options[serviceKey].enabled = e.target.checked - options.set(_options) - }} - /> - browser.tabs.update({ url: await servicesHelper.switchInstance(url, serviceKey) })} - /> -
-
+ {/if} {/each}
- window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> + window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> -- cgit 1.4.1 From 2cb60e91cd33ea63dc43b7afb2ce7a261bce6512 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 26 Jul 2024 17:39:22 +0300 Subject: Added mobile support in Svelte --- package.json | 2 +- src/assets/javascripts/utils.js | 8 -- src/pages/components/Input.svelte | 5 ++ src/pages/components/RowCheckbox.svelte | 14 ---- src/pages/components/RowSelect.svelte | 19 ----- src/pages/fonts/Inter-VariableFont_slnt,wght.ttf | Bin 0 -> 803384 bytes src/pages/fonts/Vazirmatn-VariableFont_wght.ttf | Bin 0 -> 285620 bytes src/pages/fonts/styles.css | 13 +++ src/pages/options/index.html | 1 + src/pages/options_src/App.svelte | 20 ++++- src/pages/options_src/General/General.svelte | 89 ++++++++++++--------- src/pages/options_src/Services/Instances.svelte | 5 +- src/pages/options_src/Services/RedirectType.svelte | 23 +++--- src/pages/options_src/Services/Services.svelte | 71 ++++++++-------- src/pages/options_src/Sidebar.svelte | 14 ++++ src/pages/popup/index.html | 2 +- .../stylesheets/Inter-VariableFont_slnt,wght.ttf | Bin 803384 -> 0 bytes .../stylesheets/Vazirmatn-VariableFont_wght.ttf | Bin 285620 -> 0 bytes src/pages/stylesheets/styles.css | 88 -------------------- 19 files changed, 157 insertions(+), 217 deletions(-) delete mode 100644 src/pages/components/RowCheckbox.svelte delete mode 100644 src/pages/components/RowSelect.svelte create mode 100644 src/pages/fonts/Inter-VariableFont_slnt,wght.ttf create mode 100644 src/pages/fonts/Vazirmatn-VariableFont_wght.ttf create mode 100644 src/pages/fonts/styles.css delete mode 100644 src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf delete mode 100644 src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf delete mode 100644 src/pages/stylesheets/styles.css (limited to 'src/pages') diff --git a/package.json b/package.json index d0669a69..0f89cbdb 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "start": "web-ext run", "nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox", - "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix", + "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix ", "build": "web-ext build", "test": "web-ext lint", "html": "rollup -c --config-popup && rollup -c --config-options" diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js index 439826dd..18168e90 100644 --- a/src/assets/javascripts/utils.js +++ b/src/assets/javascripts/utils.js @@ -20,13 +20,6 @@ function getNextInstance(currentInstanceUrl, instances) { return instances[nextInstanceIndex] } -/** - * @param {string} str - */ -function camelCase(str) { - return str.charAt(0).toUpperCase() + str.slice(1) -} - /** * @param {URL} url */ @@ -178,7 +171,6 @@ export default { protocolHost, getList, getBlacklist, - camelCase, getConfig, getOptions, getPingCache, diff --git a/src/pages/components/Input.svelte b/src/pages/components/Input.svelte index d963233c..97a47e6d 100644 --- a/src/pages/components/Input.svelte +++ b/src/pages/components/Input.svelte @@ -38,4 +38,9 @@ input:focus { outline-color: var(--active); } + @media (max-width: 715px) { + input { + width: 200px; + } + } diff --git a/src/pages/components/RowCheckbox.svelte b/src/pages/components/RowCheckbox.svelte deleted file mode 100644 index b7ccab93..00000000 --- a/src/pages/components/RowCheckbox.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - diff --git a/src/pages/components/RowSelect.svelte b/src/pages/components/RowSelect.svelte deleted file mode 100644 index d685803e..00000000 --- a/src/pages/components/RowSelect.svelte +++ /dev/null @@ -1,19 +0,0 @@ - - - - - { + _options.theme = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + ariaLabel="select theme" + /> + - { - _options["fetchInstances"] = e.target.options[e.target.options.selectedIndex].value - options.set(_options) - }} - ariaLabel="Select fetch public instances" - values={[ - { value: "github", name: "GitHub" }, - { value: "codeberg", name: "Codeberg" }, - { value: "disable", name: "Disable" }, - ]} - /> + + + { + serviceOptions.redirectType = e.target.options[e.target.options.selectedIndex].value + options.set(_options) + }} + {values} + /> + {#if serviceConf.frontends[frontendName].desktopApp && serviceOptions.redirectType != "main_frame"} diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index cb1efacb..9c4e6c97 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -1,6 +1,4 @@ diff --git a/src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf b/src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf deleted file mode 100644 index 969a990f..00000000 Binary files a/src/pages/stylesheets/Inter-VariableFont_slnt,wght.ttf and /dev/null differ diff --git a/src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf b/src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf deleted file mode 100644 index f4b97c01..00000000 Binary files a/src/pages/stylesheets/Vazirmatn-VariableFont_wght.ttf and /dev/null differ diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css deleted file mode 100644 index 9e8fedb3..00000000 --- a/src/pages/stylesheets/styles.css +++ /dev/null @@ -1,88 +0,0 @@ -@font-face { - font-family: "Inter"; - src: url("Inter-VariableFont_slnt,wght.ttf"); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: "Vazirmatn"; - src: url("Vazirmatn-VariableFont_wght.ttf"); - font-weight: normal; - font-style: normal; -} - -/* - -@media (max-width: 1250px) { - body.option { - flex-direction: column; - width: 95vw; - align-items: center; - padding: 40px 0px; - } - - section.links { - flex-direction: row; - width: 95vw; - padding: 0 55px; - } - - section.block-option { - width: 95vw; - } - - div.checklist div x { - overflow: hidden; - } -} - -html.mobile img, -html.mobile svg { - margin-right: 10px; - height: 30px; - width: 30px; - color: var(--text); -} - -html.mobile div.block { - padding: 0 15px; - justify-content: space-between; - display: flex; - align-items: center; - margin-top: 20px; - margin-bottom: 20px; -} - -html.mobile div.block input[type="checkbox"] { - width: 58px; - height: 30px; -} - -html.mobile div.block input[type="checkbox"]::before { - width: 24px; - height: 24px; - top: 3px; - left: 3.5px; -} - -html.mobile div.block input[type="checkbox"]:checked::before { - left: 30px; -} - -html.mobile body.option { - flex-direction: column; - width: 100%; - padding: 0; - align-items: center; -} - -html.mobile section.links { - flex-direction: row; - width: 100%; - padding: 0 55px; -} - -html.mobile section.block-option { - width: 100%; -} */ \ No newline at end of file -- cgit 1.4.1 From e97b618660094491013d9d4999ac4802429f3dc7 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 26 Jul 2024 23:53:31 +0300 Subject: Added translation support to Svelte --- package.json | 1 + src/assets/javascripts/localise.js | 34 ------ src/pages/components/Checkbox.svelte | 19 ++-- src/pages/icons/ExportIcon.svelte | 9 +- src/pages/icons/ImportIcon.svelte | 17 ++- src/pages/icons/PingIcon.svelte | 9 +- src/pages/icons/ResetIcon.svelte | 1 + src/pages/options/init.js | 8 -- src/pages/options_src/App.svelte | 9 +- src/pages/options_src/General/Exceptions.svelte | 10 +- src/pages/options_src/General/General.svelte | 18 ++-- .../options_src/General/SettingsButtons.svelte | 31 ++++-- src/pages/options_src/Services/Instances.svelte | 32 +++--- src/pages/options_src/Services/RedirectType.svelte | 12 ++- src/pages/options_src/Services/Services.svelte | 115 +++++++++++---------- src/pages/options_src/Sidebar.svelte | 23 +++-- src/pages/popup_src/App.svelte | 2 +- src/pages/popup_src/Buttons.svelte | 94 +++++++++-------- src/pages/popup_src/components/Switch.svelte | 13 ++- 19 files changed, 251 insertions(+), 206 deletions(-) delete mode 100644 src/assets/javascripts/localise.js delete mode 100644 src/pages/options/init.js (limited to 'src/pages') diff --git a/package.json b/package.json index 0f89cbdb..2a79b660 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts": { "start": "web-ext run", "nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox", + "start_ar": "web-ext run --firefox=/home/esmail/software/firefox_ar/firefox", "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix ", "build": "web-ext build", "test": "web-ext lint", diff --git a/src/assets/javascripts/localise.js b/src/assets/javascripts/localise.js deleted file mode 100644 index d26d07d4..00000000 --- a/src/assets/javascripts/localise.js +++ /dev/null @@ -1,34 +0,0 @@ -window.browser = window.browser || window.chrome - -function localisePage() { - /** - * @param {string} tag - */ - function getMessage(tag) { - return tag.replace(/__MSG_(\w+)__/g, (_match, v1) => { - return v1 ? browser.i18n.getMessage(v1) : null - }) - } - - const elements = document.querySelectorAll("[data-localise]") - for (let i in elements) - if (elements.hasOwnProperty(i)) { - const obj = elements[i] - const tag = obj.getAttribute("data-localise").toString() - const msg = getMessage(tag) - if (msg && msg !== tag) obj.textContent = msg - } - - const placeholders = document.querySelectorAll("[data-localise-placeholder]") - for (let i in placeholders) - if (placeholders.hasOwnProperty(i)) { - const obj = placeholders[i] - const tag = obj.getAttribute("data-localise-placeholder").toString() - const msg = getMessage(tag) - if (msg && msg !== tag) obj.placeholder = msg - } -} - -export default { - localisePage, -} diff --git a/src/pages/components/Checkbox.svelte b/src/pages/components/Checkbox.svelte index dbefd7e9..9ba9c56c 100644 --- a/src/pages/components/Checkbox.svelte +++ b/src/pages/components/Checkbox.svelte @@ -1,9 +1,10 @@ - + diff --git a/src/pages/icons/ExportIcon.svelte b/src/pages/icons/ExportIcon.svelte index 196726a8..d155e5c5 100644 --- a/src/pages/icons/ExportIcon.svelte +++ b/src/pages/icons/ExportIcon.svelte @@ -1,4 +1,11 @@ - + diff --git a/src/pages/icons/ImportIcon.svelte b/src/pages/icons/ImportIcon.svelte index f022b4f0..f64d0ff6 100644 --- a/src/pages/icons/ImportIcon.svelte +++ b/src/pages/icons/ImportIcon.svelte @@ -1,5 +1,12 @@ - - - \ No newline at end of file + + + diff --git a/src/pages/icons/PingIcon.svelte b/src/pages/icons/PingIcon.svelte index 8fcfe27b..34c4a37d 100644 --- a/src/pages/icons/PingIcon.svelte +++ b/src/pages/icons/PingIcon.svelte @@ -1,4 +1,11 @@ - + - let browser = window.browser || window.chrome + const browser = window.browser || window.chrome import General from "./General/General.svelte" import utils from "../../assets/javascripts/utils.js" @@ -67,12 +67,15 @@ cssVariables = light } } + + const dir = ["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage()) ? "rtl" : "ltr" + document.body.dir = dir {#if _options && _config}
-
- - - + + + +
- let browser = window.browser || window.chrome + const browser = window.browser || window.chrome import Exceptions from "./Exceptions.svelte" import SettingsButtons from "./SettingsButtons.svelte" @@ -26,12 +26,12 @@
- + { _options.fetchInstances = e.target.options[e.target.options.selectedIndex].value @@ -60,7 +60,7 @@ - + { @@ -71,7 +71,7 @@ - + diff --git a/src/pages/options_src/General/SettingsButtons.svelte b/src/pages/options_src/General/SettingsButtons.svelte index c37a3702..3ea46a2d 100644 --- a/src/pages/options_src/General/SettingsButtons.svelte +++ b/src/pages/options_src/General/SettingsButtons.svelte @@ -1,5 +1,5 @@ - + { @@ -130,8 +136,8 @@ options.set(_options) }} values={[ - { value: "bypass", name: "Bypass" }, - { value: "block", name: "Block" }, + { value: "bypass", name: browser.i18n.getMessage("bypass") || "Bypass" }, + { value: "block", name: browser.i18n.getMessage("block") || "Block" }, ]} /> @@ -139,13 +145,14 @@ {#if selectedService == "search"} {/if} @@ -184,8 +191,10 @@ justify-content: start; align-items: center; } + :global(.svelte_select img, .svelte_select svg) { margin-right: 10px; + margin-left: 0; height: 26px; width: 26px; color: var(--text); diff --git a/src/pages/options_src/Sidebar.svelte b/src/pages/options_src/Sidebar.svelte index 4a808268..fb515f53 100644 --- a/src/pages/options_src/Sidebar.svelte +++ b/src/pages/options_src/Sidebar.svelte @@ -1,4 +1,6 @@ -{#if redirect} - browser.runtime.sendMessage("redirectTab")}> - - - -{/if} - -{#if switchInstance} - browser.tabs.update({ url: await servicesHelper.switchInstance(url) })} - > - - - -{/if} +
+ {#if redirect} + browser.runtime.sendMessage("redirectTab")}> + + + + {/if} -{#if redirectToOriginal} - servicesHelper.copyRaw(url)}> - - - - browser.runtime.sendMessage("reverseTab")}> - - - -{/if} + {#if switchInstance} + browser.tabs.update({ url: await servicesHelper.switchInstance(url) })} + > + + + + {/if} -{#if redirect || switchInstance || redirectToOriginal} -
-{/if} + {#if redirectToOriginal} + servicesHelper.copyRaw(url)}> + + + + browser.runtime.sendMessage("reverseTab")}> + + + + {/if} -{#if currentService} - -
-{/if} + {#if redirect || switchInstance || redirectToOriginal} +
+ {/if} -{#each _options.popupServices as serviceKey} - {#if currentService !== serviceKey} - + {#if currentService} + +
{/if} -{/each} -
+ {#each _options.popupServices as serviceKey} + {#if currentService !== serviceKey} + + {/if} + {/each} + +
- window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> - - - + window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> + + + +
diff --git a/src/pages/popup_src/components/Switch.svelte b/src/pages/popup_src/components/Switch.svelte index f420caa1..e581e5f4 100644 --- a/src/pages/popup_src/components/Switch.svelte +++ b/src/pages/popup_src/components/Switch.svelte @@ -1,5 +1,5 @@ +
diff --git a/src/pages/options_src/General/General.svelte b/src/pages/options_src/General/General.svelte index 732ad83b..37c38a0a 100644 --- a/src/pages/options_src/General/General.svelte +++ b/src/pages/options_src/General/General.svelte @@ -38,7 +38,6 @@ _options.theme = e.target.options[e.target.options.selectedIndex].value options.set(_options) }} - ariaLabel="select theme" /> @@ -55,7 +54,6 @@ _options.fetchInstances = e.target.options[e.target.options.selectedIndex].value options.set(_options) }} - ariaLabel={"Select fetch public instances"} /> @@ -75,7 +73,7 @@ - + - +
diff --git a/src/pages/options_src/General/SettingsButtons.svelte b/src/pages/options_src/General/SettingsButtons.svelte index 3ea46a2d..2f574199 100644 --- a/src/pages/options_src/General/SettingsButtons.svelte +++ b/src/pages/options_src/General/SettingsButtons.svelte @@ -14,24 +14,18 @@ const unsubscribe = options.subscribe(val => (_options = val)) onDestroy(unsubscribe) - let disableButtons = false - let importSettingsInput let importSettingsFiles $: if (importSettingsFiles) { - disableButtons = true const reader = new FileReader() reader.readAsText(importSettingsFiles[0]) reader.onload = async () => { const data = JSON.parse(reader.result) if ("theme" in data && data.version == browser.runtime.getManifest().version) { browser.storage.local.clear(async () => { - console.log("clearing") options.set(data) - disableButtons = false }) } else { - console.log("incompatible settings") alert("Incompatible settings") } } @@ -42,26 +36,21 @@ } async function exportSettings() { - disableButtons = true _options.version = browser.runtime.getManifest().version const resultString = JSON.stringify(_options, null, " ") const anchor = document.createElement("a") anchor.href = "data:application/json;base64," + btoa(resultString) anchor.download = `libredirect-settings-v${_options.version}.json` anchor.click() - disableButtons = false } async function exportSettingsSync() { - disableButtons = true _options.version = browser.runtime.getManifest().version await servicesHelper.initDefaults() browser.storage.sync.set({ options: _options }) - disableButtons = false } async function importSettingsSync() { - disableButtons = true browser.storage.sync.get({ options }, r => { const optionsSync = r.options if (optionsSync.version == browser.runtime.getManifest().version) { @@ -69,24 +58,21 @@ } else { alert("Error") } - disableButtons = false }) } async function resetSettings() { - disableButtons = true browser.storage.local.clear(async () => { await servicesHelper.initDefaults() options.set(await utils.getOptions()) - disableButtons = false }) }
- - - - -
diff --git a/src/pages/options_src/Sidebar.svelte b/src/pages/options_src/Sidebar.svelte index fb515f53..97780b15 100644 --- a/src/pages/options_src/Sidebar.svelte +++ b/src/pages/options_src/Sidebar.svelte @@ -10,15 +10,15 @@ -- cgit 1.4.1 From a9ecaf4ac0d97510b95fe965eebd543d53e3e5ac Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 2 Aug 2024 16:27:54 +0300 Subject: Improved mobile support. Fixed https://github.com/libredirect/browser_extension/issues/956 --- package.json | 2 +- src/pages/background/background.js | 404 ++++++++++++------------ src/pages/components/Checkbox.svelte | 1 - src/pages/options_src/General/General.svelte | 39 ++- src/pages/options_src/Services/Instances.svelte | 1 - src/pages/options_src/Services/Services.svelte | 10 +- src/pages/popup_src/Buttons.svelte | 30 +- src/pages/popup_src/components/Switch.svelte | 5 +- 8 files changed, 273 insertions(+), 219 deletions(-) (limited to 'src/pages') diff --git a/package.json b/package.json index 2a79b660..2895734d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "start": "web-ext run", "nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox", "start_ar": "web-ext run --firefox=/home/esmail/software/firefox_ar/firefox", - "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.fenix ", + "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.firefox --adb-remove-old-artifacts", "build": "web-ext build", "test": "web-ext lint", "html": "rollup -c --config-popup && rollup -c --config-options" diff --git a/src/pages/background/background.js b/src/pages/background/background.js index e3d9fb31..d42e5027 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -91,221 +91,233 @@ browser.tabs.onRemoved.addListener(tabId => { } }) -browser.commands.onCommand.addListener(async command => { - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - const url = new URL(tabs[0].url) - switch (command) { - case "switchInstance": { - const newUrl = await servicesHelper.switchInstance(url) - if (newUrl) browser.tabs.update({ url: newUrl }) - break - } - case "copyRaw": - servicesHelper.copyRaw(url) - break - case "redirect": - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - const newUrl = servicesHelper.redirect(url, "main_frame", null, true) - if (newUrl) { - browser.tabs.update(tabs[0].id, { url: newUrl }, () => { - tabIdRedirects[tabs[0].id] = true - }) - } - } - }) - break - case "reverse": - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - const newUrl = await servicesHelper.reverse(url) - if (newUrl) { - browser.tabs.update(tabs[0].id, { url: newUrl }, () => { - tabIdRedirects[tabs[0].id] = false - }) - } +browser.runtime.getPlatformInfo(r => { + if (r.os != "fuchsia" && r.os != "ios" && r.os != "android") { + browser.commands.onCommand.addListener(async command => { + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + const url = new URL(tabs[0].url) + switch (command) { + case "switchInstance": { + const newUrl = await servicesHelper.switchInstance(url) + if (newUrl) browser.tabs.update({ url: newUrl }) + break } - }) - break - } - }) -}) - -browser.contextMenus.create({ - id: "settingsTab", - title: browser.i18n.getMessage("settings"), - contexts: ["browser_action"], -}) -browser.contextMenus.create({ - id: "switchInstanceTab", - title: browser.i18n.getMessage("switchInstance"), - contexts: ["browser_action"], -}) -browser.contextMenus.create({ id: "copyReverseTab", title: "Copy Original", contexts: ["browser_action"] }) -browser.contextMenus.create({ id: "redirectTab", title: "Redirect", contexts: ["browser_action"] }) -browser.contextMenus.create({ id: "reverseTab", title: "Redirect To Original", contexts: ["browser_action"] }) + case "copyRaw": + servicesHelper.copyRaw(url) + break + case "redirect": + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + if (tabs[0].url) { + const url = new URL(tabs[0].url) + const newUrl = servicesHelper.redirect(url, "main_frame", null, true) + if (newUrl) { + browser.tabs.update(tabs[0].id, { url: newUrl }, () => { + tabIdRedirects[tabs[0].id] = true + }) + } + } + }) + break + case "reverse": + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + if (tabs[0].url) { + const url = new URL(tabs[0].url) + const newUrl = await servicesHelper.reverse(url) + if (newUrl) { + browser.tabs.update(tabs[0].id, { url: newUrl }, () => { + tabIdRedirects[tabs[0].id] = false + }) + } + } + }) + break + } + }) + }) -browser.contextMenus.create({ id: "redirectLink", title: "Redirect", contexts: ["link"] }) -browser.contextMenus.create({ id: "redirectLinkInNewTab", title: "Redirect In New Tab", contexts: ["link"] }) -browser.contextMenus.create({ id: "reverseLink", title: "Redirect To Original", contexts: ["link"] }) -browser.contextMenus.create({ id: "reverseLinkInNewTab", title: "Redirect To Original In New Tab", contexts: ["link"] }) -browser.contextMenus.create({ id: "copyReverseLink", title: "Copy Original", contexts: ["link"] }) -browser.contextMenus.create({ id: "bypassLink", title: "Bypass", contexts: ["link"] }) -browser.contextMenus.create({ id: "bypassLinkInNewTab", title: "Bypass In New Tab", contexts: ["link"] }) + browser.contextMenus.create({ + id: "settingsTab", + title: browser.i18n.getMessage("settings"), + contexts: ["browser_action"], + }) + browser.contextMenus.create({ + id: "switchInstanceTab", + title: browser.i18n.getMessage("switchInstance"), + contexts: ["browser_action"], + }) + browser.contextMenus.create({ id: "copyReverseTab", title: "Copy Original", contexts: ["browser_action"] }) + browser.contextMenus.create({ id: "redirectTab", title: "Redirect", contexts: ["browser_action"] }) + browser.contextMenus.create({ id: "reverseTab", title: "Redirect To Original", contexts: ["browser_action"] }) -if (!isChrome) { - browser.contextMenus.create({ id: "redirectBookmark", title: "Redirect", contexts: ["bookmark"] }) - browser.contextMenus.create({ id: "redirectBookmarkInNewTab", title: "Redirect In New Tab", contexts: ["bookmark"] }) - browser.contextMenus.create({ id: "reverseBookmark", title: "Redirect To Original", contexts: ["bookmark"] }) - browser.contextMenus.create({ - id: "reverseBookmarkInNewTab", - title: "Redirect To Original In New Tab", - contexts: ["bookmark"], - }) - browser.contextMenus.create({ id: "copyReverseBookmark", title: "Copy Original", contexts: ["bookmark"] }) - browser.contextMenus.create({ id: "bypassBookmark", title: "Bypass", contexts: ["bookmark"] }) - browser.contextMenus.create({ id: "bypassBookmarkInNewTab", title: "Bypass In New Tab", contexts: ["bookmark"] }) -} + browser.contextMenus.create({ id: "redirectLink", title: "Redirect", contexts: ["link"] }) + browser.contextMenus.create({ id: "redirectLinkInNewTab", title: "Redirect In New Tab", contexts: ["link"] }) + browser.contextMenus.create({ id: "reverseLink", title: "Redirect To Original", contexts: ["link"] }) + browser.contextMenus.create({ + id: "reverseLinkInNewTab", + title: "Redirect To Original In New Tab", + contexts: ["link"], + }) + browser.contextMenus.create({ id: "copyReverseLink", title: "Copy Original", contexts: ["link"] }) + browser.contextMenus.create({ id: "bypassLink", title: "Bypass", contexts: ["link"] }) + browser.contextMenus.create({ id: "bypassLinkInNewTab", title: "Bypass In New Tab", contexts: ["link"] }) -browser.contextMenus.onClicked.addListener(async info => { - switch (info.menuItemId) { - case "switchInstanceTab": { - const url = new URL(info.pageUrl) - const newUrl = await servicesHelper.switchInstance(url) - if (newUrl) browser.tabs.update({ url: newUrl }) - return + if (!isChrome) { + browser.contextMenus.create({ id: "redirectBookmark", title: "Redirect", contexts: ["bookmark"] }) + browser.contextMenus.create({ + id: "redirectBookmarkInNewTab", + title: "Redirect In New Tab", + contexts: ["bookmark"], + }) + browser.contextMenus.create({ id: "reverseBookmark", title: "Redirect To Original", contexts: ["bookmark"] }) + browser.contextMenus.create({ + id: "reverseBookmarkInNewTab", + title: "Redirect To Original In New Tab", + contexts: ["bookmark"], + }) + browser.contextMenus.create({ id: "copyReverseBookmark", title: "Copy Original", contexts: ["bookmark"] }) + browser.contextMenus.create({ id: "bypassBookmark", title: "Bypass", contexts: ["bookmark"] }) + browser.contextMenus.create({ id: "bypassBookmarkInNewTab", title: "Bypass In New Tab", contexts: ["bookmark"] }) } - case "settingsTab": - browser.runtime.openOptionsPage() - return - case "copyReverseTab": - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - servicesHelper.copyRaw(url) + + browser.contextMenus.onClicked.addListener(async info => { + switch (info.menuItemId) { + case "switchInstanceTab": { + const url = new URL(info.pageUrl) + const newUrl = await servicesHelper.switchInstance(url) + if (newUrl) browser.tabs.update({ url: newUrl }) + return } - }) - return - case "reverseTab": - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) - const newUrl = await servicesHelper.reverse(url) - if (newUrl) { - browser.tabs.update(tabs[0].id, { url: newUrl }, () => { - tabIdRedirects[tabs[0].id] = false - }) - } + case "settingsTab": + browser.runtime.openOptionsPage() + return + case "copyReverseTab": + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + if (tabs[0].url) { + const url = new URL(tabs[0].url) + servicesHelper.copyRaw(url) + } + }) + return + case "reverseTab": + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + if (tabs[0].url) { + const url = new URL(tabs[0].url) + const newUrl = await servicesHelper.reverse(url) + if (newUrl) { + browser.tabs.update(tabs[0].id, { url: newUrl }, () => { + tabIdRedirects[tabs[0].id] = false + }) + } + } + }) + return + case "redirectTab": + browser.tabs.query({ active: true, currentWindow: true }, async tabs => { + if (tabs[0].url) { + const url = new URL(tabs[0].url) + const newUrl = servicesHelper.redirect(url, "main_frame", null, true) + if (newUrl) { + browser.tabs.update(tabs[0].id, { url: newUrl }, () => { + tabIdRedirects[tabs[0].id] = true + }) + } + } + }) + return + case "copyReverseLink": { + const url = new URL(info.linkUrl) + await servicesHelper.copyRaw(url) + return } - }) - return - case "redirectTab": - browser.tabs.query({ active: true, currentWindow: true }, async tabs => { - if (tabs[0].url) { - const url = new URL(tabs[0].url) + case "redirectLink": + case "redirectLinkInNewTab": { + const url = new URL(info.linkUrl) const newUrl = servicesHelper.redirect(url, "main_frame", null, true) if (newUrl) { - browser.tabs.update(tabs[0].id, { url: newUrl }, () => { - tabIdRedirects[tabs[0].id] = true - }) + if (info.menuItemId == "redirectLink") browser.tabs.update({ url: newUrl }) + else browser.tabs.create({ url: newUrl }) } + return } - }) - return - case "copyReverseLink": { - const url = new URL(info.linkUrl) - await servicesHelper.copyRaw(url) - return - } - case "redirectLink": - case "redirectLinkInNewTab": { - const url = new URL(info.linkUrl) - const newUrl = servicesHelper.redirect(url, "main_frame", null, true) - if (newUrl) { - if (info.menuItemId == "redirectLink") browser.tabs.update({ url: newUrl }) - else browser.tabs.create({ url: newUrl }) - } - return - } - case "reverseLink": - case "reverseLinkInNewTab": { - const url = new URL(info.linkUrl) - const newUrl = await servicesHelper.reverse(url) - if (newUrl) { - if (info.menuItemId == "reverseLink") { - browser.tabs.update({ url: newUrl }, tab => { - tabIdRedirects[tab.id] = false - }) - } else { - browser.tabs.create({ url: newUrl }, tab => { - tabIdRedirects[tab.id] = false - }) - } - } - return - } - case "bypassLink": - case "bypassLinkInNewTab": { - const url = new URL(info.linkUrl) - if (info.menuItemId == "bypassLink") { - browser.tabs.update({ url: url.href }, tab => { - tabIdRedirects[tab.id] = false - }) - } else { - browser.tabs.create({ url: url.href }, tab => { - tabIdRedirects[tab.id] = false - }) - } - return - } - case "copyReverseBookmark": - browser.bookmarks.get(info.bookmarkId, bookmarks => { - const url = new URL(bookmarks[0].url) - servicesHelper.copyRaw(url) - }) - return - case "redirectBookmark": - case "redirectBookmarkInNewTab": - browser.bookmarks.get(info.bookmarkId, bookmarks => { - const url = new URL(bookmarks[0].url) - const newUrl = servicesHelper.redirect(url, "main_frame", null, true) - if (newUrl) { - if (info.menuItemId == "redirectBookmark") browser.tabs.update({ url: newUrl }) - else browser.tabs.create({ url: newUrl }) + case "reverseLink": + case "reverseLinkInNewTab": { + const url = new URL(info.linkUrl) + const newUrl = await servicesHelper.reverse(url) + if (newUrl) { + if (info.menuItemId == "reverseLink") { + browser.tabs.update({ url: newUrl }, tab => { + tabIdRedirects[tab.id] = false + }) + } else { + browser.tabs.create({ url: newUrl }, tab => { + tabIdRedirects[tab.id] = false + }) + } + } + return } - }) - return - case "reverseBookmark": - case "reverseBookmarkInNewTab": - browser.bookmarks.get(info.bookmarkId, async bookmarks => { - const url = new URL(bookmarks[0].url) - const newUrl = await servicesHelper.reverse(url) - if (newUrl) { - if (info.menuItemId == "reverseBookmark") { - browser.tabs.update({ url: newUrl }, tab => { + case "bypassLink": + case "bypassLinkInNewTab": { + const url = new URL(info.linkUrl) + if (info.menuItemId == "bypassLink") { + browser.tabs.update({ url: url.href }, tab => { tabIdRedirects[tab.id] = false }) } else { - browser.tabs.create({ url: newUrl }, tab => { + browser.tabs.create({ url: url.href }, tab => { tabIdRedirects[tab.id] = false }) } + return } - }) - return - case "bypassBookmark": - case "bypassBookmarkInNewTab": - browser.bookmarks.get(info.bookmarkId, async bookmarks => { - const url = new URL(bookmarks[0].url) - if (info.menuItemId == "bypassBookmark") { - browser.tabs.update({ url: url.href }, tab => (tabIdRedirects[tab.id] = false)) - } else { - browser.tabs.create({ url: url.href }, tab => (tabIdRedirects[tab.id] = false)) - } - return - }) + case "copyReverseBookmark": + browser.bookmarks.get(info.bookmarkId, bookmarks => { + const url = new URL(bookmarks[0].url) + servicesHelper.copyRaw(url) + }) + return + case "redirectBookmark": + case "redirectBookmarkInNewTab": + browser.bookmarks.get(info.bookmarkId, bookmarks => { + const url = new URL(bookmarks[0].url) + const newUrl = servicesHelper.redirect(url, "main_frame", null, true) + if (newUrl) { + if (info.menuItemId == "redirectBookmark") browser.tabs.update({ url: newUrl }) + else browser.tabs.create({ url: newUrl }) + } + }) + return + case "reverseBookmark": + case "reverseBookmarkInNewTab": + browser.bookmarks.get(info.bookmarkId, async bookmarks => { + const url = new URL(bookmarks[0].url) + const newUrl = await servicesHelper.reverse(url) + if (newUrl) { + if (info.menuItemId == "reverseBookmark") { + browser.tabs.update({ url: newUrl }, tab => { + tabIdRedirects[tab.id] = false + }) + } else { + browser.tabs.create({ url: newUrl }, tab => { + tabIdRedirects[tab.id] = false + }) + } + } + }) + return + case "bypassBookmark": + case "bypassBookmarkInNewTab": + browser.bookmarks.get(info.bookmarkId, async bookmarks => { + const url = new URL(bookmarks[0].url) + if (info.menuItemId == "bypassBookmark") { + browser.tabs.update({ url: url.href }, tab => (tabIdRedirects[tab.id] = false)) + } else { + browser.tabs.create({ url: url.href }, tab => (tabIdRedirects[tab.id] = false)) + } + return + }) + } + }) } }) diff --git a/src/pages/components/Checkbox.svelte b/src/pages/components/Checkbox.svelte index 9ba9c56c..d42a4f10 100644 --- a/src/pages/components/Checkbox.svelte +++ b/src/pages/components/Checkbox.svelte @@ -1,7 +1,6 @@ diff --git a/src/pages/options_src/General/General.svelte b/src/pages/options_src/General/General.svelte index 37c38a0a..b6ed1b46 100644 --- a/src/pages/options_src/General/General.svelte +++ b/src/pages/options_src/General/General.svelte @@ -14,13 +14,30 @@ const unsubscribe = options.subscribe(val => (_options = val)) onDestroy(unsubscribe) + let disableBookmarks = null + browser.runtime.getPlatformInfo(r => { + switch (r.os) { + case "fuchsia": + case "ios": + case "android": + disableBookmarks = true + break + default: + disableBookmarks = false + } + if (!disableBookmarks) { + browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r)) + } + }) + let bookmarksPermission - browser.permissions.contains({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r)) - $: if (bookmarksPermission) { - browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r)) - } else { - browser.permissions.remove({ permissions: ["bookmarks"] }) - bookmarksPermission = false + $: if (disableBookmarks !== null && disableBookmarks === false) { + if (bookmarksPermission) { + browser.permissions.request({ permissions: ["bookmarks"] }, r => (bookmarksPermission = r)) + } else { + browser.permissions.remove({ permissions: ["bookmarks"] }) + bookmarksPermission = false + } } @@ -68,10 +85,12 @@ /> - - - - + {#if disableBookmarks === false} + + + + + {/if} diff --git a/src/pages/options_src/Services/Instances.svelte b/src/pages/options_src/Services/Instances.svelte index 862bbf7e..3b870c4b 100644 --- a/src/pages/options_src/Services/Instances.svelte +++ b/src/pages/options_src/Services/Instances.svelte @@ -59,7 +59,6 @@ async function pingInstances() { pingCache = {} for (const instance of allInstances) { - console.log("pinging...", instance) pingCache[instance] = { color: "lightblue", value: "pinging..." } const time = await utils.ping(instance) pingCache[instance] = colorTime(time) diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index 4e719447..b0f0d5e3 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -32,8 +32,9 @@
diff --git a/src/pages/popup_src/Buttons.svelte b/src/pages/popup_src/Buttons.svelte index bfa162f8..0b454675 100644 --- a/src/pages/popup_src/Buttons.svelte +++ b/src/pages/popup_src/Buttons.svelte @@ -41,7 +41,14 @@
{#if redirect} - browser.runtime.sendMessage("redirectTab")}> + { + browser.runtime.sendMessage("redirectTab", () => { + window.close() + }) + }} + > @@ -50,7 +57,10 @@ {#if switchInstance} browser.tabs.update({ url: await servicesHelper.switchInstance(url) })} + on:click={async () => + browser.tabs.update({ url: await servicesHelper.switchInstance(url) }, () => { + window.close() + })} > @@ -62,7 +72,13 @@ - browser.runtime.sendMessage("reverseTab")}> + + browser.runtime.sendMessage("reverseTab", () => { + window.close() + })} + > @@ -85,7 +101,13 @@
- window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> + + browser.tabs.create({ url: browser.runtime.getURL("pages/options/index.html") }, () => { + window.close() + })} + > diff --git a/src/pages/popup_src/components/Switch.svelte b/src/pages/popup_src/components/Switch.svelte index e581e5f4..42a86403 100644 --- a/src/pages/popup_src/components/Switch.svelte +++ b/src/pages/popup_src/components/Switch.svelte @@ -28,7 +28,10 @@
window.open(browser.runtime.getURL(_config.services[serviceKey].url), "_blank")} + on:click={() => + browser.tabs.create({ url: browser.runtime.getURL(_config.services[serviceKey].url) }, () => { + window.close() + })} > -- cgit 1.4.1 From 101e2eb89e21f6fecf8f2c39d26b29437fd180d4 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 2 Aug 2024 16:49:28 +0300 Subject: Closed popup after switching instance --- src/pages/popup_src/components/Switch.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/pages') diff --git a/src/pages/popup_src/components/Switch.svelte b/src/pages/popup_src/components/Switch.svelte index 42a86403..f3df9317 100644 --- a/src/pages/popup_src/components/Switch.svelte +++ b/src/pages/popup_src/components/Switch.svelte @@ -48,7 +48,10 @@ /> browser.tabs.update({ url: await servicesHelper.switchInstance(url, serviceKey) })} + on:click={async () => + browser.tabs.update({ url: await servicesHelper.switchInstance(url, serviceKey) }, () => { + window.close() + })} />
-- cgit 1.4.1 From e3517b107678ff1fd1fce3fd88da716516c0cf4e Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 7 Aug 2024 18:32:57 +0300 Subject: Allowed switching service by hovering https://github.com/libredirect/browser_extension/issues/961 --- src/pages/options_src/Services/Services.svelte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/pages') diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index b0f0d5e3..16bf7b92 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -27,6 +27,8 @@ $: serviceConf = _config.services[selectedService] $: serviceOptions = _options[selectedService] $: frontendWebsite = serviceConf.frontends[serviceOptions.frontend].url + $: servicesEntries = Object.entries(_config.services) + $: frontendEntries = Object.entries(serviceConf.frontends)
@@ -41,9 +43,10 @@ clearable={false} class="svelte_select" value={selectedService} + on:hoverItem={e => (selectedService = servicesEntries[e.detail][0])} on:change={e => (selectedService = e.detail.value)} items={[ - ...Object.entries(_config.services).map(([serviceKey, service]) => { + ...servicesEntries.map(([serviceKey, service]) => { return { value: serviceKey, label: service.name } }), ]} @@ -102,12 +105,16 @@ dir="ltr" class="svelte_select" value={serviceOptions.frontend} + on:hoverItem={e => { + serviceOptions.frontend = frontendEntries[e.detail][0] + options.set(_options) + }} on:change={e => { serviceOptions.frontend = e.detail.value options.set(_options) }} items={[ - ...Object.entries(serviceConf.frontends).map(([frontendId, frontend]) => ({ + ...frontendEntries.map(([frontendId, frontend]) => ({ value: frontendId, label: frontend.name, })), -- cgit 1.4.1 From feca205994a6d5def48233c115cd3d50f2568506 Mon Sep 17 00:00:00 2001 From: Monstorix Date: Sat, 10 Aug 2024 21:47:55 +0800 Subject: Fix sidebar layouts and font fallbacks for CJK --- src/pages/options_src/App.svelte | 2 +- src/pages/options_src/Sidebar.svelte | 3 ++- src/pages/popup_src/App.svelte | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/pages') diff --git a/src/pages/options_src/App.svelte b/src/pages/options_src/App.svelte index dfafe1f0..b5a44856 100644 --- a/src/pages/options_src/App.svelte +++ b/src/pages/options_src/App.svelte @@ -110,7 +110,7 @@ margin: 0; padding-top: 50px; justify-content: center; - font-family: "Inter"; + font-family: "Inter", sans-serif; box-sizing: border-box; font-size: 16px; background-color: var(--bg-main); diff --git a/src/pages/options_src/Sidebar.svelte b/src/pages/options_src/Sidebar.svelte index 97780b15..5e2f4931 100644 --- a/src/pages/options_src/Sidebar.svelte +++ b/src/pages/options_src/Sidebar.svelte @@ -14,7 +14,7 @@ page.set("services")} style={$page == "services" && "color: var(--active);"}> - {browser.i18n.getMessage("general") || "Services"} + {browser.i18n.getMessage("services") || "Services"} @@ -37,6 +37,7 @@ color: var(--text); transition: 0.1s; margin: 10px; + min-width: max-content; } a:hover { diff --git a/src/pages/popup_src/App.svelte b/src/pages/popup_src/App.svelte index df37d55d..52aadc74 100644 --- a/src/pages/popup_src/App.svelte +++ b/src/pages/popup_src/App.svelte @@ -106,7 +106,7 @@ margin: 0; padding: 10px; padding-top: 20px; - font-family: "Inter"; + font-family: "Inter", sans-serif; font-size: 16px; background-color: var(--bg-main); color: var(--text); -- cgit 1.4.1 From 3043541b5305ec0ed4fd01fa06da495f55c3053c Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 15 Aug 2024 09:41:12 +0300 Subject: Removed select by hover https://github.com/libredirect/browser_extension/issues/961 --- package.json | 4 ++-- src/pages/options_src/Services/FrontendIcon.svelte | 4 +--- src/pages/options_src/Services/Services.svelte | 5 ----- 3 files changed, 3 insertions(+), 10 deletions(-) (limited to 'src/pages') diff --git a/package.json b/package.json index 9288b04b..7b9fbd11 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ }, "scripts": { "start": "web-ext run", - "nightly": "web-ext run --firefox=/home/esmail/software/firefox_nightly/firefox", - "start_ar": "web-ext run --firefox=/home/esmail/software/firefox_ar/firefox", + "firefox": "web-ext run --firefox=/home/manerakai/software/firefox/firefox", + "start_ar": "web-ext run --firefox=/home/manerakai/software/firefox_ar/firefox", "android": "web-ext run -t firefox-android --adb-device emulator-5554 --firefox-apk org.mozilla.firefox --adb-remove-old-artifacts", "build": "web-ext build -i pages/options_src -i pages/popup_src pages/icons -i pages/popup_src -i pages/components", "build_chromium": "brave-browser --pack-extension=src/ --pack-extension-key=src.pem", diff --git a/src/pages/options_src/Services/FrontendIcon.svelte b/src/pages/options_src/Services/FrontendIcon.svelte index 24942fd6..4b392676 100644 --- a/src/pages/options_src/Services/FrontendIcon.svelte +++ b/src/pages/options_src/Services/FrontendIcon.svelte @@ -1,6 +1,7 @@ diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index 16bf7b92..a78ff0b6 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -43,7 +43,6 @@ clearable={false} class="svelte_select" value={selectedService} - on:hoverItem={e => (selectedService = servicesEntries[e.detail][0])} on:change={e => (selectedService = e.detail.value)} items={[ ...servicesEntries.map(([serviceKey, service]) => { @@ -105,10 +104,6 @@ dir="ltr" class="svelte_select" value={serviceOptions.frontend} - on:hoverItem={e => { - serviceOptions.frontend = frontendEntries[e.detail][0] - options.set(_options) - }} on:change={e => { serviceOptions.frontend = e.detail.value options.set(_options) -- cgit 1.4.1 From ef9b247a916cb1e6fdaf275f0bcdfe7d104b1b2b Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 16 Aug 2024 13:44:31 +0300 Subject: Faided disabled services https://github.com/libredirect/browser_extension/issues/961 --- src/pages/options_src/Services/Services.svelte | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/pages') diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index a78ff0b6..7c4a92b3 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -50,11 +50,11 @@ }), ]} > -
+
{item.label}
-
+
{selection.label}
@@ -181,10 +181,10 @@ --width: 210px; --background: var(--bg-secondary); --list-background: var(--bg-secondary); - --item-active-background: red; --item-is-active-bg: grey; --item-hover-bg: grey; --item-is-active-color: var(--text); + --list-max-height: 400px; --padding: 0 0 0 10px; --item-color: var(--text); } @@ -201,4 +201,8 @@ width: 26px; color: var(--text); } + + :global(.svelte_select .disabled) { + opacity: 0.4; + } -- cgit 1.4.1 From 6bd542f858ceaa392e11a526c713359d8f667399 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 16 Aug 2024 15:53:53 +0300 Subject: Added arrow icon to dropdowns. Added settings button to each service in the popup https://github.com/libredirect/browser_extension/issues/961 --- src/pages/icons/SettingsIcon.svelte | 3 ++ src/pages/options_src/App.svelte | 10 +++---- src/pages/options_src/Services/Services.svelte | 13 +++++++-- src/pages/options_src/Sidebar.svelte | 6 ++-- src/pages/options_src/stores.js | 1 - src/pages/options_src/url.js | 38 ++++++++++++++++++++++++++ src/pages/popup_src/App.svelte | 2 +- src/pages/popup_src/Buttons.svelte | 4 +-- src/pages/popup_src/components/Switch.svelte | 8 ++++++ 9 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 src/pages/options_src/url.js (limited to 'src/pages') diff --git a/src/pages/icons/SettingsIcon.svelte b/src/pages/icons/SettingsIcon.svelte index f47d078a..00798289 100644 --- a/src/pages/icons/SettingsIcon.svelte +++ b/src/pages/icons/SettingsIcon.svelte @@ -1,10 +1,13 @@ (_page = val)) - const dark = { text: "#fff", bgMain: "#121212", @@ -85,9 +83,9 @@ --light-grey: {cssVariables.lightGrey};" > - {#if _page == "general"} + {#if !$url.hash || $url.hash == "#general"} - {:else if _page == "services"} + {:else if $url.hash.startsWith("#services")} {/if}
diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index 7c4a92b3..93afcded 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -1,6 +1,7 @@
- page.set("general")} style={$page == "general" && "color: var(--active);"}> + {browser.i18n.getMessage("general") || "General"} - page.set("services")} style={$page == "services" && "color: var(--active);"}> + {browser.i18n.getMessage("services") || "Services"} diff --git a/src/pages/options_src/stores.js b/src/pages/options_src/stores.js index 782f6064..7ae0f8c7 100644 --- a/src/pages/options_src/stores.js +++ b/src/pages/options_src/stores.js @@ -2,4 +2,3 @@ import { writable } from "svelte/store" export const options = writable(null) export const config = writable(null) -export const page = writable("general") diff --git a/src/pages/options_src/url.js b/src/pages/options_src/url.js new file mode 100644 index 00000000..010e5b21 --- /dev/null +++ b/src/pages/options_src/url.js @@ -0,0 +1,38 @@ +// https://svelte.dev/repl/5abaac000b164aa1aacc6051d5c4f584?version=3.59.2 + +import { derived, writable } from 'svelte/store' + +export function createUrlStore(ssrUrl) { + // Ideally a bundler constant so that it's tree-shakable + if (typeof window === 'undefined') { + const { subscribe } = writable(ssrUrl) + return { subscribe } + } + + const href = writable(window.location.href) + + const originalPushState = history.pushState + const originalReplaceState = history.replaceState + + const updateHref = () => href.set(window.location.href) + + history.pushState = () => { + originalPushState.apply(this, arguments) + updateHref() + } + + history.replaceState = () => { + originalReplaceState.apply(this, arguments) + updateHref() + } + + window.addEventListener('popstate', updateHref) + window.addEventListener('hashchange', updateHref) + + return { + subscribe: derived(href, ($href) => new URL($href)).subscribe + } +} + +// If you're using in a pure SPA, you can return a store directly and share it everywhere +export default createUrlStore() diff --git a/src/pages/popup_src/App.svelte b/src/pages/popup_src/App.svelte index 52aadc74..3409052d 100644 --- a/src/pages/popup_src/App.svelte +++ b/src/pages/popup_src/App.svelte @@ -88,7 +88,7 @@ diff --git a/src/pages/popup_src/components/Switch.svelte b/src/pages/popup_src/components/Switch.svelte index f3df9317..6485f875 100644 --- a/src/pages/popup_src/components/Switch.svelte +++ b/src/pages/popup_src/components/Switch.svelte @@ -9,6 +9,7 @@ import { onDestroy } from "svelte" import servicesHelper from "../../../assets/javascripts/services" import { options, config } from "../stores" + import SettingsIcon from "../../icons/SettingsIcon.svelte" let _options let _config @@ -53,6 +54,13 @@ window.close() })} /> + + browser.tabs.create({ url: browser.runtime.getURL(`pages/options/index.html#services:${serviceKey}`) }, () => { + window.close() + })} + />
-- cgit 1.4.1 From f8af807d724e748efda71148e9a5733b36e453ee Mon Sep 17 00:00:00 2001 From: Monstorix Date: Sat, 17 Aug 2024 17:41:03 +0800 Subject: Complete translation keys and fix Simplified Chinese translations --- src/_locales/ar/messages.json | 40 +++++- src/_locales/bn/messages.json | 146 +++++++++++++------- src/_locales/bs/messages.json | 48 ++++++- src/_locales/cs/messages.json | 39 +++++- src/_locales/de/messages.json | 39 +++++- src/_locales/delete.py | 18 ++- src/_locales/en/messages.json | 43 +++++- src/_locales/eo/messages.json | 146 +++++++++++++++++++- src/_locales/es/messages.json | 39 +++++- src/_locales/fi/messages.json | 153 +++++++++++++-------- src/_locales/filter.py | 5 + src/_locales/fr/messages.json | 43 +++++- src/_locales/gl/messages.json | 39 +++++- src/_locales/hr/messages.json | 39 +++++- src/_locales/id/messages.json | 39 +++++- src/_locales/it/messages.json | 39 +++++- src/_locales/ja/messages.json | 39 +++++- src/_locales/jv/messages.json | 135 +++++++++++++++++- src/_locales/ko/messages.json | 46 ++++++- src/_locales/nb_NO/messages.json | 46 ++++++- src/_locales/nl/messages.json | 39 +++++- src/_locales/pl/messages.json | 39 +++++- src/_locales/pt/messages.json | 48 ++++++- src/_locales/pt_BR/messages.json | 45 +++++- src/_locales/ro/messages.json | 39 +++++- src/_locales/ru/messages.json | 39 +++++- src/_locales/sr/messages.json | 48 ++++++- src/_locales/tr/messages.json | 39 +++++- src/_locales/uk/messages.json | 39 +++++- src/_locales/vi/messages.json | 39 +++++- src/_locales/zh_Hans/messages.json | 47 ++++++- src/_locales/zh_Hant/messages.json | 86 +++++++++--- src/pages/options_src/Services/RedirectType.svelte | 6 +- 33 files changed, 1509 insertions(+), 225 deletions(-) (limited to 'src/pages') diff --git a/src/_locales/ar/messages.json b/src/_locales/ar/messages.json index 516d07d2..10413b84 100644 --- a/src/_locales/ar/messages.json +++ b/src/_locales/ar/messages.json @@ -83,9 +83,8 @@ "message": "أضف نظرائك المفضلين", "description": "used in the settings page" }, - "copyRaw": { - "message": "الرابط الأصلي", - "description": "used in the popup" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "تم النسخ", @@ -110,5 +109,38 @@ }, "disable": { "message": "عطّل" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/bn/messages.json b/src/_locales/bn/messages.json index cdde0c45..60b91d65 100644 --- a/src/_locales/bn/messages.json +++ b/src/_locales/bn/messages.json @@ -1,22 +1,42 @@ { - "dark": { - "message": "অন্ধকার", + "extensionName": { + "message": "লিবরিডাইরেক্ট", + "description": "name of the extension" + }, + "extensionDescription": { + "message": "একটি ওয়েব এক্সটেনশন যা জনপ্রিয় সাইটগুলোকে বিকল্প গোপনীয়তা-বান্ধব ফ্রন্টএন্ড এবং ব্যাকএন্ডে পুনর্নির্দেশ করে", + "description": "description of the extension" + }, + "switchInstance": { + "message": "ইন্সট্যান্স পাল্টাও", + "description": "used in manifest.json as shortcut description" + }, + "settings": { + "message": "পছন্দসমূহ", + "description": "used in the popup" + }, + "general": { + "message": "সাধারণ", "description": "used in the settings page" }, - "auto": { - "message": "স্বয়ংক্রিয়", + "theme": { + "message": "রঙ", "description": "used in the settings page" }, - "enable": { - "message": "সক্রিয়", + "light": { + "message": "সাদা", "description": "used in the settings page" }, - "frontend": { - "message": "সামনের অংশ", + "dark": { + "message": "অন্ধকার", "description": "used in the settings page" }, - "both": { - "message": "উভয়", + "auto": { + "message": "স্বয়ংক্রিয়", + "description": "used in the settings page" + }, + "excludeFromRedirecting": { + "message": "পুনঃনির্দেশ থেকে বাদ দেওয়া", "description": "used in the settings page" }, "importSettings": { @@ -31,73 +51,95 @@ "message": "পছন্দসমূহ সহজাত অবস্থায় ফিরত নাও", "description": "used in the settings page" }, + "enable": { + "message": "সক্রিয়", + "description": "used in the settings page" + }, + "showInPopup": { + "message": "পপআপে দেখাও", + "description": "used in the settings page" + }, + "frontend": { + "message": "সামনের অংশ", + "description": "used in the settings page" + }, "redirectType": { "message": "পুনঃনির্দেশ ধরণ", "description": "used in the settings page" }, - "excludeFromRedirecting": { - "message": "পুনঃনির্দেশ থেকে বাদ দেওয়া", + "both": { + "message": "উভয়", "description": "used in the settings page" }, - "showInPopup": { - "message": "পপআপে দেখাও", + "onlyEmbedded": { + "message": "শুধু এমবেডকৃত", "description": "used in the settings page" }, - "copyRaw": { - "message": "কাঁচা অনুলিপি" - }, "onlyNotEmbedded": { "message": "এমবেডকৃত নয়", "description": "used in the settings page" }, - "about": { - "message": "আমাদের সম্পর্কে" + "addYourFavoriteInstances": { + "message": "পছন্দের ইন্সট্যান্স যোগ করো", + "description": "used in the settings page" + }, + "copyOriginal": { + "message": "Copy Original" + }, + "copied": { + "message": "অনুলিপিত" + }, + "redirectToOriginal": { + "message": "আসলটায় পুনঃনির্দেশ করো", + "description": "Used in context menus when right clicking on a page/tab" }, "redirectLink": { "message": "পুনঃনির্দেশ করার চেষ্টা করো", "description": "Used in context menus when right clicking on a hyperlink" }, - "extensionName": { - "message": "লিবরিডাইরেক্ট", - "description": "name of the extension" + "about": { + "message": "আমাদের সম্পর্কে" }, - "theme": { - "message": "রঙ", - "description": "used in the settings page" + "unsupportedIframesHandling": { + "message": "Unsupported embeds handling" }, - "light": { - "message": "সাদা", - "description": "used in the settings page" + "fetchPublicInstances": { + "message": "Fetch public instances" }, - "copied": { - "message": "অনুলিপিত" + "disable": { + "message": "Disable" }, - "extensionDescription": { - "message": "একটি ওয়েব এক্সটেনশন যা জনপ্রিয় সাইটগুলোকে বিকল্প গোপনীয়তা-বান্ধব ফ্রন্টএন্ড এবং ব্যাকএন্ডে পুনর্নির্দেশ করে", - "description": "description of the extension" + "pingInstances": { + "message": "Ping Instances" }, - "redirectToOriginal": { - "message": "আসলটায় পুনঃনির্দেশ করো", - "description": "Used in context menus when right clicking on a page/tab" + "exportSettingsToSync": { + "message": "Export Settings to Sync" }, - "addYourFavoriteInstances": { - "message": "পছন্দের ইন্সট্যান্স যোগ করো", - "description": "used in the settings page" + "importSettingsFromSync": { + "message": "Import Settings from Sync" }, - "settings": { - "message": "পছন্দসমূহ", - "description": "used in the popup" + "services": { + "message": "Services" }, - "general": { - "message": "সাধারণ", - "description": "used in the settings page" + "service": { + "message": "Service" }, - "switchInstance": { - "message": "ইন্সট্যান্স পাল্টাও", - "description": "used in manifest.json as shortcut description" + "bookmarksMenu": { + "message": "Bookmarks menu" }, - "onlyEmbedded": { - "message": "শুধু এমবেডকৃত", - "description": "used in the settings page" + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/bs/messages.json b/src/_locales/bs/messages.json index 06c50c34..3f3039b6 100644 --- a/src/_locales/bs/messages.json +++ b/src/_locales/bs/messages.json @@ -83,8 +83,8 @@ "message": "Dodajte vaše omiljene instance", "description": "used in the settings page" }, - "copyRaw": { - "message": "Kopirajte neobrađenu kodu" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Kopirano" @@ -99,5 +99,47 @@ }, "about": { "message": "O" + }, + "unsupportedIframesHandling": { + "message": "Unsupported iframes handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/cs/messages.json b/src/_locales/cs/messages.json index 245eb285..3ae7d793 100644 --- a/src/_locales/cs/messages.json +++ b/src/_locales/cs/messages.json @@ -83,8 +83,8 @@ "message": "Přidejte své oblíbené instance", "description": "used in the settings page" }, - "copyRaw": { - "message": "Zkopírovat surové" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Zkopírováno" @@ -108,5 +108,38 @@ }, "disable": { "message": "Zakázat" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json index dbd4b53c..f7f58875 100644 --- a/src/_locales/de/messages.json +++ b/src/_locales/de/messages.json @@ -83,8 +83,8 @@ "message": "Eigene Instanz hinzufügen", "description": "used in the settings page" }, - "copyRaw": { - "message": "Original-Link kopieren" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Kopiert" @@ -108,5 +108,38 @@ }, "disable": { "message": "Deaktivieren" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/delete.py b/src/_locales/delete.py index 13bfe546..486ab76f 100644 --- a/src/_locales/delete.py +++ b/src/_locales/delete.py @@ -11,15 +11,21 @@ with open('./en/messages.json') as data: keys = ['extensionName', 'extensionDescription', 'general', + 'services', + 'service', 'theme', 'auto', 'light', 'dark', 'excludeFromRedirecting', + 'fetchPublicInstances', 'importSettings', 'exportSettings', + 'exportSettingsToSync', + 'importSettingsFromSync', 'resetSettings', 'enable', + 'disable', 'showInPopup', 'frontend', 'redirectType', @@ -28,12 +34,22 @@ keys = ['extensionName', 'onlyNotEmbedded', 'addYourFavoriteInstances', 'switchInstance', - 'copyRaw', + 'copyOriginal', 'copied', 'settings', 'about', 'redirectToOriginal', 'redirectLink', + 'redirectOnlyInIncognito', + 'bookmarksMenu', + 'showInPopup', + 'unsupportedIframesHandling', + 'bypass', + 'block', + 'searchHint', + 'excludeFromRedirecting', + 'pingInstances', + 'redirect', ] tmp = {} diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 251bbebe..32f4b706 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -83,8 +83,8 @@ "message": "Add your favorite instances", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copy Raw" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copied" @@ -101,12 +101,45 @@ "message": "About" }, "unsupportedIframesHandling": { - "message": "Unsupported iframes handling" + "message": "Unsupported embeds handling" }, "fetchPublicInstances": { "message": "Fetch public instances" }, "disable": { "message": "Disable" - } -} \ No newline at end of file + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" + } +} diff --git a/src/_locales/eo/messages.json b/src/_locales/eo/messages.json index 0967ef42..885c7802 100644 --- a/src/_locales/eo/messages.json +++ b/src/_locales/eo/messages.json @@ -1 +1,145 @@ -{} +{ + "extensionName": { + "message": "LibRedirect", + "description": "name of the extension" + }, + "extensionDescription": { + "message": "A web extension that redirects popular sites to alternative privacy-friendly frontends and backends", + "description": "description of the extension" + }, + "switchInstance": { + "message": "Switch Instance", + "description": "used in manifest.json as shortcut description" + }, + "settings": { + "message": "Settings", + "description": "used in the popup" + }, + "general": { + "message": "General", + "description": "used in the settings page" + }, + "theme": { + "message": "Theme", + "description": "used in the settings page" + }, + "light": { + "message": "Light", + "description": "used in the settings page" + }, + "dark": { + "message": "Dark", + "description": "used in the settings page" + }, + "auto": { + "message": "Auto", + "description": "used in the settings page" + }, + "excludeFromRedirecting": { + "message": "Excluded from redirecting", + "description": "used in the settings page" + }, + "importSettings": { + "message": "Import Settings", + "description": "used in the settings page" + }, + "exportSettings": { + "message": "Export Settings", + "description": "used in the settings page" + }, + "resetSettings": { + "message": "Reset Settings", + "description": "used in the settings page" + }, + "enable": { + "message": "Enable", + "description": "used in the settings page" + }, + "showInPopup": { + "message": "Show in popup", + "description": "used in the settings page" + }, + "frontend": { + "message": "Frontend", + "description": "used in the settings page" + }, + "redirectType": { + "message": "Redirect Type", + "description": "used in the settings page" + }, + "both": { + "message": "both", + "description": "used in the settings page" + }, + "onlyEmbedded": { + "message": "only embedded", + "description": "used in the settings page" + }, + "onlyNotEmbedded": { + "message": "only not embedded", + "description": "used in the settings page" + }, + "addYourFavoriteInstances": { + "message": "Add your favorite instances", + "description": "used in the settings page" + }, + "copyOriginal": { + "message": "Copy Original" + }, + "copied": { + "message": "Copied" + }, + "redirectToOriginal": { + "message": "Redirect to original", + "description": "Used in context menus when right clicking on a page/tab" + }, + "redirectLink": { + "message": "Attempt to redirect", + "description": "Used in context menus when right clicking on a hyperlink" + }, + "about": { + "message": "About" + }, + "unsupportedIframesHandling": { + "message": "Unsupported embeds handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" + } +} \ No newline at end of file diff --git a/src/_locales/es/messages.json b/src/_locales/es/messages.json index 8ebe7844..71b01de4 100644 --- a/src/_locales/es/messages.json +++ b/src/_locales/es/messages.json @@ -83,8 +83,8 @@ "message": "Añade tus instancias preferidas", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copiar Original" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copiado" @@ -108,5 +108,38 @@ }, "disable": { "message": "Desactivar" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/fi/messages.json b/src/_locales/fi/messages.json index 0b6b797b..7e88f79c 100644 --- a/src/_locales/fi/messages.json +++ b/src/_locales/fi/messages.json @@ -1,21 +1,43 @@ { - "excludeFromRedirecting": { - "message": "Poissuljettu uudelleenohjaukselta", - "description": "used in the settings page" - }, - "copyRaw": { - "message": "Kopioi alkuperäinen" + "extensionName": { + "message": "LibRedirect", + "description": "name of the extension" }, - "both": { - "message": "molemmat", - "description": "used in the settings page" + "extensionDescription": { + "message": "Selainlaajennus joka uudelleenohjaa suositut sivustot vaihtoehtoisiin yksityisyysystävällisiin käyttöliittymiin", + "description": "description of the extension" }, "switchInstance": { "message": "Vaihda instanssi", "description": "used in manifest.json as shortcut description" }, - "unsupportedIframesHandling": { - "message": "Tukemattomien iframejen käsittely" + "settings": { + "message": "Asetukset", + "description": "used in the popup" + }, + "general": { + "message": "Yleiset", + "description": "used in the settings page" + }, + "theme": { + "message": "Teema", + "description": "used in the settings page" + }, + "light": { + "message": "Vaalea", + "description": "used in the settings page" + }, + "dark": { + "message": "Tumma", + "description": "used in the settings page" + }, + "auto": { + "message": "Automaattinen", + "description": "used in the settings page" + }, + "excludeFromRedirecting": { + "message": "Poissuljettu uudelleenohjaukselta", + "description": "used in the settings page" }, "importSettings": { "message": "Tuo asetukset", @@ -25,88 +47,99 @@ "message": "Vie asetukset", "description": "used in the settings page" }, - "fetchPublicInstances": { - "message": "Hae julkiset instanssit" - }, - "addYourFavoriteInstances": { - "message": "Lisää suosikki-instanssisi", + "resetSettings": { + "message": "Nollaa asetukset", "description": "used in the settings page" }, - "extensionName": { - "message": "LibRedirect", - "description": "name of the extension" + "enable": { + "message": "Ota käyttöön", + "description": "used in the settings page" }, "showInPopup": { "message": "Näytä ponnahdusvalikossa", "description": "used in the settings page" }, - "theme": { - "message": "Teema", + "frontend": { + "message": "Käyttöliittymä", + "description": "used in the settings page" + }, + "redirectType": { + "message": "Uudelleenohjauksen tyyppi", + "description": "used in the settings page" + }, + "both": { + "message": "molemmat", "description": "used in the settings page" }, "onlyEmbedded": { "message": "vain upotteet", "description": "used in the settings page" }, - "light": { - "message": "Vaalea", + "onlyNotEmbedded": { + "message": "vain muut kuin upotteet", "description": "used in the settings page" }, - "frontend": { - "message": "Käyttöliittymä", + "addYourFavoriteInstances": { + "message": "Lisää suosikki-instanssisi", "description": "used in the settings page" }, - "extensionDescription": { - "message": "Selainlaajennus joka uudelleenohjaa suositut sivustot vaihtoehtoisiin yksityisyysystävällisiin käyttöliittymiin", - "description": "description of the extension" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Kopioitu" }, - "onlyNotEmbedded": { - "message": "vain muut kuin upotteet", - "description": "used in the settings page" - }, - "about": { - "message": "Tietoja" + "redirectToOriginal": { + "message": "Uudelleenohjaa alkuperäiseen", + "description": "Used in context menus when right clicking on a page/tab" }, "redirectLink": { "message": "Yritä uudelleenohjata", "description": "Used in context menus when right clicking on a hyperlink" }, - "redirectType": { - "message": "Uudelleenohjauksen tyyppi", - "description": "used in the settings page" - }, - "dark": { - "message": "Tumma", - "description": "used in the settings page" + "about": { + "message": "Tietoja" }, - "general": { - "message": "Yleiset", - "description": "used in the settings page" + "unsupportedIframesHandling": { + "message": "Tukemattomien iframejen käsittely" }, - "enable": { - "message": "Ota käyttöön", - "description": "used in the settings page" + "fetchPublicInstances": { + "message": "Hae julkiset instanssit" }, "disable": { "message": "Poista käytöstä" }, - "redirectToOriginal": { - "message": "Uudelleenohjaa alkuperäiseen", - "description": "Used in context menus when right clicking on a page/tab" + "pingInstances": { + "message": "Ping Instances" }, - "auto": { - "message": "Automaattinen", - "description": "used in the settings page" + "exportSettingsToSync": { + "message": "Export Settings to Sync" }, - "settings": { - "message": "Asetukset", - "description": "used in the popup" + "importSettingsFromSync": { + "message": "Import Settings from Sync" }, - "resetSettings": { - "message": "Nollaa asetukset", - "description": "used in the settings page" + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/filter.py b/src/_locales/filter.py index c60a6a4b..f9f03a1d 100644 --- a/src/_locales/filter.py +++ b/src/_locales/filter.py @@ -3,16 +3,20 @@ import json langs = [ 'ar', + 'bn', 'bs', 'cs', 'de', + 'eo', 'es', + 'fi', 'fr', 'gl', 'hr', 'id', 'it', 'ja', + 'jv', 'ko', 'nb_NO', 'nl', @@ -26,6 +30,7 @@ langs = [ 'uk', 'vi', 'zh_Hans', + 'zh_Hant', ] en_json = {} diff --git a/src/_locales/fr/messages.json b/src/_locales/fr/messages.json index b24f6fcc..03fbc927 100644 --- a/src/_locales/fr/messages.json +++ b/src/_locales/fr/messages.json @@ -83,8 +83,8 @@ "message": "Ajoutez vos instances favorites", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copier le lien original" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copié" @@ -100,13 +100,46 @@ "about": { "message": "À propos" }, + "unsupportedIframesHandling": { + "message": "Gestion des iframes non prises en charge" + }, "fetchPublicInstances": { "message": "Rechercher des instances publiques" }, "disable": { "message": "Désactiver" }, - "unsupportedIframesHandling": { - "message": "Gestion des iframes non prises en charge" + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/gl/messages.json b/src/_locales/gl/messages.json index 0df4ab9d..7ea16955 100644 --- a/src/_locales/gl/messages.json +++ b/src/_locales/gl/messages.json @@ -83,8 +83,8 @@ "message": "Engade as túas instancias favoritas", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copiar Orixinal" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copiouse" @@ -108,5 +108,38 @@ }, "disable": { "message": "Desactivar" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/hr/messages.json b/src/_locales/hr/messages.json index 838a2af0..25c738c8 100644 --- a/src/_locales/hr/messages.json +++ b/src/_locales/hr/messages.json @@ -83,8 +83,8 @@ "message": "Dodajte svoje omiljene instance", "description": "used in the settings page" }, - "copyRaw": { - "message": "Kopiraj original" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Kopirano" @@ -108,5 +108,38 @@ }, "disable": { "message": "Deaktiviraj" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/id/messages.json b/src/_locales/id/messages.json index 8db8ba91..c78c9b39 100644 --- a/src/_locales/id/messages.json +++ b/src/_locales/id/messages.json @@ -83,8 +83,8 @@ "message": "Tambahkan server favorit Anda", "description": "used in the settings page" }, - "copyRaw": { - "message": "Salin Mentah" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Disalin" @@ -108,5 +108,38 @@ }, "disable": { "message": "Nonaktifkan" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/it/messages.json b/src/_locales/it/messages.json index 3507fe28..0ad02c44 100644 --- a/src/_locales/it/messages.json +++ b/src/_locales/it/messages.json @@ -83,8 +83,8 @@ "message": "Aggiungi le tue istanze preferite", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copia grezza" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copiato" @@ -108,5 +108,38 @@ }, "disable": { "message": "Disattiva" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/ja/messages.json b/src/_locales/ja/messages.json index 3c77cf98..7ee234ec 100644 --- a/src/_locales/ja/messages.json +++ b/src/_locales/ja/messages.json @@ -83,8 +83,8 @@ "message": "好きなインスタンスを追加", "description": "used in the settings page" }, - "copyRaw": { - "message": "元のURIをコピー" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "コピーしました" @@ -108,5 +108,38 @@ }, "disable": { "message": "無効" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/jv/messages.json b/src/_locales/jv/messages.json index 40fb052b..90a2fc45 100644 --- a/src/_locales/jv/messages.json +++ b/src/_locales/jv/messages.json @@ -1,4 +1,24 @@ { + "extensionName": { + "message": "LibRedirect", + "description": "name of the extension" + }, + "extensionDescription": { + "message": "A web extension that redirects popular sites to alternative privacy-friendly frontends and backends", + "description": "description of the extension" + }, + "switchInstance": { + "message": "Switch Instance", + "description": "used in manifest.json as shortcut description" + }, + "settings": { + "message": "Settings", + "description": "used in the popup" + }, + "general": { + "message": "General", + "description": "used in the settings page" + }, "theme": { "message": "Téma", "description": "used in the settings page" @@ -11,8 +31,115 @@ "message": "Peteng", "description": "used in the settings page" }, - "extensionName": { - "message": "LibRedirect", - "description": "name of the extension" + "auto": { + "message": "Auto", + "description": "used in the settings page" + }, + "excludeFromRedirecting": { + "message": "Excluded from redirecting", + "description": "used in the settings page" + }, + "importSettings": { + "message": "Import Settings", + "description": "used in the settings page" + }, + "exportSettings": { + "message": "Export Settings", + "description": "used in the settings page" + }, + "resetSettings": { + "message": "Reset Settings", + "description": "used in the settings page" + }, + "enable": { + "message": "Enable", + "description": "used in the settings page" + }, + "showInPopup": { + "message": "Show in popup", + "description": "used in the settings page" + }, + "frontend": { + "message": "Frontend", + "description": "used in the settings page" + }, + "redirectType": { + "message": "Redirect Type", + "description": "used in the settings page" + }, + "both": { + "message": "both", + "description": "used in the settings page" + }, + "onlyEmbedded": { + "message": "only embedded", + "description": "used in the settings page" + }, + "onlyNotEmbedded": { + "message": "only not embedded", + "description": "used in the settings page" + }, + "addYourFavoriteInstances": { + "message": "Add your favorite instances", + "description": "used in the settings page" + }, + "copyOriginal": { + "message": "Copy Original" + }, + "copied": { + "message": "Copied" + }, + "redirectToOriginal": { + "message": "Redirect to original", + "description": "Used in context menus when right clicking on a page/tab" + }, + "redirectLink": { + "message": "Attempt to redirect", + "description": "Used in context menus when right clicking on a hyperlink" + }, + "about": { + "message": "About" + }, + "unsupportedIframesHandling": { + "message": "Unsupported embeds handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/ko/messages.json b/src/_locales/ko/messages.json index 85b72c93..c9774988 100644 --- a/src/_locales/ko/messages.json +++ b/src/_locales/ko/messages.json @@ -83,8 +83,8 @@ "message": "Add your favorite instances", "description": "used in the settings page" }, - "copyRaw": { - "message": "Raw 복사" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "복사됨" @@ -99,5 +99,47 @@ }, "about": { "message": "About" + }, + "unsupportedIframesHandling": { + "message": "Unsupported iframes handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } } \ No newline at end of file diff --git a/src/_locales/nb_NO/messages.json b/src/_locales/nb_NO/messages.json index 46860019..ac7accd4 100644 --- a/src/_locales/nb_NO/messages.json +++ b/src/_locales/nb_NO/messages.json @@ -83,8 +83,8 @@ "message": "Add your favorite instances", "description": "used in the settings page" }, - "copyRaw": { - "message": "Kopier originallenke" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Kopiert" @@ -99,5 +99,47 @@ }, "about": { "message": "About" + }, + "unsupportedIframesHandling": { + "message": "Unsupported iframes handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } } \ No newline at end of file diff --git a/src/_locales/nl/messages.json b/src/_locales/nl/messages.json index a4c6fbba..07dd6ec7 100644 --- a/src/_locales/nl/messages.json +++ b/src/_locales/nl/messages.json @@ -83,8 +83,8 @@ "message": "Toevoegen aan favoriete instanties", "description": "used in the settings page" }, - "copyRaw": { - "message": "Onbewerkte code kopiëren" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Gekopieerd" @@ -108,5 +108,38 @@ }, "disable": { "message": "Uitschakelen" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/pl/messages.json b/src/_locales/pl/messages.json index d9cb8cde..818c1fb9 100644 --- a/src/_locales/pl/messages.json +++ b/src/_locales/pl/messages.json @@ -83,8 +83,8 @@ "message": "Dodaj ulubione instancje", "description": "used in the settings page" }, - "copyRaw": { - "message": "Skopiuj nieprzetworzony" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Skopiowano" @@ -108,5 +108,38 @@ }, "disable": { "message": "Wyłącz" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/pt/messages.json b/src/_locales/pt/messages.json index 5340cb1b..a29c9a07 100644 --- a/src/_locales/pt/messages.json +++ b/src/_locales/pt/messages.json @@ -83,8 +83,8 @@ "message": "Adicionar a sua instância favorita", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copiar URL original" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copiado" @@ -99,5 +99,47 @@ }, "about": { "message": "Sobre" + }, + "unsupportedIframesHandling": { + "message": "Unsupported iframes handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/pt_BR/messages.json b/src/_locales/pt_BR/messages.json index f0fc4e8a..2fd4383e 100644 --- a/src/_locales/pt_BR/messages.json +++ b/src/_locales/pt_BR/messages.json @@ -83,8 +83,8 @@ "message": "Adicione sua instância favorita", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copiar URL original" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copiado" @@ -100,7 +100,46 @@ "about": { "message": "Sobre" }, + "unsupportedIframesHandling": { + "message": "Unsupported iframes handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, "disable": { "message": "Desativar" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/ro/messages.json b/src/_locales/ro/messages.json index 6c530d3b..1bf62182 100644 --- a/src/_locales/ro/messages.json +++ b/src/_locales/ro/messages.json @@ -83,8 +83,8 @@ "message": "Add your favorite instances", "description": "used in the settings page" }, - "copyRaw": { - "message": "Copiați Raw" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Copiat" @@ -108,5 +108,38 @@ }, "disable": { "message": "Dezactivează" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/ru/messages.json b/src/_locales/ru/messages.json index a8920dd6..a958bb5d 100644 --- a/src/_locales/ru/messages.json +++ b/src/_locales/ru/messages.json @@ -83,8 +83,8 @@ "message": "Добавить в избранное", "description": "used in the settings page" }, - "copyRaw": { - "message": "Копировать изначальную" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Скопировано" @@ -108,5 +108,38 @@ }, "disable": { "message": "Выключить" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/sr/messages.json b/src/_locales/sr/messages.json index b14cb2dc..e4a71835 100644 --- a/src/_locales/sr/messages.json +++ b/src/_locales/sr/messages.json @@ -83,8 +83,8 @@ "message": "Додајте своје омиљене инстанце", "description": "used in the settings page" }, - "copyRaw": { - "message": "Копирајте необрађену коду" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Копирано" @@ -99,5 +99,47 @@ }, "about": { "message": "О" + }, + "unsupportedIframesHandling": { + "message": "Unsupported iframes handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/tr/messages.json b/src/_locales/tr/messages.json index e350a9fa..c77210c0 100644 --- a/src/_locales/tr/messages.json +++ b/src/_locales/tr/messages.json @@ -83,8 +83,8 @@ "message": "Sevdiğiniz örnekleri ekleyin", "description": "used in the settings page" }, - "copyRaw": { - "message": "Ham Kopyala" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Kopyalandı" @@ -108,5 +108,38 @@ }, "disable": { "message": "Devre dışı bırak" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/uk/messages.json b/src/_locales/uk/messages.json index 0b3b7f0f..14763b6b 100644 --- a/src/_locales/uk/messages.json +++ b/src/_locales/uk/messages.json @@ -83,8 +83,8 @@ "message": "Додати свої улюблені сервери", "description": "used in the settings page" }, - "copyRaw": { - "message": "Копіювати оригінал посилання" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Скопійовано" @@ -108,5 +108,38 @@ }, "disable": { "message": "Вимкнути" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/vi/messages.json b/src/_locales/vi/messages.json index dac9e4a7..1ad0a2e8 100644 --- a/src/_locales/vi/messages.json +++ b/src/_locales/vi/messages.json @@ -83,8 +83,8 @@ "message": "Thêm những instance bạn yêu thích", "description": "used in the settings page" }, - "copyRaw": { - "message": "Sao chép liên kết gốc" + "copyOriginal": { + "message": "Copy Original" }, "copied": { "message": "Đã Sao Chép" @@ -108,5 +108,38 @@ }, "disable": { "message": "Tắt" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/_locales/zh_Hans/messages.json b/src/_locales/zh_Hans/messages.json index 7cb1f511..0584edf0 100644 --- a/src/_locales/zh_Hans/messages.json +++ b/src/_locales/zh_Hans/messages.json @@ -56,7 +56,7 @@ "description": "used in the settings page" }, "showInPopup": { - "message": "显示于弹出窗口", + "message": "显示在弹窗中", "description": "used in the settings page" }, "frontend": { @@ -68,22 +68,22 @@ "description": "used in the settings page" }, "both": { - "message": "两者", + "message": "所有页面", "description": "used in the settings page" }, "onlyEmbedded": { - "message": "仅当嵌入时", + "message": "仅嵌入页面", "description": "used in the settings page" }, "onlyNotEmbedded": { - "message": "仅当非嵌入时", + "message": "仅常规页面", "description": "used in the settings page" }, "addYourFavoriteInstances": { "message": "添加您喜欢的实例", "description": "used in the settings page" }, - "copyRaw": { + "copyOriginal": { "message": "复制原始链接" }, "copied": { @@ -94,19 +94,52 @@ "description": "Used in context menus when right clicking on a page/tab" }, "redirectLink": { - "message": "尝试重定向", + "message": "尝试进行重定向", "description": "Used in context menus when right clicking on a hyperlink" }, "about": { "message": "关于" }, "unsupportedIframesHandling": { - "message": "对不支持的 iframe 的处理方式" + "message": "处理未支持的嵌入页面的方式" }, "fetchPublicInstances": { "message": "获取公共实例" }, "disable": { "message": "禁用" + }, + "pingInstances": { + "message": "对实例进行测速" + }, + "exportSettingsToSync": { + "message": "导出设置到同步服务" + }, + "importSettingsFromSync": { + "message": "从同步服务导入设置" + }, + "services": { + "message": "服务" + }, + "service": { + "message": "服务" + }, + "bookmarksMenu": { + "message": "书签菜单" + }, + "redirectOnlyInIncognito": { + "message": "仅在隐私模式下重定向" + }, + "bypass": { + "message": "绕过" + }, + "block": { + "message": "屏蔽" + }, + "searchHint": { + "message": "请将 LibRedirect 设为默认搜索引擎。对于 Chromium 的操作方法,点击此处了解。" + }, + "redirect": { + "message": "重定向" } } diff --git a/src/_locales/zh_Hant/messages.json b/src/_locales/zh_Hant/messages.json index 86675479..12218d75 100644 --- a/src/_locales/zh_Hant/messages.json +++ b/src/_locales/zh_Hant/messages.json @@ -1,15 +1,12 @@ { - "both": { - "message": "全部", - "description": "used in the settings page" - }, - "copied": { - "message": "已複製" - }, "extensionName": { "message": "LibRedirect", "description": "name of the extension" }, + "extensionDescription": { + "message": "WebExtension 擴充套件,可將熱門網站重新導向至隱私友好的替代服務", + "description": "description of the extension" + }, "switchInstance": { "message": "切換執行個體", "description": "used in manifest.json as shortcut description" @@ -18,10 +15,6 @@ "message": "設定", "description": "used in the popup" }, - "extensionDescription": { - "message": "WebExtension 擴充套件,可將熱門網站重新導向至隱私友好的替代服務", - "description": "description of the extension" - }, "general": { "message": "一般", "description": "used in the settings page" @@ -42,14 +35,14 @@ "message": "自動", "description": "used in the settings page" }, - "importSettings": { - "message": "匯入設定", - "description": "used in the settings page" - }, "excludeFromRedirecting": { "message": "不作重新導向", "description": "used in the settings page" }, + "importSettings": { + "message": "匯入設定", + "description": "used in the settings page" + }, "exportSettings": { "message": "匯出設定", "description": "used in the settings page" @@ -74,6 +67,14 @@ "message": "重新導向類型", "description": "used in the settings page" }, + "both": { + "message": "全部", + "description": "used in the settings page" + }, + "onlyEmbedded": { + "message": "僅內嵌", + "description": "used in the settings page" + }, "onlyNotEmbedded": { "message": "非內嵌", "description": "used in the settings page" @@ -82,6 +83,12 @@ "message": "新增常用執行個體", "description": "used in the settings page" }, + "copyOriginal": { + "message": "Copy Original" + }, + "copied": { + "message": "已複製" + }, "redirectToOriginal": { "message": "重新導向到原網址", "description": "Used in context menus when right clicking on a page/tab" @@ -90,14 +97,49 @@ "message": "嘗試重新導向", "description": "Used in context menus when right clicking on a hyperlink" }, - "copyRaw": { - "message": "複製原始網址" - }, "about": { "message": "關於" }, - "onlyEmbedded": { - "message": "僅內嵌", - "description": "used in the settings page" + "unsupportedIframesHandling": { + "message": "Unsupported iframes handling" + }, + "fetchPublicInstances": { + "message": "Fetch public instances" + }, + "disable": { + "message": "Disable" + }, + "pingInstances": { + "message": "Ping Instances" + }, + "exportSettingsToSync": { + "message": "Export Settings to Sync" + }, + "importSettingsFromSync": { + "message": "Import Settings from Sync" + }, + "services": { + "message": "Services" + }, + "service": { + "message": "Service" + }, + "bookmarksMenu": { + "message": "Bookmarks menu" + }, + "redirectOnlyInIncognito": { + "message": "Redirect Only in Incognito" + }, + "bypass": { + "message": "Bypass" + }, + "block": { + "message": "Block" + }, + "searchHint": { + "message": "Set LibRedirect as Default Search Engine. For how to do in chromium browsers, click here." + }, + "redirect": { + "message": "Redirect" } -} +} \ No newline at end of file diff --git a/src/pages/options_src/Services/RedirectType.svelte b/src/pages/options_src/Services/RedirectType.svelte index 29c169bc..69ea2b73 100644 --- a/src/pages/options_src/Services/RedirectType.svelte +++ b/src/pages/options_src/Services/RedirectType.svelte @@ -37,15 +37,15 @@ Object.values(serviceConf.frontends).some(frontend => frontend.embeddable) ) { values = [ - { value: "both", name: "both" }, - { value: "main_frame", name: "Only Not Embedded" }, + { value: "both", name: browser.i18n.getMessage("both") || "Both" }, + { value: "main_frame", name: browser.i18n.getMessage("onlyNotEmbedded") || "Only Not Embedded" }, ] if (serviceOptions.redirectType == "sub_frame") { serviceOptions.redirectType = "main_frame" options.set(_options) } } else { - values = [{ value: "main_frame", name: "Only Not Embedded" }] + values = [{ value: "main_frame", name: browser.i18n.getMessage("onlyNotEmbedded") || "Only Not Embedded" }] serviceOptions.redirectType = "main_frame" options.set(_options) } -- cgit 1.4.1 From 7c9a23503783a6397b628541b50e3081901cd96f Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 17 Aug 2024 21:59:56 +0300 Subject: Added Dropdown is searchable hint https://github.com/libredirect/browser_extension/issues/961 --- src/pages/options_src/Services/Services.svelte | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/pages') diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index 93afcded..481afb83 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -24,6 +24,8 @@ unsubscribeConfig() }) let selectedService = $url.hash.startsWith("#services:") ? $url.hash.split(":")[1] : "youtube" + let hideServiceSelection = false + let hideFrontendSelection = false $: serviceConf = _config.services[selectedService] $: serviceOptions = _options[selectedService] $: frontendWebsite = serviceConf.frontends[serviceOptions.frontend].url @@ -38,7 +40,7 @@ {browser.i18n.getMessage("service") || "Service"} -
+
(hideServiceSelection = true)} on:keydown={null}> { selectedService = e.detail.value window.location.hash = `services:${e.detail.value}` + hideServiceSelection = false }} + on:focus={() => (hideServiceSelection = true)} + on:blur={() => (hideServiceSelection = false)} items={[ ...servicesEntries.map(([serviceKey, service]) => { return { value: serviceKey, label: service.name } @@ -58,9 +63,17 @@ {item.label}
-
- - {selection.label} +
+ {#if !hideServiceSelection} + + {selection.label} + {:else} + {browser.i18n.getMessage("search_service") || "Search Service"} + {/if}
🮦
@@ -103,7 +116,7 @@ {browser.i18n.getMessage("frontend") || "Frontend"} -
+
(hideFrontendSelection = true)} on:keydown={null}> { serviceOptions.frontend = e.detail.value options.set(_options) + hideFrontendSelection = false }} + on:focus={() => (hideFrontendSelection = true)} + on:blur={() => (hideFrontendSelection = false)} items={[ ...frontendEntries.map(([frontendId, frontend]) => ({ value: frontendId, @@ -126,8 +142,12 @@ {item.label}
- - {selection.label} + {#if !hideFrontendSelection} + + {selection.label} + {:else} + {browser.i18n.getMessage("search_frontend") || "Search Frontend"} + {/if}
🮦
-- cgit 1.4.1 From a94ad51a346d58f090e4d9a26fe5e78f15474acd Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 18 Aug 2024 13:00:57 +0300 Subject: Allowing to import from previous version https://github.com/libredirect/browser_extension/issues/961 --- src/assets/javascripts/services.js | 134 +++++++++------------ src/pages/background/background.js | 8 +- .../options_src/General/SettingsButtons.svelte | 28 ++--- src/pages/options_src/Services/Services.svelte | 2 +- src/pages/popup_src/App.svelte | 2 +- 5 files changed, 76 insertions(+), 98 deletions(-) (limited to 'src/pages') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 417f66c3..9b6ef325 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -831,99 +831,86 @@ const defaultInstances = { ytify: ["https://ytify.netlify.app"], } +async function getDefaults() { + let config = await utils.getConfig() + let options = {} + for (const service in config.services) { + options[service] = {} + for (const defaultOption in config.services[service].options) { + options[service][defaultOption] = config.services[service].options[defaultOption] + } + for (const frontend in config.services[service].frontends) { + if (config.services[service].frontends[frontend].instanceList) { + options[frontend] = [] + } + } + } + options.exceptions = { + url: [], + regex: [], + } + options.theme = "detect" + options.popupServices = ["youtube", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] + options.fetchInstances = "github" + options.redirectOnlyInIncognito = false + options = { ...options, ...defaultInstances } + return options +} + function initDefaults() { return new Promise(resolve => { browser.storage.local.clear(async () => { - let config = await utils.getConfig() - let options = {} - for (const service in config.services) { - options[service] = {} - for (const defaultOption in config.services[service].options) { - options[service][defaultOption] = config.services[service].options[defaultOption] - } - for (const frontend in config.services[service].frontends) { - if (config.services[service].frontends[frontend].instanceList) { - options[frontend] = [] - } - } - } - options.exceptions = { - url: [], - regex: [], - } - options.theme = "detect" - options.popupServices = ["youtube", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] - options.fetchInstances = "github" - options.redirectOnlyInIncognito = false - - options = { ...options, ...defaultInstances } - + options = await getDefaults() browser.storage.local.set({ options }, () => resolve()) }) }) } -function upgradeOptions() { - return new Promise(async resolve => { - let options = await utils.getOptions() - - browser.storage.local.clear(() => { - browser.storage.local.set({ options }, () => { - resolve() - }) - }) - }) -} - -function processUpdate() { +function processUpdate(_options) { return new Promise(async resolve => { - let frontends = [] const config = await utils.getConfig() - let options = await utils.getOptions() - for (const service in config.services) { - if (!options[service]) options[service] = {} + let options = _options ?? await utils.getOptions() - if (!(options[service].frontend in config.services[service].frontends)) { - options[service] = config.services[service].options // Reset settings for service - delete options[options[service].frontend] // Remove deprecated frontend - } + const defaults = await getDefaults() - for (const defaultOption in config.services[service].options) { - if (!(defaultOption in options[service])) { - options[service][defaultOption] = config.services[service].options[defaultOption] + // Remove any unknown option or subOption + for (const optionName in options) { + if (!(optionName in defaults)) delete options[optionName] + else if (typeof optionName === 'object' && optionName !== null) { + for (const subOptionName in options[optionName]) { + if (!(subOptionName in defaults[optionName])) delete options[optionName][subOptionName] } } + } + + // Remove any unknwon popupService + options.popupServices = options.popupServices.filter(service => service in config.services) + + // Add missing options + for (const [defaultName, defaultValue] of Object.entries(defaults)) { + if (!(defaultName in options)) { + options[defaultName] = defaultValue + } + } - for (const frontend in config.services[service].frontends) { - frontends.push(frontend) - if (!(frontend in options) && config.services[service].frontends[frontend].instanceList) { - options[frontend] = defaultInstances[frontend] || [] - } + for (const [serviceName, serviceValue] of Object.entries(config.services)) { + // Reset service options if selected frontend is deprecated + if (!(options[serviceName].frontend in serviceValue.frontends)) { + options[serviceName] = serviceValue.options } - for (const frontend of options.popupServices) { - if (!Object.keys(config.services).includes(frontend)) { - const i = options.popupServices.indexOf(frontend) - if (i > -1) options.popupServices.splice(i, 1) + // Add a default service option if it's not present + for (const optionName in serviceValue.options) { + if (!(optionName in options[serviceName])) { + options[serviceName][optionName] = serviceValue.options[optionName] } } } - const general = ["theme", "popupServices", "fetchInstances", "redirectOnlyInIncognito"] - const combined = [ - ...Object.keys(config.services), - ...frontends, - ...general, - "exceptions", - "popupServices", - "version", - ] - for (const key in options) { - if (combined.indexOf(key) < 0) { - delete options[key] // Remove any unknown settings in options - } - } - browser.storage.local.set({ options }, () => { - resolve() + + browser.storage.local.clear(() => { + browser.storage.local.set({ options }, () => { + resolve(options) + }) }) }) } @@ -973,7 +960,6 @@ export default { computeService, reverse, initDefaults, - upgradeOptions, processUpdate, copyRaw, switchInstance, diff --git a/src/pages/background/background.js b/src/pages/background/background.js index d42e5027..576365bd 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -13,14 +13,8 @@ browser.runtime.onInstalled.addListener(async details => { if (!(await utils.getOptions())) { await servicesHelper.initDefaults() } - browser.runtime.openOptionsPage() } else if (details.reason == "update") { - if (details.previousVersion == "2.5.2") { - await servicesHelper.upgradeOptions() - await servicesHelper.processUpdate() - } else { - await servicesHelper.processUpdate() - } + await servicesHelper.processUpdate() } } }) diff --git a/src/pages/options_src/General/SettingsButtons.svelte b/src/pages/options_src/General/SettingsButtons.svelte index 2f574199..29b756d2 100644 --- a/src/pages/options_src/General/SettingsButtons.svelte +++ b/src/pages/options_src/General/SettingsButtons.svelte @@ -20,14 +20,12 @@ const reader = new FileReader() reader.readAsText(importSettingsFiles[0]) reader.onload = async () => { - const data = JSON.parse(reader.result) - if ("theme" in data && data.version == browser.runtime.getManifest().version) { - browser.storage.local.clear(async () => { - options.set(data) - }) - } else { - alert("Incompatible settings") + let data = JSON.parse(reader.result) + if (data.version != browser.runtime.getManifest().version) { + alert("Importing from a previous version. Be careful") } + data = await servicesHelper.processUpdate(data) + options.set(data) } reader.onerror = error => { console.log("error", error) @@ -51,20 +49,20 @@ } async function importSettingsSync() { - browser.storage.sync.get({ options }, r => { - const optionsSync = r.options - if (optionsSync.version == browser.runtime.getManifest().version) { - options.set(optionsSync) - } else { - alert("Error") + browser.storage.sync.get({ options }, async r => { + let data = r.options + if (data.version != browser.runtime.getManifest().version) { + alert("Importing from a previous version. Be careful") } + data = await servicesHelper.processUpdate(data) + options.set(data) }) } async function resetSettings() { browser.storage.local.clear(async () => { - await servicesHelper.initDefaults() - options.set(await utils.getOptions()) + const data = await servicesHelper.initDefaults() + options.set(data) }) } diff --git a/src/pages/options_src/Services/Services.svelte b/src/pages/options_src/Services/Services.svelte index 481afb83..6b16e824 100644 --- a/src/pages/options_src/Services/Services.svelte +++ b/src/pages/options_src/Services/Services.svelte @@ -72,7 +72,7 @@ {selection.label} {:else} - {browser.i18n.getMessage("search_service") || "Search Service"} + {browser.i18n.getMessage("searchService") || "Search Service"} {/if}
🮦
diff --git a/src/pages/popup_src/App.svelte b/src/pages/popup_src/App.svelte index 3409052d..2bd16169 100644 --- a/src/pages/popup_src/App.svelte +++ b/src/pages/popup_src/App.svelte @@ -88,7 +88,7 @@ diff --git a/src/pages/messages/index.html b/src/pages/messages/index.html new file mode 100644 index 00000000..8701c152 --- /dev/null +++ b/src/pages/messages/index.html @@ -0,0 +1,14 @@ + + + + + + + Settings + + + + + + + diff --git a/src/pages/messages/no_instance.html b/src/pages/messages/no_instance.html deleted file mode 100644 index 55e5fac7..00000000 --- a/src/pages/messages/no_instance.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - No instances found - - - - -
-

LibRedirect: You have no instance selected for this frontend

-
- - diff --git a/src/pages/messages_src/App.svelte b/src/pages/messages_src/App.svelte new file mode 100644 index 00000000..b08a143b --- /dev/null +++ b/src/pages/messages_src/App.svelte @@ -0,0 +1,132 @@ + + +{#if _options && _config} +
+ {#if window.location.search.includes("message=disabled")} +
+

You disabled redirections for this service

+ +
+ {:else if window.location.search.includes("message=no_instance")} +
+

You have no instance selected for this frontend

+ +
+ {/if} +
+{:else} +

Loading...

+{/if} + + diff --git a/src/pages/messages_src/main.js b/src/pages/messages_src/main.js new file mode 100644 index 00000000..c4012f4a --- /dev/null +++ b/src/pages/messages_src/main.js @@ -0,0 +1,7 @@ +import App from "./App.svelte" + +const app = new App({ + target: document.body, +}) + +export default app diff --git a/src/pages/messages_src/stores.js b/src/pages/messages_src/stores.js new file mode 100644 index 00000000..782f6064 --- /dev/null +++ b/src/pages/messages_src/stores.js @@ -0,0 +1,5 @@ +import { writable } from "svelte/store" + +export const options = writable(null) +export const config = writable(null) +export const page = writable("general") diff --git a/src/pages/options_src/App.svelte b/src/pages/options_src/App.svelte index 565aacef..1c4830bf 100644 --- a/src/pages/options_src/App.svelte +++ b/src/pages/options_src/App.svelte @@ -2,7 +2,7 @@ const browser = window.browser || window.chrome import General from "./General/General.svelte" - import url from './url' + import url from "./url" import utils from "../../assets/javascripts/utils.js" import { onDestroy } from "svelte" import servicesHelper from "../../assets/javascripts/services.js" @@ -37,51 +37,15 @@ config.set(await utils.getConfig()) }) - const dark = { - text: "#fff", - bgMain: "#121212", - bgSecondary: "#202020", - active: "#fbc117", - danger: "#f04141", - lightGrey: "#c3c3c3", - } - const light = { - text: "black", - bgMain: "white", - bgSecondary: "#e4e4e4", - active: "#fb9817", - danger: "#f04141", - lightGrey: "#c3c3c3", - } - let cssVariables - $: if (_options) { - if (_options.theme == "dark") { - cssVariables = dark - } else if (_options.theme == "light") { - cssVariables = light - } else if (window.matchMedia("(prefers-color-scheme: dark)").matches) { - cssVariables = dark - } else { - cssVariables = light - } - } + let style + $: if (_options) style = utils.style(_options, window) const dir = ["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage()) ? "rtl" : "ltr" document.body.dir = dir {#if _options && _config} -
+
{#if !$url.hash || $url.hash == "#general"} diff --git a/src/pages/options_src/Services/Instances.svelte b/src/pages/options_src/Services/Instances.svelte index 32425b80..4e5d1e7d 100644 --- a/src/pages/options_src/Services/Instances.svelte +++ b/src/pages/options_src/Services/Instances.svelte @@ -64,16 +64,9 @@ pingCache[instance] = colorTime(time) } } - function randomInstances(n) { - let instances = [] - for (let i = 0; i < n; i++) { - instances.push(redirects[selectedFrontend]["clearnet"][Math.floor(Math.random() * allInstances.length)]) - } - return instances - } async function autoPickInstance() { - const instances = randomInstances(5) + const instances = utils.randomInstances(redirects[selectedFrontend]["clearnet"], 5) const myInstancesCache = [] for (const instance of instances) { pingCache[instance] = { color: "lightblue", value: "pinging..." } @@ -81,9 +74,7 @@ pingCache[instance] = colorTime(time) myInstancesCache.push([instance, time]) } - myInstancesCache.sort(function (a, b) { - return a[1] - b[1] - }) + myInstancesCache.sort((a, b) => a[1] - b[1]) _options[selectedFrontend].push(myInstancesCache[0][0]) options.set(_options) diff --git a/src/pages/popup_src/App.svelte b/src/pages/popup_src/App.svelte index 8f958a3e..f6699312 100644 --- a/src/pages/popup_src/App.svelte +++ b/src/pages/popup_src/App.svelte @@ -38,48 +38,12 @@ let _page page.subscribe(val => (_page = val)) - const dark = { - text: "#fff", - bgMain: "#121212", - bgSecondary: "#202020", - active: "#fbc117", - danger: "#f04141", - lightGrey: "#c3c3c3", - } - const light = { - text: "black", - bgMain: "white", - bgSecondary: "#e4e4e4", - active: "#fb9817", - danger: "#f04141", - lightGrey: "#c3c3c3", - } - let cssVariables - $: if (_options) { - if (_options.theme == "dark") { - cssVariables = dark - } else if (_options.theme == "light") { - cssVariables = light - } else if (window.matchMedia("(prefers-color-scheme: dark)").matches) { - cssVariables = dark - } else { - cssVariables = light - } - } + let style + $: if (_options) style = utils.style(_options, window) {#if _options && _config} -
+
{:else} -- cgit 1.4.1 From 1492345b0d2f0f4d6d4a7a6f8814596785a472b0 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 29 Aug 2024 15:29:51 +0300 Subject: Added message popup for Server Errors https://github.com/libredirect/browser_extension/issues/936 --- src/assets/javascripts/services.js | 10 ++++++ src/pages/background/background.js | 34 +++++++++++++------- src/pages/messages_src/App.svelte | 65 +++++++++++++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 12 deletions(-) (limited to 'src/pages') diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index d1c12375..243f0598 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -667,6 +667,15 @@ function computeService(url) { resolve() }) } +export function computeFrontend(url) { + for (const service in config.services) { + for (const frontend in config.services[service].frontends) { + if (all(service, frontend, options, config).includes(utils.protocolHost(url))) { + return {service, frontend} + } + } + } +} /** * @param {URL} url @@ -975,4 +984,5 @@ export default { copyRaw, switchInstance, isException, + computeFrontend, } diff --git a/src/pages/background/background.js b/src/pages/background/background.js index db7ad087..2bb6cb57 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -58,7 +58,7 @@ browser.webRequest.onBeforeRequest.addListener( return null } - const newUrl = servicesHelper.redirect( + let newUrl = servicesHelper.redirect( url, details.type, originUrl, @@ -72,20 +72,16 @@ browser.webRequest.onBeforeRequest.addListener( const frontend = url.searchParams.get("frontend") const oldUrl = new URL(url.searchParams.get("url")) - browser.tabs.update({ - url: browser.runtime.getURL( - `/pages/messages/index.html?message=no_instance&url=${encodeURIComponent(oldUrl)}&frontend=${encodeURIComponent(frontend)}` - ), - }) + newUrl = browser.runtime.getURL( + `/pages/messages/index.html?message=no_instance&url=${encodeURIComponent(oldUrl)}&frontend=${encodeURIComponent(frontend)}` + ) } if (!newUrl) { if (url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) { - browser.tabs.update({ - url: browser.runtime.getURL( - `/pages/messages/index.html?message=disabled&url=${encodeURIComponent(url.href)}` - ), - }) + newUrl = browser.runtime.getURL( + `/pages/messages/index.html?message=disabled&url=${encodeURIComponent(url.href)}` + ) } } @@ -108,6 +104,22 @@ browser.webRequest.onBeforeRequest.addListener( ["blocking"] ) +browser.webRequest.onHeadersReceived.addListener( + details => { + if (details.statusCode >= 501 || details.statusCode == 429 || details.statusCode == 403) { + const url = new URL(details.url) + const { service, frontend } = servicesHelper.computeFrontend(url) + if (!service) return + browser.tabs.update({ + url: browser.runtime.getURL( + `/pages/messages/index.html?message=server_error&code=${details.statusCode}=&url=${encodeURIComponent(url.href)}&frontend=${encodeURIComponent(frontend)}&service=${encodeURIComponent(service)}` + ), + }) + } + }, + { urls: [""] } +) + browser.tabs.onRemoved.addListener(tabId => { if (tabIdRedirects[tabId] != undefined) { delete tabIdRedirects[tabId] diff --git a/src/pages/messages_src/App.svelte b/src/pages/messages_src/App.svelte index b08a143b..05a78044 100644 --- a/src/pages/messages_src/App.svelte +++ b/src/pages/messages_src/App.svelte @@ -9,6 +9,7 @@ import { options, config, page } from "./stores" import Button from "../components/Button.svelte" import AutoPickIcon from "../icons/AutoPickIcon.svelte" + import SwitchInstanceIcon from "../icons/SwitchInstanceIcon.svelte" let _options const unsubscribeOptions = options.subscribe(val => { @@ -49,7 +50,7 @@ const params = new URLSearchParams(window.location.search) const oldUrl = new URL(params.get("url")) - async function autoPickInstance() { + async function autoPick() { const frontend = params.get("frontend") autoPicking = true const instances = utils.randomInstances(redirects[frontend]["clearnet"], 5) @@ -59,6 +60,10 @@ _options[frontend].push(pings[0][0]) options.set(_options) autoPicking = false + } + + async function autoPickInstance() { + await autoPick() await redirectUrl() } @@ -73,6 +78,36 @@ const newUrl = await servicesHelper.redirectAsync(oldUrl, "main_frame", null, null, false, true) browser.tabs.update({ url: newUrl }) } + + async function switchInstance() { + const newUrl = await servicesHelper.switchInstance(oldUrl) + browser.tabs.update({ url: newUrl }) + } + + async function removeInstance() { + const frontend = params.get("frontend") + const i = _options[frontend].indexOf(utils.protocolHost(oldUrl)) + _options[frontend].splice(i, 1) + options.set(_options) + const newUrl = await servicesHelper.switchInstance(oldUrl, service) + browser.tabs.update({ url: newUrl }) + } + + async function removeAndAutoPickInstance() { + const frontend = params.get("frontend") + const i = _options[frontend].indexOf(utils.protocolHost(oldUrl)) + _options[frontend].splice(i, 1) + options.set(_options) + await autoPick() + const newUrl = await servicesHelper.switchInstance(oldUrl, service) + browser.tabs.update({ url: newUrl }) + } + + async function addAutoPickInstance() { + await autoPick() + const newUrl = await servicesHelper.switchInstance(oldUrl) + browser.tabs.update({ url: newUrl }) + } {#if _options && _config} @@ -84,6 +119,34 @@ {browser.i18n.getMessage("enable") || "Enable"}
+ {:else if window.location.search.includes("message=server_error")} + +
+

Your selected instance gave out an error

+ {#if _options[params.get("frontend")].length > 1} + + + {:else} + + + {/if} +
{:else if window.location.search.includes("message=no_instance")}

You have no instance selected for this frontend

-- cgit 1.4.1 From 79e134a1873e6897107b1f2acb4437030cea2425 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 31 Aug 2024 11:47:11 +0300 Subject: small UI improvements --- src/pages/background/background.js | 29 +++++++++++++++++--------- src/pages/messages_src/App.svelte | 8 +++---- src/pages/options_src/Services/Services.svelte | 2 ++ 3 files changed, 25 insertions(+), 14 deletions(-) (limited to 'src/pages') diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 2bb6cb57..0d558b01 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -71,17 +71,21 @@ browser.webRequest.onBeforeRequest.addListener( const url = new URL(newUrl) const frontend = url.searchParams.get("frontend") const oldUrl = new URL(url.searchParams.get("url")) - - newUrl = browser.runtime.getURL( - `/pages/messages/index.html?message=no_instance&url=${encodeURIComponent(oldUrl)}&frontend=${encodeURIComponent(frontend)}` - ) + const params = new URLSearchParams({ + message: "no_instance", + url: oldUrl, + frontend: frontend, + }) + newUrl = browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`) } if (!newUrl) { if (url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) { - newUrl = browser.runtime.getURL( - `/pages/messages/index.html?message=disabled&url=${encodeURIComponent(url.href)}` - ) + const params = new URLSearchParams({ + message: "disabled", + url: url.href, + }) + newUrl = browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`) } } @@ -110,10 +114,15 @@ browser.webRequest.onHeadersReceived.addListener( const url = new URL(details.url) const { service, frontend } = servicesHelper.computeFrontend(url) if (!service) return + const params = new URLSearchParams({ + message: "server_error", + code: details.statusCode, + url: url.href, + frontend: frontend, + service: service, + }) browser.tabs.update({ - url: browser.runtime.getURL( - `/pages/messages/index.html?message=server_error&code=${details.statusCode}=&url=${encodeURIComponent(url.href)}&frontend=${encodeURIComponent(frontend)}&service=${encodeURIComponent(service)}` - ), + url: browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`), }) } }, diff --git a/src/pages/messages_src/App.svelte b/src/pages/messages_src/App.svelte index 05a78044..6d68ff5f 100644 --- a/src/pages/messages_src/App.svelte +++ b/src/pages/messages_src/App.svelte @@ -112,17 +112,17 @@ {#if _options && _config}
- {#if window.location.search.includes("message=disabled")} + {#if params.get("message") == "disabled"}

You disabled redirections for this service

- {:else if window.location.search.includes("message=server_error")} + {:else if params.get("message") == "server_error"}
-

Your selected instance gave out an error

+

Your selected instance gave out an error: {params.get("code")}

{#if _options[params.get("frontend")].length > 1} {/if}
- {:else if window.location.search.includes("message=no_instance")} + {:else if params.get("message") == "no_instance"}

You have no instance selected for this frontend