From cf45e7b8c735d1859ff377fc594a4b4cbfa597b9 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 14 May 2023 14:42:23 +0300 Subject: [PATCH] Documented the .libredirect.invalid urls better https://github.com/libredirect/browser_extension/issues/671 --- src/config.json | 30 ++++++++++++++++++----------- src/pages/background/background.js | 10 +++++++++- src/pages/messages/no_instance.html | 26 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 src/pages/messages/no_instance.html diff --git a/src/config.json b/src/config.json index d5ae1fd..b68321b 100644 --- a/src/config.json +++ b/src/config.json @@ -161,7 +161,8 @@ "proxiTok": { "name": "ProxiTok", "instanceList": true, - "url": "https://github.com/pablouser1/ProxiTok" + "url": "https://github.com/pablouser1/ProxiTok", + "localhost": true } }, "targets": [ @@ -187,7 +188,8 @@ "teddit": { "name": "Teddit", "instanceList": true, - "url": "https://codeberg.org/teddit/teddit" + "url": "https://codeberg.org/teddit/teddit", + "localhost": true } }, "targets": [ @@ -277,7 +279,8 @@ "quetre": { "name": "Quetre", "instanceList": true, - "url": "https://github.com/zyachel/quetre" + "url": "https://github.com/zyachel/quetre", + "localhost": true } }, "targets": [ @@ -297,7 +300,8 @@ "libremdb": { "name": "libremdb", "instanceList": true, - "url": "https://github.com/zyachel/libremdb" + "url": "https://github.com/zyachel/libremdb", + "localhost": true } }, "targets": [ @@ -317,8 +321,7 @@ "breezeWiki": { "name": "BreezeWiki", "instanceList": true, - "url": "https://breezewiki.com", - "localhost": true + "url": "https://breezewiki.com" } }, "targets": [ @@ -362,7 +365,8 @@ "searxng": { "name": "SearXNG", "instanceList": true, - "url": "https://github.com/searxng/searxng" + "url": "https://github.com/searxng/searxng", + "localhost": true }, "searx": { "name": "SearX", @@ -404,7 +408,8 @@ "lingva": { "name": "Lingva Translate", "instanceList": true, - "url": "https://github.com/TheDavidDelta/lingva-translate" + "url": "https://github.com/TheDavidDelta/lingva-translate", + "localhost": true }, "libreTranslate": { "name": "LibreTranslate", @@ -521,7 +526,8 @@ "dumb": { "name": "Dumb", "instanceList": true, - "url": "https://github.com/rramiachraf/dumb" + "url": "https://github.com/rramiachraf/dumb", + "localhost": true } }, "targets": [ @@ -561,7 +567,8 @@ "anonymousOverflow": { "name": "AnonymousOverflow", "instanceList": true, - "url": "https://github.com/httpjamesm/AnonymousOverflow" + "url": "https://github.com/httpjamesm/AnonymousOverflow", + "localhost": true } }, "targets": [ @@ -582,7 +589,8 @@ "biblioReads": { "name": "BiblioReads", "instanceList": true, - "url": "https://github.com/nesaku/BiblioReads" + "url": "https://github.com/nesaku/BiblioReads", + "localhost": true } }, "targets": [ diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 8071305..8e42776 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -45,7 +45,6 @@ browser.webRequest.onBeforeRequest.addListener( if (details.frameAncestors && details.frameAncestors.length > 0 && servicesHelper.isException(new URL(details.frameAncestors[0].url))) newUrl = null - console.log(servicesHelper.isException(url)) if (servicesHelper.isException(url)) { if (details.type == "main_frame") newUrl = "BYPASSTAB" @@ -53,6 +52,15 @@ browser.webRequest.onBeforeRequest.addListener( return null } + if (!newUrl) { + const match = url.href.match(/^https?:\/{2}(.*)\.libredirect\.invalid.*/) + if (match[1]) { + browser.tabs.update({ + url: browser.runtime.getURL(`/pages/messages/no_instance.html`) + }); + } + } + if (newUrl) { if (newUrl === "CANCEL") { console.log(`Canceled ${url}`) diff --git a/src/pages/messages/no_instance.html b/src/pages/messages/no_instance.html new file mode 100644 index 0000000..76ec19c --- /dev/null +++ b/src/pages/messages/no_instance.html @@ -0,0 +1,26 @@ + + + + + + + + + No instances found + + + + +
+

You have no instance selected for this frontend

+
+ + + \ No newline at end of file