From 64a655fba3478d278c89e9b4a2ff0c01196d0488 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 4 Feb 2023 23:16:36 +0300 Subject: [PATCH] Added anonymousOverflow https://github.com/libredirect/libredirect/issues/577 --- src/assets/javascripts/services.js | 22 ++++++++++++++++------ src/config.json | 25 ++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index f409715..40b607b 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -54,7 +54,10 @@ function redirect(url, type, initiator, forceRedirection) { frontend = options[service].frontend ?? Object.keys(config.services[service].frontends)[0] - if (!regexArray(service, url, config, frontend)) continue + if (!regexArray(service, url, config, frontend)) { + frontend = null + continue + } if ( initiator @@ -86,6 +89,9 @@ function redirect(url, type, initiator, forceRedirection) { } return [zoom, lon, lat] } + + if (!frontend) return + 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": @@ -381,8 +387,6 @@ function redirect(url, type, initiator, forceRedirection) { else return `${randomInstance}${url.pathname}${url.search}&teddit_proxy=${url.hostname}` } return `${randomInstance}${url.pathname}${url.search}` - default: - 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/')) { @@ -394,10 +398,15 @@ function redirect(url, type, initiator, forceRedirection) { if (url.pathname.endsWith('-lyrics')) return `${randomInstance}${url.pathname}` } case "ruralDictionary": { - if (!url.pathname.endsWith('/define.php') && !url.pathname.endsWith('/random.php') && !url.pathname.endsWith('/')) return + if (!url.pathname.endsWith('/define.php') && !url.pathname.endsWith('/random.php') && url.pathname != '/') return return `${randomInstance}${url.pathname}${url.search}` } - + case "anonymousOverflow": { + if (!url.pathname.startsWith('/questions') && url.pathname != '/') return + return `${randomInstance}${url.pathname}${url.search}` + } + default: + return `${randomInstance}${url.pathname}${url.search}` } } @@ -512,7 +521,7 @@ function initDefaults() { options['popupServices'] = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"] options['invidious'] = ['https://inv.vern.cc'] - options['piped'] = ['https://piped.video'] + options['piped'] = ['https://pipedapi-libre.kavin.rocks'] options['pipedMaterial'] = ['https://piped-material.xn--17b.net'] options['cloudtube'] = ['https://tube.cadence.moe'] options['proxiTok'] = ['https://proxitok.pabloferreiro.es'] @@ -536,6 +545,7 @@ function initDefaults() { options['neuters'] = ['https://neuters.de'] options['dumb'] = ['https://dm.vern.cc'] options['ruralDictionary'] = ['https://rd.vern.cc'] + options['anonymousOverflow'] = ['https://code.whatever.social'] browser.storage.local.set({ options }, () => resolve() diff --git a/src/config.json b/src/config.json index 8027bf0..92d4dd3 100644 --- a/src/config.json +++ b/src/config.json @@ -470,7 +470,7 @@ } }, "targets": [ - "^https?:\\/{2}(www\\.)?reuters.com\\/" + "^https?:\\/{2}(www\\.)?reuters\\.com\\/" ], "name": "Paste Text", "options": { @@ -489,7 +489,7 @@ } }, "targets": [ - "^https?:\\/{2}(www\\.)?genius.com\\/" + "^https?:\\/{2}(www\\.)?genius\\.com\\/" ], "name": "Genius", "options": { @@ -508,7 +508,7 @@ } }, "targets": [ - "^https?:\\/{2}(www\\.)?urbandictionary.com\\/" + "^https?:\\/{2}(www\\.)?urbandictionary\\.com\\/" ], "name": "Urban Dictionary", "options": { @@ -517,6 +517,25 @@ "imageType": "svg", "embeddable": false, "url": "https://urbandictionary.com" + }, + "stackOverflow": { + "frontends": { + "anonymousOverflow": { + "name": "AnonymousOverflow", + "instanceList": true, + "url": "https://github.com/httpjamesm/AnonymousOverflow" + } + }, + "targets": [ + "^https?:\\/{2}stackoverflow\\.com\\/" + ], + "name": "Stack Overflow", + "options": { + "enabled": false + }, + "imageType": "svg", + "embeddable": false, + "url": "https://stackoverflow.com/" } } } \ No newline at end of file