From fff96565f7647ccebfb05b4fa2de96ea1cb99213 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 5 Feb 2023 12:34:06 +0300 Subject: Re-added wikiless https://github.com/libredirect/libredirect/issues/612. Fixed UI bug in settings --- README.md | 1 + src/assets/images/goodreads-icon-light.svg | 327 +++++++++++++++++++++++++++++ src/assets/images/goodreads-icon.svg | 327 +++++++++++++++++++++++++++++ src/assets/images/wikipedia-icon.svg | 3 + src/assets/javascripts/services.js | 23 ++ src/config.json | 27 ++- src/pages/options/index.js | 13 +- src/pages/options/widgets/services.pug | 16 +- 8 files changed, 717 insertions(+), 20 deletions(-) create mode 100644 src/assets/images/goodreads-icon-light.svg create mode 100644 src/assets/images/goodreads-icon.svg create mode 100644 src/assets/images/wikipedia-icon.svg diff --git a/README.md b/README.md index 11c5d464..ad8d9c77 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ A web extension that redirects YouTube, Twitter, TikTok... requests to alternati - Genius [Dumb](https://github.com/rramiachraf/dumb) - StackOverflow [AnonymousOverflow](https://github.com/httpjamesm/AnonymousOverflow) - Goodreads [BiblioReads](https://github.com/nesaku/BiblioReads) +- Wikipedia [Wikiless](https://wikiless.org) **Note**: The Extension will be using random instances by default. You can modify this and add custom instances too. diff --git a/src/assets/images/goodreads-icon-light.svg b/src/assets/images/goodreads-icon-light.svg new file mode 100644 index 00000000..f6a4c947 --- /dev/null +++ b/src/assets/images/goodreads-icon-light.svg @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/images/goodreads-icon.svg b/src/assets/images/goodreads-icon.svg new file mode 100644 index 00000000..5e446292 --- /dev/null +++ b/src/assets/images/goodreads-icon.svg @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/images/wikipedia-icon.svg b/src/assets/images/wikipedia-icon.svg new file mode 100644 index 00000000..87876d46 --- /dev/null +++ b/src/assets/images/wikipedia-icon.svg @@ -0,0 +1,3 @@ + + +Wikipedia logo version 2 \ No newline at end of file diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index b91fd233..00e48932 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -425,6 +425,28 @@ function redirect(url, type, initiator, forceRedirection) { if (!url.pathname.startsWith('/book/show/') && url.pathname != '/') return return `${randomInstance}${url.pathname}${url.search}` } + case "wikiless": { + let GETArguments = [] + if (url.search.length > 0) { + let search = url.search.substring(1) //get rid of '?' + let argstrings = search.split("&") + for (let i = 0; i < argstrings.length; i++) { + let args = argstrings[i].split("=") + GETArguments.push([args[0], args[1]]) + } + } + + let link = `${randomInstance}${url.pathname}` + let urlSplit = url.host.split(".") + if (urlSplit[0] != "wikipedia" && urlSplit[0] != "www") { + if (urlSplit[0] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"]) + else GETArguments.push(["lang", urlSplit[0]]) + if (urlSplit[1] == "m") GETArguments.push(["mobileaction", "toggle_view_mobile"]) + // wikiless doesn't have mobile view support yet + } + for (let i = 0; i < GETArguments.length; i++) link += (i == 0 ? "?" : "&") + GETArguments[i][0] + "=" + GETArguments[i][1] + return link + } default: return `${randomInstance}${url.pathname}${url.search}` } @@ -568,6 +590,7 @@ function initDefaults() { options['ruralDictionary'] = ['https://rd.vern.cc'] options['anonymousOverflow'] = ['https://code.whatever.social'] options['biblioReads'] = ['https://biblioreads.ml'] + options['wikiless'] = ['https://wikiless.org'] browser.storage.local.set({ options }, () => resolve() diff --git a/src/config.json b/src/config.json index b8e43438..4497d77a 100644 --- a/src/config.json +++ b/src/config.json @@ -489,7 +489,7 @@ "genius": { "frontends": { "dumb": { - "name": "dumb", + "name": "Dumb", "instanceList": true, "url": "https://github.com/rramiachraf/dumb" } @@ -543,10 +543,10 @@ "embeddable": false, "url": "https://stackoverflow.com/" }, - "goodReads": { + "goodreads": { "frontends": { "biblioReads": { - "name": "goodReads", + "name": "BiblioReads", "instanceList": true, "url": "https://github.com/nesaku/BiblioReads" } @@ -558,9 +558,28 @@ "options": { "enabled": false }, - "imageType": "svg", + "imageType": "svgMono", "embeddable": false, "url": "https://goodreads.com/" + }, + "wikipedia": { + "frontends": { + "wikiless": { + "name": "Wikiless", + "instanceList": true, + "url": "https://wikiless.org" + } + }, + "targets": [ + "^https?:\\/{2}(?:[a-z]+\\.)*wikipedia\\.org\\/?" + ], + "name": "Wikipedia", + "options": { + "enabled": false + }, + "imageType": "svg", + "embeddable": false, + "url": "https://wikipedia.org" } } } \ No newline at end of file diff --git a/src/pages/options/index.js b/src/pages/options/index.js index c6c21095..dc3140fc 100644 --- a/src/pages/options/index.js +++ b/src/pages/options/index.js @@ -41,6 +41,12 @@ function changeFrontendsSettings(service) { } } } + const frontend_name_element = document.getElementById(`${service}_page`).getElementsByClassName("frontend_name")[0] + if (divs[service].frontend) { + frontend_name_element.href = config.services[service].frontends[divs[service].frontend.value].url + } else { + frontend_name_element.href = Object.values(config.services[service].frontends)[0].url + } } async function loadPage(path) { @@ -78,13 +84,6 @@ async function loadPage(path) { }) } - const frontend_name_element = document.getElementById(`${service}_page`).getElementsByClassName("frontend_name")[0] - if (divs[service].frontend) { - frontend_name_element.href = config.services[service].frontends[divs[service].frontend.value].url - } else { - frontend_name_element.href = Object.values(config.services[service].frontends)[0].url - } - changeFrontendsSettings(service) diff --git a/src/pages/options/widgets/services.pug b/src/pages/options/widgets/services.pug index 257ffd7c..e23aa08e 100644 --- a/src/pages/options/widgets/services.pug +++ b/src/pages/options/widgets/services.pug @@ -16,17 +16,15 @@ each val, service in services h4(data-localise="__MSG_showInPopup__") Show in popup input(id=service type="checkbox") - if Object.keys(services[service].frontends).length> 1 - div(class="some-block option-block") - h4 - a(class="frontend_name" target="_blank" data-localise="__MSG_frontend__") Frontend - select(id=service+"-frontend") + div(class="some-block option-block") + h4 + a(class="frontend_name" target="_blank" data-localise="__MSG_frontend__") Frontend + select(id=service+"-frontend") + if Object.keys(services[service].frontends).length> 1 each val, frontend in services[service].frontends option(value=frontend)=services[service].frontends[frontend].name - else - div(class="some-block option-block") - h4 - a(class="frontend_name" target="_blank" data-localise="__MSG_frontend__") Frontend + else + option(value=frontend)=Object.values(services[service].frontends)[0].name if services[service].embeddable div(class="some-block option-block") -- cgit 1.4.1