From ab7a702accc0c4f28867762621357ff1ef3f1443 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Thu, 14 Mar 2024 12:49:42 +0300 Subject: [PATCH] Cleaned code --- src/assets/javascripts/services.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index b23295d..8bbc6de 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -67,15 +67,16 @@ async function redirectAsync(url, type, initiator, forceRedirection) { * @param randomInstance * @returns {undefined|string} */ -function rewrite(url, frontend, randomInstance){ +function rewrite(url, frontend, randomInstance) { if (!frontend || !randomInstance) return switch (frontend) { case "hyperpipe": { return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/")) } case "searx": - case "searxng": + case "searxng": { return `${randomInstance}/${url.search}` + } case "whoogle": { return `${randomInstance}/search${url.search}` } @@ -101,7 +102,6 @@ function rewrite(url, frontend, randomInstance){ case "freetubePwa": { return 'freetube://' + url.href } - case "poketube": { if (url.pathname.startsWith('/channel')) { const reg = /\/channel\/(.*)\/?$/.exec(url.pathname) @@ -526,18 +526,17 @@ function redirect(url, type, initiator, forceRedirection, incognito) { frontend = options[service].frontend - if (config.services[service].frontends[frontend].desktopApp && type != "main_frame" && options[service].redirectType != "main_frame") frontend = options[service].embedFrontend - if (!regexArray(service, url, config, frontend)) { frontend = null continue } if ( - config.services[service].embeddable && + config.services[service].embeddable + && type != options[service].redirectType && options[service].redirectType != "both" ) { if (options[service].unsupportedUrls == 'block') return 'CANCEL' @@ -548,11 +547,7 @@ function redirect(url, type, initiator, forceRedirection, incognito) { if (instanceList === undefined) break if (instanceList.length === 0) return null - if ( - initiator - && - instanceList.includes(initiator.origin) - ) { + if (initiator && instanceList.includes(initiator.origin)) { if (type != "main_frame") return null else return "BYPASSTAB" }