From cf7afda7e00558d4e086c34c11dcf2bd098cdc28 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Tue, 1 Nov 2022 19:32:49 +0300 Subject: Improved design of sidebar and customize popup https://github.com/libredirect/libredirect/issues/369 --- src/config/config.json | 189 +++++++++++++++++++++++++++------ src/pages/options/widgets/general.ejs | 185 +++++++++++++++----------------- src/pages/options/widgets/services.ejs | 160 ++++++++++++++-------------- src/pages/stylesheets/styles.css | 17 ++- 4 files changed, 332 insertions(+), 219 deletions(-) diff --git a/src/config/config.json b/src/config/config.json index b1c4c8a4..cff06b6c 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -22,8 +22,12 @@ "frontends": { "invidious": { "preferences": { - "cookies": ["PREFS"], - "localstorage": ["dark_mode"] + "cookies": [ + "PREFS" + ], + "localstorage": [ + "dark_mode" + ] }, "name": "Invidious", "embeddable": true, @@ -59,7 +63,9 @@ }, "pipedMaterial": { "preferences": { - "localstorage": ["PREFERENCES"] + "localstorage": [ + "PREFERENCES" + ] }, "name": "Piped-Material", "embeddable": false, @@ -109,7 +115,9 @@ "frontends": { "beatbump": { "preferences": { - "localstorage": ["settings"], + "localstorage": [ + "settings" + ], "indexeddb": "beatbump" }, "name": "Beatbump", @@ -117,14 +125,26 @@ }, "hyperpipe": { "preferences": { - "localstorage": ["api", "authapi", "codec", "locale", "next", "pipedapi", "quality", "theme", "vol"], + "localstorage": [ + "api", + "authapi", + "codec", + "locale", + "next", + "pipedapi", + "quality", + "theme", + "vol" + ], "indexeddb": "hyperpipedb" }, "name": "Hyperpipe", "instanceList": true } }, - "targets": ["^https?:\\/{2}music\\.youtube\\.com(\\/|$)"], + "targets": [ + "^https?:\\/{2}music\\.youtube\\.com(\\/|$)" + ], "name": "YT Music", "options": { "enabled": true, @@ -190,7 +210,9 @@ "instanceList": true } }, - "targets": ["^https?:\\/{2}(www\\.)?instagram\\.com\\/?(p\\/|$)"], + "targets": [ + "^https?:\\/{2}(www\\.)?instagram\\.com\\/?(p\\/|$)" + ], "name": "Instagram", "options": { "enabled": true @@ -203,13 +225,18 @@ "frontends": { "proxiTok": { "preferences": { - "cookies": ["api-test_endpoints", "theme"] + "cookies": [ + "api-test_endpoints", + "theme" + ] }, "name": "ProxiTok", "instanceList": true } }, - "targets": ["^https?:\\/{2}(www\\.|)tiktok\\.com(\\/|$)"], + "targets": [ + "^https?:\\/{2}(www\\.|)tiktok\\.com(\\/|$)" + ], "name": "TikTok", "options": { "enabled": true @@ -222,7 +249,20 @@ "frontends": { "libreddit": { "preferences": { - "cookies": ["theme", "front_page", "layout", "wide", "post_sort", "comment_sort", "show_nsfw", "autoplay_videos", "use_hls", "hide_hls_notification", "subscriptions", "filters"] + "cookies": [ + "theme", + "front_page", + "layout", + "wide", + "post_sort", + "comment_sort", + "show_nsfw", + "autoplay_videos", + "use_hls", + "hide_hls_notification", + "subscriptions", + "filters" + ] }, "name": "Libreddit", "instanceList": true @@ -253,13 +293,29 @@ }, "ferrit": { "preferences": { - "cookies": ["theme", "front_page", "layout", "wide", "post_sort", "comment_sort", "show_nsfw", "autoplay_videos", "use_hls", "hide_hls_notification", "subscriptions", "filters"] + "cookies": [ + "theme", + "front_page", + "layout", + "wide", + "post_sort", + "comment_sort", + "show_nsfw", + "autoplay_videos", + "use_hls", + "hide_hls_notification", + "subscriptions", + "filters" + ] }, "name": "Ferrit", "instanceList": true } }, - "targets": ["^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?=\\/u(ser)?\\/|\\/r\\/|\\/?$)", "^https?:\\/{2}(i|(external-)?preview)\\.redd\\.it"], + "targets": [ + "^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?=\\/u(ser)?\\/|\\/r\\/|\\/?$)", + "^https?:\\/{2}(i|(external-)?preview)\\.redd\\.it" + ], "name": "Reddit", "options": { "enabled": true, @@ -277,7 +333,9 @@ "instanceList": true } }, - "targets": ["^https?:\\/{2}([im]\\.)?(stack\\.)?imgur\\.(com|io)(\\/|$)"], + "targets": [ + "^https?:\\/{2}([im]\\.)?(stack\\.)?imgur\\.(com|io)(\\/|$)" + ], "name": "Imgur", "options": { "enabled": true, @@ -291,13 +349,18 @@ "frontends": { "wikiless": { "preferences": { - "cookies": ["theme", "default_lang"] + "cookies": [ + "theme", + "default_lang" + ] }, "name": "Wikiless", "instanceList": true } }, - "targets": ["^https?:\\/{2}(?:[a-z]+\\.)*wikipedia\\.org(\\/|$)"], + "targets": [ + "^https?:\\/{2}(?:[a-z]+\\.)*wikipedia\\.org(\\/|$)" + ], "name": "Wikipedia", "options": { "enabled": false @@ -345,13 +408,17 @@ "frontends": { "quetre": { "preferences": { - "localstorage": ["theme"] + "localstorage": [ + "theme" + ] }, "name": "Quetre", "instanceList": true } }, - "targets": ["^https?:\\/{2}([a-zA-Z0-9-]+\\.)*quora\\.com(\\/|$)"], + "targets": [ + "^https?:\\/{2}([a-zA-Z0-9-]+\\.)*quora\\.com(\\/|$)" + ], "name": "Quora", "options": { "enabled": true @@ -364,13 +431,17 @@ "frontends": { "libremdb": { "preferences": { - "localstorage": ["theme"] + "localstorage": [ + "theme" + ] }, "name": "libremdb", "instanceList": true } }, - "targets": ["^https?:\\/{2}(?:www\\.|m\\.|)imdb\\.com\\/title"], + "targets": [ + "^https?:\\/{2}(?:www\\.|m\\.|)imdb\\.com\\/title" + ], "name": "IMDb", "options": { "enabled": true @@ -386,7 +457,9 @@ "instanceList": true } }, - "targets": ["^https?:\\/{2}(www\\.|)reuters\\.com(\\/|$)"], + "targets": [ + "^https?:\\/{2}(www\\.|)reuters\\.com(\\/|$)" + ], "name": "Reuters", "options": { "enabled": false @@ -402,7 +475,9 @@ "instanceList": true } }, - "targets": ["^https?:\\/{2}(?:[a-zA-Z0-9-]+\\.)?(?:fandom|wikia)\\.com(?=\\/wiki|\\/?$)"], + "targets": [ + "^https?:\\/{2}(?:[a-zA-Z0-9-]+\\.)?(?:fandom|wikia)\\.com(?=\\/wiki|\\/?$)" + ], "name": "Fandom", "options": { "enabled": true @@ -431,8 +506,18 @@ "frontends": { "librarian": { "preferences": { - "cookies": ["nsfw", "theme"], - "localstorage": ["autoplay", "autoplayNextVid", "collapseComments", "plyr", "sb_categories", "showRelated"] + "cookies": [ + "nsfw", + "theme" + ], + "localstorage": [ + "autoplay", + "autoplayNextVid", + "collapseComments", + "plyr", + "sb_categories", + "showRelated" + ] }, "name": "Librarian", "embeddable": true, @@ -444,7 +529,10 @@ "instanceList": false } }, - "targets": ["^https?:\\/{2}odysee\\.com(\\/|$)", "^https?:\\/{2}lbry\\.tv(\\/|$)"], + "targets": [ + "^https?:\\/{2}odysee\\.com(\\/|$)", + "^https?:\\/{2}lbry\\.tv(\\/|$)" + ], "name": "LBRY", "options": { "enabled": true, @@ -517,13 +605,26 @@ }, "librex": { "preferences": { - "cookies": ["bibliogram", "disable_frontends", " disable_special", "invidious", "libreddit", "nitter", "proxitok", "save", "theme", "wikiless"] + "cookies": [ + "bibliogram", + "disable_frontends", + " disable_special", + "invidious", + "libreddit", + "nitter", + "proxitok", + "save", + "theme", + "wikiless" + ] }, "name": "LibreX", "instanceList": true } }, - "targets": ["^https?:\\/{2}search\\.libredirect\\.invalid"], + "targets": [ + "^https?:\\/{2}search\\.libredirect\\.invalid" + ], "name": "Search", "options": { "enabled": true, @@ -537,14 +638,24 @@ "frontends": { "simplyTranslate": { "preferences": { - "cookies": ["from_lang", "to_lang", "tts_enabled", "use_text_fields"] + "cookies": [ + "from_lang", + "to_lang", + "tts_enabled", + "use_text_fields" + ] }, "name": "SimplyTranslate", "instanceList": true }, "lingva": { "preferences": { - "localstorage": ["isauto", "source", "target", "chakra-ui-color-mode"] + "localstorage": [ + "isauto", + "source", + "target", + "chakra-ui-color-mode" + ] }, "name": "Lingva Translate", "instanceList": true @@ -554,7 +665,10 @@ "instanceList": true } }, - "targets": ["^https?:\\/{2}translate\\.google(\\.[a-z]{2,3}){1,2}\\/", "^https?:\\/{2}translate\\.libredirect\\.invalid"], + "targets": [ + "^https?:\\/{2}translate\\.google(\\.[a-z]{2,3}){1,2}\\/", + "^https?:\\/{2}translate\\.libredirect\\.invalid" + ], "name": "Translate", "options": { "enabled": true, @@ -576,7 +690,10 @@ "singleInstance": "https://www.openstreetmap.org" } }, - "targets": ["^https?:\\/{2}maps\\.libredirect\\.invalid", "^https?:\\/{2}(((www|maps)\\.)?(google\\.).*(\\/maps)|maps\\.(google\\.).*)"], + "targets": [ + "^https?:\\/{2}maps\\.libredirect\\.invalid", + "^https?:\\/{2}(((www|maps)\\.)?(google\\.).*(\\/maps)|maps\\.(google\\.).*)" + ], "name": "Maps", "options": { "enabled": false, @@ -593,7 +710,11 @@ "instanceList": "true" } }, - "targets": ["^https?:\\/{2}send\\.libredirect\\.invalid", "^https?:\\/{2}send\\.firefox\\.com\\/?$", "^https?:\\/{2}sendfiles\\.online\\/?$"], + "targets": [ + "^https?:\\/{2}send\\.libredirect\\.invalid", + "^https?:\\/{2}send\\.firefox\\.com\\/?$", + "^https?:\\/{2}sendfiles\\.online\\/?$" + ], "name": "Send Files", "options": { "enabled": true @@ -609,7 +730,9 @@ "instanceList": true } }, - "targets": ["^https?:\\/{2}paste\\.libredirect\\.invalid"], + "targets": [ + "^https?:\\/{2}paste\\.libredirect\\.invalid" + ], "name": "Paste Text", "options": { "enabled": true @@ -630,4 +753,4 @@ "color": "grey" } } -} +} \ No newline at end of file diff --git a/src/pages/options/widgets/general.ejs b/src/pages/options/widgets/general.ejs index e24046db..ca96f1c8 100644 --- a/src/pages/options/widgets/general.ejs +++ b/src/pages/options/widgets/general.ejs @@ -1,102 +1,87 @@
-
-

