about summary refs log tree commit diff stats
path: root/src/assets/javascripts
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2024-08-26 13:24:05 +0300
committerManeraKai <manerakai@protonmail.com>2024-08-26 13:24:05 +0300
commit9e4c9cda67994a9f560f1e9791a28dfffc809912 (patch)
tree137a6f1b1c496db6b2838bae832b3869d3b6e773 /src/assets/javascripts
parentFixing and improving redirect core (diff)
downloadlibredirect-9e4c9cda67994a9f560f1e9791a28dfffc809912.zip
Added Koub https://codeberg.org/LibRedirect/browser_extension/issues/146
Diffstat (limited to 'src/assets/javascripts')
-rw-r--r--src/assets/javascripts/services.js34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index e93b637c..ee48a1b9 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -31,6 +31,7 @@ function all(service, frontend, options, config) {
  * @param {string} service
  * @param {URL} url
  * @param {{}} config
+ * @param {{}} options
  * @param {string} frontend
  */
 function regexArray(service, url, config, options, frontend) {
@@ -51,17 +52,6 @@ function regexArray(service, url, config, options, frontend) {
 
 /**
  * @param {URL} url
- * @param {string} type
- * @param {URL} originUrl
- * @param {boolean} forceRedirection
- */
-async function redirectAsync(url, type, originUrl, documentUrl, incognito, forceRedirection) {
-  await init()
-  return redirect(url, type, originUrl, documentUrl, incognito, forceRedirection)
-}
-
-/**
- * @param {URL} url
  * @param {string} frontend
  * @param {string} randomInstance
  * @returns {undefined|string}
@@ -554,6 +544,13 @@ function rewrite(url, originUrl, frontend, randomInstance) {
         return `${randomInstance}/list?playlists=${encodeURIComponent(url.searchParams.get("list"))}`
       return `${randomInstance}${url.pathname}${url.search}`
     }
+    case "koub":
+      if (url.pathname.startsWith("/view/") || url.pathname.startsWith("/stories/")) {
+        return `${randomInstance}${url.pathname}${url.search}`
+      }
+      const accountReg = /^\/([^\/]+)\/?$/.exec(url.pathname)
+      if (accountReg) return `${randomInstance}/account${url.pathname}${url.search}`
+
     case "piped":
     case "pipedMaterial":
     case "cloudtube":
@@ -634,6 +631,20 @@ function redirect(url, type, originUrl, documentUrl, incognito, forceRedirection
 
 /**
  * @param {URL} url
+ * @param {string} type
+ * @param {URL} originUrl
+ * @param {URL} documentUrl
+ * @param {boolean} incognito
+ * @param {boolean} forceRedirection
+ * @returns {string | undefined}
+ */
+async function redirectAsync(url, type, originUrl, documentUrl, incognito, forceRedirection) {
+  await init()
+  return redirect(url, type, originUrl, documentUrl, incognito, forceRedirection)
+}
+
+/**
+ * @param {URL} url
  * @param {*} returnFrontend
  */
 function computeService(url, returnFrontend) {
@@ -821,6 +832,7 @@ const defaultInstances = {
   skunkyArt: ["https://skunky.bloat.cat"],
   ytify: ["https://ytify.netlify.app"],
   nerdsForNerds: ["https://nn.vern.cc"],
+  koub: ["https://koub.clovius.club"],
 }
 
 async function getDefaults() {