diff options
author | ManeraKai <manerakai@protonmail.com> | 2022-08-14 15:34:08 +0300 |
---|---|---|
committer | ManeraKai <manerakai@protonmail.com> | 2022-08-14 15:34:08 +0300 |
commit | 87d68cb662ca1d4ca436e8a10e101900b59c2bd3 (patch) | |
tree | fca63e867634bae40722a6b8f50aad10e2d73e3d /src/assets | |
parent | Removed embedded only https://github.com/libredirect/libredirect/issues/410 (diff) | |
download | libredirect-87d68cb662ca1d4ca436e8a10e101900b59c2bd3.zip |
removed ref_src and ref_url from twitter urls https://github.com/libredirect/libredirect/issues/395
Diffstat (limited to 'src/assets')
-rw-r--r-- | src/assets/javascripts/twitter.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/assets/javascripts/twitter.js b/src/assets/javascripts/twitter.js index 5704d259..eca8219f 100644 --- a/src/assets/javascripts/twitter.js +++ b/src/assets/javascripts/twitter.js @@ -110,13 +110,27 @@ function redirect(url, type, initiator, disableOverride) { const randomInstance = utils.getRandomInstance(instancesList) // https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg + + let search = new URLSearchParams(url.search) + + search.delete("ref_src") + search.delete("ref_url") + + search = search.toString() + if (search !== "") search = `?${search}` + if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") { - const [, id, format, extra] = url.search.match(/(.*)\?format=(.*)&(.*)/) + const [, id, format, extra] = search.match(/(.*)\?format=(.*)&(.*)/) const query = encodeURIComponent(`${id}.${format}?${extra}`) - return `${randomInstance}/pic${url.pathname}${query}` - } else if (url.pathname.split("/").includes("tweets")) return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}` - else if (url.host == "t.co") return `${randomInstance}/t.co${url.pathname}` - else return `${randomInstance}${url.pathname}${url.search}` + return `${randomInstance}/pic${search}${query}` + } + if (url.pathname.split("/").includes("tweets")) { + return `${randomInstance}${url.pathname.replace("/tweets", "")}${search}` + } + if (url.host == "t.co") { + return `${randomInstance}/t.co${url.pathname}` + } + return `${randomInstance}${url.pathname}${search}` } function reverse(url) { |