Twitter twimg redirects #307

This commit is contained in:
ManeraKai 2022-06-04 17:54:13 +03:00
parent 0500bab297
commit b6875ee886
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
1 changed files with 5 additions and 2 deletions

View File

@ -92,8 +92,11 @@ function redirect(url, initiator) {
const randomInstance = utils.getRandomInstance(instancesList);
// https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video")
return `${randomInstance}/pic/${encodeURIComponent(`${url.host}${url.pathname}`)}`;
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
const [, id, format, extra] = url.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')