diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 2cb3fed..fc5921e 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -46,12 +46,14 @@ function all(service, frontend, options, config, redirects) { } function regexArray(service, url, config) { - let targetList - if (config.services[service].targets == "datajson") targetList = targets[service] - else targetList = config.services[service].targets - for (const targetString in targetList) { - const target = new RegExp(targetList[targetString]) - if (target.test(url.href)) return true + if (config.services[service].targets == "datajson") { + if (targets[service].includes(utils.protocolHost(url))) return true + } else { + const targetList = config.services[service].targets + for (const targetString in targetList) { + const target = new RegExp(targetList[targetString]) + if (target.test(url.href)) return true + } } return false } @@ -398,9 +400,7 @@ function redirect(url, type, initiator, forceRedirection) { if (url.href.search(/^https?:\/{2}(?:[im]\.)?stack\./) > -1) return `${randomInstance}/stack${url.pathname}${url.search}` else return `${randomInstance}${url.pathname}${url.search}` case "libreddit": - if (url.hostname.match(/^(i|preview)\.redd\.it/)) { - return `${randomInstance}/img${url.pathname}` - } + if (url.hostname.match(/^(i|preview)\.redd\.it/)) return `${randomInstance}/img${url.pathname}` return `${randomInstance}${url.pathname}${url.search}` default: return `${randomInstance}${url.pathname}${url.search}` diff --git a/src/config/config.json b/src/config/config.json index 628bd46..6c7ff53 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -93,7 +93,7 @@ } }, "targets": [ - "^https?:\\/{2}(?:www\\.|m\\.|)youtube.com(?!(?:iframe_api\\/.*)|(?:\/redirect))", + "^https?:\\/{2}(?:www\\.|m\\.|)youtube.com(?!(?:iframe_api\\/.*)|(?:\\/redirect))", "^https?:\\/{2}img\\.youtube.com\\/vi\\/.*\\/..*", "^https?:\\/{2}(?:i|s)\\.ytimg.com\\/vi\\/.*\\/..*", "^https?:\\/{2}(?:www\\.|music\\.|)youtube.com\\/watch?v=..*", @@ -293,7 +293,7 @@ } }, "targets": [ - "^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com", + "^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.|)reddit\\.com(?!\\/(gallery)|(rpan)|(settings)|(topics)|(dev))", "^https?:\\/{2}(i\\.|preview\\.)redd\\.it" ], "name": "Reddit",