Fixed peertube redirects

This commit is contained in:
Hygna 2022-10-11 16:11:39 +01:00
parent c60e6f2c52
commit 8df59a5b6e
No known key found for this signature in database
1 changed files with 8 additions and 12 deletions

View File

@ -2,13 +2,14 @@ window.browser = window.browser || window.chrome
import utils from "./utils.js" import utils from "./utils.js"
let config, options, redirects let config, options, redirects, targets
function init() { function init() {
return new Promise(async resolve => { return new Promise(async resolve => {
browser.storage.local.get(["options", "redirects"], r => { browser.storage.local.get(["options", "redirects", "targets"], r => {
options = r.options options = r.options
redirects = r.redirects redirects = r.redirects
targets = r.targets
fetch("/config/config.json") fetch("/config/config.json")
.then(response => response.text()) .then(response => response.text())
.then(configData => { .then(configData => {
@ -45,16 +46,11 @@ function all(service, frontend, options, config, redirects) {
} }
function regexArray(service, url, config) { function regexArray(service, url, config) {
let targets let targetList
if (config.services[service].targets == "datajson") { if (config.services[service].targets == "datajson") targetList = targets[service]
browser.storage.local.get("targets", r => { else targetList = config.services[service].targets
targets = r.targets[service] for (const targetString in targetList) {
}) const target = new RegExp(targetList[targetString])
} else {
targets = config.services[service].targets
}
for (const targetString in targets) {
const target = new RegExp(targets[targetString])
if (target.test(url.href)) return true if (target.test(url.href)) return true
} }
return false return false