General

-
-
-
-

Theme

- -
-
-

Network

- -
-
-
-

Fallback to clearnet if no instances are available for the current network

- -
-
-
-

- -
-
-
-

Latency Threshold

- - -
-
-
-

-
-
-
-
-   -   -
- -
-
-
- -
- -     - - -   - Export Settings    - - - - - Reset Settings -
-
-
-

Customize Popup

-
- - +
+

General

+
+
+
+

Theme

+ +
+
+

Network

+ +
+
+
+

Fallback to clearnet if no instances are available for the current network

+ +
+
+
+

+ +
+
+
+

Latency Threshold

+ + +
+
+
+

+
+
+
+
+   +   +
+ +
+
+
+ +
+ +     + +   Export Settings    + + + + + Reset Settings +
+
diff --git a/src/pages/options/widgets/services.ejs b/src/pages/options/widgets/services.ejs index 44c6a9f3..c3019074 100644 --- a/src/pages/options/widgets/services.ejs +++ b/src/pages/options/widgets/services.ejs @@ -1,86 +1,84 @@ <% for (const service in config.services) { -%>
-
-

<%= config.services[service].name %>

-
-
-
-

Enable

- -
- <% if (Object.keys(config.services[service].frontends).length > 1) { %> -
-

Frontend

- -
- <% if (config.services[service].embeddable) { _%> -
-

Embed Frontend

- -
- <% } _%> - <% } _%> - <% if (config.services[service].embeddable) { _%> -
-

Redirect Type

- -
- <% } _%> -
- <% for (const frontend in config.services[service].frontends) { -%> - <% if (config.services[service].frontends[frontend].instanceList) { _%> -
- <% for (const network in config.networks) { -%> -
-
-

Default Instances

-
-
-
-
-

Custom Instances

-
-
-
- - -
-
-
- <% if (network == "clearnet") { _%> -
- - -
- <% } _%> -
- <% } %> -
- <% } _%> - <% } %> +
+

<%= config.services[service].name %>

+
+
+
+

Enable

+ +
+
+

Show in Popup

+ +
+ <% if (Object.keys(config.services[service].frontends).length> 1) { %> +
+

Frontend

+ +
+ <% if (config.services[service].embeddable) { _%> +
+

Embed Frontend

+ +
+ <% } _%> <% } _%> <% if (config.services[service].embeddable) { _%> +
+

Redirect Type

+ +
+ <% } _%> +
+ <% for (const frontend in config.services[service].frontends) { -%> <% if (config.services[service].frontends[frontend].instanceList) { _%> +
+ <% for (const network in config.networks) { -%> +
+
+

Default Instances

+
+
+
+
+

Custom Instances

+
+
+
+ + +
+
+
+ <% if (network=="clearnet" ) { _%> +
+ + +
+ <% } _%> +
+ <% } %> +
+ <% } _%> <% } %>
<% } %> diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 0df2f9fa..5f2871e4 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -79,7 +79,6 @@ select { margin: 0; max-width: 500px; border-radius: 3px; - cursor: pointer; } input[type="url"], @@ -110,11 +109,19 @@ section.option-block h2 { body.option { display: flex; padding: 40px; - width: 900px; + width: 1100px; +} + +section.links { + display: flex; + flex-wrap: wrap; + flex-direction: column; + width: 300px; + max-height: 720px; } section.links div { - margin: 20px 0; + margin: 10px; width: max-content; } @@ -458,7 +465,7 @@ body div section { display: none; } -div.about > div { +div.about>div { justify-content: start; width: 520px; } @@ -480,4 +487,4 @@ input:disabled { div.about a { width: 500px; display: inline-block; -} +} \ No newline at end of file -- cgit 1.4.1 From 7bceec8cd4d21441e1da84f155fb5edf7ccd7008 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Tue, 1 Nov 2022 19:59:38 +0300 Subject: Clarified Exceptions https://github.com/libredirect/libredirect/issues/345 --- src/pages/options/widgets/general.ejs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/options/widgets/general.ejs b/src/pages/options/widgets/general.ejs index ca96f1c8..b3ff930e 100644 --- a/src/pages/options/widgets/general.ejs +++ b/src/pages/options/widgets/general.ejs @@ -36,8 +36,9 @@ +
-

+

Excluded from redirecting

@@ -55,6 +56,7 @@
+
-- cgit 1.4.1 From fa686cc6cf6a4dbf9e9d0f006ab33dece17636e5 Mon Sep 17 00:00:00 2001 From: Daniel Valentine Date: Tue, 1 Nov 2022 22:56:10 -0600 Subject: Fix link to libreddit-instances JSON. With the resumption of the Libreddit project, the repo containing the instances that I started in [ferritreader](https://github.com/ferritreader) has moved to [libreddit/libreddit-instances](https://github.com/libreddit/libreddit-instances). This commit fixes the URL for libreddit instances to point to that repo. --- src/instances/get_instances.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 5e868257..966767bd 100755 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -334,7 +334,7 @@ def bibliogram(): def libreddit(): - fetchJsonList('libreddit', 'Libreddit', 'https://github.com/ferritreader/libreddit-instances/raw/master/instances.json', + fetchJsonList('libreddit', 'Libreddit', 'https://github.com/libreddit/libreddit-instances/raw/master/instances.json', {'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}, True) -- cgit 1.4.1 From 1324a81f0c61bdbdf181b9834e6980655d2bc7be Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 2 Nov 2022 15:57:18 +0000 Subject: Update chromium.md --- chromium.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chromium.md b/chromium.md index 3f3693d2..9d1bcd4f 100644 --- a/chromium.md +++ b/chromium.md @@ -8,6 +8,8 @@ Updates are automatic +**NOTE:** If this way failed. Then try the Windows, MacOS way. + ## Windows, MacOS - Download the latest release [libredirect-2.3.4.zip](https://github.com/libredirect/libredirect/releases/download/v2.3.4/libredirect-2.3.4.zip) -- cgit 1.4.1 From 80c918031451e98b3500b7e6d80a11cf43db673c Mon Sep 17 00:00:00 2001 From: Daniel Valentine Date: Tue, 8 Nov 2022 18:57:50 -0700 Subject: Remove Ferrit. --- src/config/config.json | 24 ++---------------------- src/instances/get_instances.py | 6 ------ 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/config/config.json b/src/config/config.json index cff06b6c..c05eb3ad 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -290,26 +290,6 @@ }, "name": "Teddit", "instanceList": true - }, - "ferrit": { - "preferences": { - "cookies": [ - "theme", - "front_page", - "layout", - "wide", - "post_sort", - "comment_sort", - "show_nsfw", - "autoplay_videos", - "use_hls", - "hide_hls_notification", - "subscriptions", - "filters" - ] - }, - "name": "Ferrit", - "instanceList": true } }, "targets": [ @@ -319,7 +299,7 @@ "name": "Reddit", "options": { "enabled": true, - "frontend": "ferrit" + "frontend": "libreddit" }, "imageType": "png", "embeddable": false, @@ -753,4 +733,4 @@ "color": "grey" } } -} \ No newline at end of file +} diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py index 966767bd..913ee1c4 100755 --- a/src/instances/get_instances.py +++ b/src/instances/get_instances.py @@ -343,11 +343,6 @@ def teddit(): {'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}, False) -def ferrit(): - fetchJsonList('ferrit', 'Ferrit', 'https://raw.githubusercontent.com/ferritreader/ferrit-instances/master/instances.json', - {'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}, True) - - def wikiless(): fetchJsonList('wikiless', 'Wikiless', 'https://wikiless.org/instances.json', {'clearnet': 'url', 'tor': 'onion', 'i2p': 'i2p', 'loki': None}, False) @@ -505,7 +500,6 @@ nitter() bibliogram() libreddit() teddit() -ferrit() wikiless() scribe() quetre() -- cgit 1.4.1 From f47f9f51ea16b14e950a7efc34e3d3a15a136128 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 11 Nov 2022 06:11:36 +0300 Subject: fixed medium archive links redirecting https://github.com/libredirect/libredirect/issues/527 --- src/assets/javascripts/services.js | 2 +- src/config/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 432420fb..bcf35822 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -47,7 +47,7 @@ function all(service, frontend, options, config, redirects) { function regexArray(service, url, config) { if (config.services[service].targets == "datajson") { - if (targets[service].includes(utils.protocolHost(url))) return true + if (targets[service].startsWith(utils.protocolHost(url))) return true } else { const targetList = config.services[service].targets for (const targetString in targetList) { diff --git a/src/config/config.json b/src/config/config.json index c05eb3ad..7b81d9f2 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -357,7 +357,7 @@ } }, "targets": [ - "(?:.*\\.)*(? Date: Sat, 12 Nov 2022 11:54:34 +0300 Subject: Fixed not redirecting https://github.com/libredirect/libredirect/issues/525 --- .prettierignore | 9 --------- package.json | 13 +------------ src/assets/javascripts/services.js | 14 +++++++++++--- src/config/config.json | 1 - src/pages/background/background.js | 1 - src/pages/options/widgets/services.js | 34 +++++++++++++++++++--------------- 6 files changed, 31 insertions(+), 41 deletions(-) delete mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index d789b742..00000000 --- a/.prettierignore +++ /dev/null @@ -1,9 +0,0 @@ -web-ext-artifacts/ -.DS_Store -nod -node_modules -package-lock.json -src/instances/data.json -src/instances/blacklist.json -src/_locales/ -.vscode diff --git a/package.json b/package.json index 98351dad..ade219b1 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build": "web-ext build", "test": "web-ext lint", "instances": "python3 src/instances/get_instances.py && git update-index --assume-unchanged src/instances/blacklist.json src/instances/data.json", - "ejs": "ejs src/pages/options/index.ejs -f src/config/config.json -o src/pages/options/index.html && ejs src/pages/popup/popup.ejs -f src/config/config.json -o src/pages/popup/popup.html && prettier -w src/pages/options/index.html src/pages/popup/popup.html" + "ejs": "ejs src/pages/options/index.ejs -f src/config/config.json -o src/pages/options/index.html && ejs src/pages/popup/popup.ejs -f src/config/config.json -o src/pages/popup/popup.html" }, "repository": { "type": "git", @@ -24,19 +24,8 @@ "homepage": "https://libredirect.codeberg.page", "devDependencies": { "ejs": "^3.1.8", - "prettier": "^2.7.1", "web-ext": "^7.2.0" }, - "prettier": { - "semi": false, - "tabWidth": 2, - "useTabs": true, - "arrowParens": "avoid", - "printWidth": 200, - "bracketSameLine": true, - "endOfLine": "lf", - "singleQuote": false - }, "webExt": { "ignoreFiles": [ "instances/get_instances.py", diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index bcf35822..9d80e17a 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -59,15 +59,17 @@ function regexArray(service, url, config) { } function redirect(url, type, initiator, forceRedirection) { - if (type != "main_frame" && type != "sub_frame") return + if (type != "main_frame" && type != "sub_frame" && type != "image") return let randomInstance let frontend for (const service in config.services) { + if (!forceRedirection && !options[service].enabled) continue + if (config.services[service].embeddable && type != options[service].redirectType && options[service].redirectType != "both") continue if (!config.services[service].embeddable && type != "main_frame") continue - // let targets = new RegExp(config.services[service].targets.join("|"), "i") + // let targets = new RegExp(config.services[service].targets.join("|"), "i") if (!regexArray(service, url, config)) continue // if (initiator) { // console.log(initiator.host) @@ -75,11 +77,17 @@ function redirect(url, type, initiator, forceRedirection) { // //if (all(service, null, options, config, redirects).includes(initiator.origin) && reverse(initiator) == url) return "BYPASSTAB" // } + if (Object.keys(config.services[service].frontends).length > 1) { - if (type == "sub_frame" && config.services[service].embeddable && !config.services[service].frontends[options[service].frontend].embeddable) frontend = options[service].embedFrontend + if ( + type == "sub_frame" && config.services[service].embeddable + && + !config.services[service].frontends[options[service].frontend].embeddable + ) frontend = options[service].embedFrontend else frontend = options[service].frontend } else frontend = Object.keys(config.services[service].frontends)[0] + if (config.services[service].frontends[frontend].instanceList) { let instanceList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom] if (instanceList.length === 0 && options.networkFallback) instanceList = [...options[frontend].clearnet.enabled, ...options[frontend].clearnet.custom] diff --git a/src/config/config.json b/src/config/config.json index 7b81d9f2..8b99423a 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -309,7 +309,6 @@ "frontends": { "rimgo": { "name": "rimgo", - "embeddable": true, "instanceList": true } }, diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 71fff06c..3a695048 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -56,7 +56,6 @@ browser.webRequest.onBeforeRequest.addListener( } catch { return null } - if (tabIdRedirects[details.tabId] == false) return null let newUrl = servicesHelper.redirect(url, details.type, initiator, tabIdRedirects[details.tabId]) diff --git a/src/pages/options/widgets/services.js b/src/pages/options/widgets/services.js index 37385faa..12904130 100644 --- a/src/pages/options/widgets/services.js +++ b/src/pages/options/widgets/services.js @@ -31,28 +31,32 @@ function changeFrontendsSettings(service) { for (const frontend in config.services[service].frontends) { if (config.services[service].frontends[frontend].instanceList) { const frontendDiv = document.getElementById(frontend) - if (frontend == divs[service].frontend.value) { - frontendDiv.style.display = "block" - } else { - frontendDiv.style.display = "none" + if (typeof divs[service].frontend !== "undefined") { + if (frontend == divs[service].frontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } } } } if (config.services[service].embeddable) { - if (!config.services[service].frontends[divs[service].frontend.value].embeddable) { - divs[service].embedFrontend.disabled = false - for (const frontend in config.services[service].frontends) { - if (config.services[service].frontends[frontend].embeddable) { - const frontendDiv = document.getElementById(frontend) - if (frontend == divs[service].embedFrontend.value) { - frontendDiv.style.display = "block" - } else { - frontendDiv.style.display = "none" + if (typeof divs[service].frontend !== "undefined") { + if (!config.services[service].frontends[divs[service].frontend.value].embeddable) { + divs[service].embedFrontend.disabled = false + for (const frontend in config.services[service].frontends) { + if (config.services[service].frontends[frontend].embeddable) { + const frontendDiv = document.getElementById(frontend) + if (frontend == divs[service].embedFrontend.value) { + frontendDiv.style.display = "block" + } else { + frontendDiv.style.display = "none" + } } } - } - } else if (Object.keys(config.services[service].frontends).length > 1) divs[service].embedFrontend.disabled = true + } else if (Object.keys(config.services[service].frontends).length > 1) divs[service].embedFrontend.disabled = true + } } } -- cgit 1.4.1 From 544b69602e3f48018bc4feb2cf39a44dd3b4c52a Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 12 Nov 2022 12:51:58 +0300 Subject: Added excludeTargets for more basic frontends https://github.com/libredirect/libredirect/issues/531 --- src/assets/javascripts/services.js | 23 +++++++++++++---------- src/config/config.json | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 9d80e17a..65a359e3 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -45,11 +45,15 @@ function all(service, frontend, options, config, redirects) { return instances } -function regexArray(service, url, config) { +function regexArray(service, url, config, frontend) { if (config.services[service].targets == "datajson") { if (targets[service].startsWith(utils.protocolHost(url))) return true } else { const targetList = config.services[service].targets + if (frontend && config.services[service].frontends[frontend].excludeTargets) + for (const i in config.services[service].frontends[frontend].excludeTargets) { + targetList = targetList.splice(i, 1) + } for (const targetString in targetList) { const target = new RegExp(targetList[targetString]) if (target.test(url.href)) return true @@ -69,15 +73,6 @@ function redirect(url, type, initiator, forceRedirection) { if (config.services[service].embeddable && type != options[service].redirectType && options[service].redirectType != "both") continue if (!config.services[service].embeddable && type != "main_frame") continue - // let targets = new RegExp(config.services[service].targets.join("|"), "i") - if (!regexArray(service, url, config)) continue - // if (initiator) { - // console.log(initiator.host) - // if (targets.test(initiator.host)) continue - // //if (all(service, null, options, config, redirects).includes(initiator.origin) && reverse(initiator) == url) return "BYPASSTAB" - // } - - if (Object.keys(config.services[service].frontends).length > 1) { if ( type == "sub_frame" && config.services[service].embeddable @@ -87,6 +82,14 @@ function redirect(url, type, initiator, forceRedirection) { else frontend = options[service].frontend } else frontend = Object.keys(config.services[service].frontends)[0] + // let targets = new RegExp(config.services[service].targets.join("|"), "i") + if (!regexArray(service, url, config, frontend)) continue + // if (initiator) { + // console.log(initiator.host) + // if (targets.test(initiator.host)) continue + // //if (all(service, null, options, config, redirects).includes(initiator.origin) && reverse(initiator) == url) return "BYPASSTAB" + // } + if (config.services[service].frontends[frontend].instanceList) { let instanceList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom] diff --git a/src/config/config.json b/src/config/config.json index 8b99423a..e7d468b6 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -34,6 +34,10 @@ "instanceList": true }, "piped": { + "excludeTargets": [ + 1, + 2 + ], "preferences": { "localstorage": [ "bufferGoal", @@ -62,6 +66,10 @@ "instanceList": true }, "pipedMaterial": { + "excludeTargets": [ + 1, + 2 + ], "preferences": { "localstorage": [ "PREFERENCES" @@ -82,11 +90,19 @@ "instanceList": true }, "freetube": { + "excludeTargets": [ + 1, + 2 + ], "name": "FreeTube", "embeddable": false, "instanceList": false }, "yattee": { + "excludeTargets": [ + 1, + 2 + ], "name": "Yattee", "embeddable": false, "instanceList": false @@ -732,4 +748,4 @@ "color": "grey" } } -} +} \ No newline at end of file -- cgit 1.4.1 From 01a9a55f7d1dae2469ee7f933081d065325225b1 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 13 Nov 2022 17:48:07 +0300 Subject: Some reformatting and reordering buttons --- src/pages/options/widgets/about.ejs | 59 ++++++----- src/pages/options/widgets/general.ejs | 188 ++++++++++++++++++--------------- src/pages/options/widgets/services.ejs | 161 ++++++++++++++-------------- 3 files changed, 215 insertions(+), 193 deletions(-) diff --git a/src/pages/options/widgets/about.ejs b/src/pages/options/widgets/about.ejs index 09cdab1d..a90e8b9e 100644 --- a/src/pages/options/widgets/about.ejs +++ b/src/pages/options/widgets/about.ejs @@ -1,28 +1,37 @@ -
-
-

About

-
-
-
\ No newline at end of file diff --git a/src/pages/options/widgets/general.ejs b/src/pages/options/widgets/general.ejs index b3ff930e..fef052df 100644 --- a/src/pages/options/widgets/general.ejs +++ b/src/pages/options/widgets/general.ejs @@ -1,89 +1,101 @@
-
-

General

-
-
-
-

Theme

- -
-
-

Network

- -
-
-
-

Fallback to clearnet if no instances are available for the current network

- -
-
-
-

- -
-
-
-

Latency Threshold

- - -
-
-
-
-

Excluded from redirecting

-
-
-
-
-   -   -
- -
-
-
-
- -
- -     - -   Export Settings    - - - - - Reset Settings -
- -
+
+

General

+
+
+ +
+

Theme

+ +
+ +
+

Network

+ +
+ +
+
+

Fallback to clearnet if no instances are available for the current network

+ +
+
+ +
+

+ +
+ +
+
+

Latency Threshold

+ + +
+
+ +
+ +
+

Excluded from redirecting

+
+ +
+
+
+   +   +
+ +
+
+ +
+ +
+ + + +
+ +     + + +   Export Settings    + + + + + Reset Settings + +
+ + + \ No newline at end of file diff --git a/src/pages/options/widgets/services.ejs b/src/pages/options/widgets/services.ejs index c3019074..109f6689 100644 --- a/src/pages/options/widgets/services.ejs +++ b/src/pages/options/widgets/services.ejs @@ -1,84 +1,85 @@ <% for (const service in config.services) { -%>
-
-

<%= config.services[service].name %>

-
-
-
-

Enable

- -
-
-

Show in Popup

- -
- <% if (Object.keys(config.services[service].frontends).length> 1) { %> -
-

Frontend

- -
- <% if (config.services[service].embeddable) { _%> -
-

Embed Frontend

- -
- <% } _%> <% } _%> <% if (config.services[service].embeddable) { _%> -
-

Redirect Type

- -
- <% } _%> -
- <% for (const frontend in config.services[service].frontends) { -%> <% if (config.services[service].frontends[frontend].instanceList) { _%> -
- <% for (const network in config.networks) { -%> -
-
-

Default Instances

-
-
-
-
-

Custom Instances

-
-
-
- - -
-
-
- <% if (network=="clearnet" ) { _%> -
- - -
- <% } _%> -
- <% } %> -
- <% } _%> <% } %> +
+

<%= config.services[service].name %>

+
+
+
+

Enable

+ +
+
+

Show in Popup

+ +
+ <% if (Object.keys(config.services[service].frontends).length> 1) { %> +
+

Frontend

+ +
+ <% if (config.services[service].embeddable) { _%> +
+

Embed Frontend

+ +
+ <% } _%> <% } _%> <% if (config.services[service].embeddable) { _%> +
+

Redirect Type

+ +
+ <% } _%> +
+ <% for (const frontend in config.services[service].frontends) { -%> <% if (config.services[service].frontends[frontend].instanceList) { _%> +
+ <% for (const network in config.networks) { -%> +
+ + +
+
+
+

Default Instances

+
+
+
+
+

Custom Instances

+
+
+
+ + +
+
+
+ <% if (network=="clearnet" ) { _%> + <% } _%> +
+ <% } %> +
+ <% } _%> <% } %>
<% } %> - + \ No newline at end of file -- cgit 1.4.1 From 4625aa07feb647ecbaa9a2316e778a7bcc01c605 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 21 Nov 2022 05:43:49 +0300 Subject: Fixed Bypass not working https://github.com/libredirect/libredirect/issues/475 --- src/assets/javascripts/services.js | 11 +++-------- src/config/config.json | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 65a359e3..a8d99075 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -82,14 +82,9 @@ function redirect(url, type, initiator, forceRedirection) { else frontend = options[service].frontend } else frontend = Object.keys(config.services[service].frontends)[0] - // let targets = new RegExp(config.services[service].targets.join("|"), "i") if (!regexArray(service, url, config, frontend)) continue - // if (initiator) { - // console.log(initiator.host) - // if (targets.test(initiator.host)) continue - // //if (all(service, null, options, config, redirects).includes(initiator.origin) && reverse(initiator) == url) return "BYPASSTAB" - // } + if (initiator && all(service, null, options, config, redirects).includes(initiator.origin)) return "BYPASSTAB" if (config.services[service].frontends[frontend].instanceList) { let instanceList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom] @@ -99,7 +94,7 @@ function redirect(url, type, initiator, forceRedirection) { } else if (config.services[service].frontends[frontend].singleInstance) randomInstance = config.services[service].frontends[frontend].singleInstance break } - if (!frontend) return + if (!frontend || !randomInstance) return // Here is a (temperory) space for defining constants required in 2 or more switch cases. // When possible, try have the two switch cases share all their code as done with searx and searxng. @@ -119,7 +114,7 @@ function redirect(url, type, initiator, forceRedirection) { } return [zoom, lon, lat] } - + console.log(frontend) switch (frontend) { // This is where all instance-specific code must be ran to convert the service url to one that can be understood by the frontend. case "beatbump": diff --git a/src/config/config.json b/src/config/config.json index e7d468b6..011347f5 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -702,7 +702,7 @@ "frontends": { "send": { "name": "Send", - "instanceList": "true" + "instanceList": true } }, "targets": [ -- cgit 1.4.1