aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-11-12 12:51:58 +0300
committerManeraKai <manerakai@protonmail.com>2022-11-12 12:51:58 +0300
commit544b69602e3f48018bc4feb2cf39a44dd3b4c52a (patch)
treee447596e07c8e20f60f16eb6a4d6a8690d5e559a
parentFixed <img> not redirecting https://github.com/libredirect/libredirect/issues... (diff)
downloadlibredirect-544b69602e3f48018bc4feb2cf39a44dd3b4c52a.zip
Added excludeTargets for more basic frontends https://github.com/libredirect/libredirect/issues/531
Diffstat (limited to '')
-rw-r--r--src/assets/javascripts/services.js23
-rw-r--r--src/config/config.json18
2 files changed, 30 insertions, 11 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index 9d80e17a..65a359e3 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -45,11 +45,15 @@ function all(service, frontend, options, config, redirects) {
return instances
}
-function regexArray(service, url, config) {
+function regexArray(service, url, config, frontend) {
if (config.services[service].targets == "datajson") {
if (targets[service].startsWith(utils.protocolHost(url))) return true
} else {
const targetList = config.services[service].targets
+ if (frontend && config.services[service].frontends[frontend].excludeTargets)
+ for (const i in config.services[service].frontends[frontend].excludeTargets) {
+ targetList = targetList.splice(i, 1)
+ }
for (const targetString in targetList) {
const target = new RegExp(targetList[targetString])
if (target.test(url.href)) return true
@@ -69,15 +73,6 @@ function redirect(url, type, initiator, forceRedirection) {
if (config.services[service].embeddable && type != options[service].redirectType && options[service].redirectType != "both") continue
if (!config.services[service].embeddable && type != "main_frame") continue
- // let targets = new RegExp(config.services[service].targets.join("|"), "i")
- if (!regexArray(service, url, config)) continue
- // if (initiator) {
- // console.log(initiator.host)
- // if (targets.test(initiator.host)) continue
- // //if (all(service, null, options, config, redirects).includes(initiator.origin) && reverse(initiator) == url) return "BYPASSTAB"
- // }
-
-
if (Object.keys(config.services[service].frontends).length > 1) {
if (
type == "sub_frame" && config.services[service].embeddable
@@ -87,6 +82,14 @@ function redirect(url, type, initiator, forceRedirection) {
else frontend = options[service].frontend
} else frontend = Object.keys(config.services[service].frontends)[0]
+ // let targets = new RegExp(config.services[service].targets.join("|"), "i")
+ if (!regexArray(service, url, config, frontend)) continue
+ // if (initiator) {
+ // console.log(initiator.host)
+ // if (targets.test(initiator.host)) continue
+ // //if (all(service, null, options, config, redirects).includes(initiator.origin) && reverse(initiator) == url) return "BYPASSTAB"
+ // }
+
if (config.services[service].frontends[frontend].instanceList) {
let instanceList = [...options[frontend][options.network].enabled, ...options[frontend][options.network].custom]
diff --git a/src/config/config.json b/src/config/config.json
index 8b99423a..e7d468b6 100644
--- a/src/config/config.json
+++ b/src/config/config.json
@@ -34,6 +34,10 @@
"instanceList": true
},
"piped": {
+ "excludeTargets": [
+ 1,
+ 2
+ ],
"preferences": {
"localstorage": [
"bufferGoal",
@@ -62,6 +66,10 @@
"instanceList": true
},
"pipedMaterial": {
+ "excludeTargets": [
+ 1,
+ 2
+ ],
"preferences": {
"localstorage": [
"PREFERENCES"
@@ -82,11 +90,19 @@
"instanceList": true
},
"freetube": {
+ "excludeTargets": [
+ 1,
+ 2
+ ],
"name": "FreeTube",
"embeddable": false,
"instanceList": false
},
"yattee": {
+ "excludeTargets": [
+ 1,
+ 2
+ ],
"name": "Yattee",
"embeddable": false,
"instanceList": false
@@ -732,4 +748,4 @@
"color": "grey"
}
}
-}
+} \ No newline at end of file