Cleaned code

This commit is contained in:
ManeraKai 2024-03-14 12:49:42 +03:00
parent 1f8e0d00e1
commit ab7a702acc
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
1 changed files with 6 additions and 11 deletions

View File

@ -67,15 +67,16 @@ async function redirectAsync(url, type, initiator, forceRedirection) {
* @param randomInstance * @param randomInstance
* @returns {undefined|string} * @returns {undefined|string}
*/ */
function rewrite(url, frontend, randomInstance){ function rewrite(url, frontend, randomInstance) {
if (!frontend || !randomInstance) return if (!frontend || !randomInstance) return
switch (frontend) { switch (frontend) {
case "hyperpipe": { case "hyperpipe": {
return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/")) return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/"))
} }
case "searx": case "searx":
case "searxng": case "searxng": {
return `${randomInstance}/${url.search}` return `${randomInstance}/${url.search}`
}
case "whoogle": { case "whoogle": {
return `${randomInstance}/search${url.search}` return `${randomInstance}/search${url.search}`
} }
@ -101,7 +102,6 @@ function rewrite(url, frontend, randomInstance){
case "freetubePwa": { case "freetubePwa": {
return 'freetube://' + url.href return 'freetube://' + url.href
} }
case "poketube": { case "poketube": {
if (url.pathname.startsWith('/channel')) { if (url.pathname.startsWith('/channel')) {
const reg = /\/channel\/(.*)\/?$/.exec(url.pathname) const reg = /\/channel\/(.*)\/?$/.exec(url.pathname)
@ -526,18 +526,17 @@ function redirect(url, type, initiator, forceRedirection, incognito) {
frontend = options[service].frontend frontend = options[service].frontend
if (config.services[service].frontends[frontend].desktopApp && type != "main_frame" && options[service].redirectType != "main_frame") if (config.services[service].frontends[frontend].desktopApp && type != "main_frame" && options[service].redirectType != "main_frame")
frontend = options[service].embedFrontend frontend = options[service].embedFrontend
if (!regexArray(service, url, config, frontend)) { if (!regexArray(service, url, config, frontend)) {
frontend = null frontend = null
continue continue
} }
if ( if (
config.services[service].embeddable && config.services[service].embeddable
&&
type != options[service].redirectType && options[service].redirectType != "both" type != options[service].redirectType && options[service].redirectType != "both"
) { ) {
if (options[service].unsupportedUrls == 'block') return 'CANCEL' if (options[service].unsupportedUrls == 'block') return 'CANCEL'
@ -548,11 +547,7 @@ function redirect(url, type, initiator, forceRedirection, incognito) {
if (instanceList === undefined) break if (instanceList === undefined) break
if (instanceList.length === 0) return null if (instanceList.length === 0) return null
if ( if (initiator && instanceList.includes(initiator.origin)) {
initiator
&&
instanceList.includes(initiator.origin)
) {
if (type != "main_frame") return null if (type != "main_frame") return null
else return "BYPASSTAB" else return "BYPASSTAB"
} }