Skip to content

Commit

Permalink
Modified Tumblr redirection #869
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Dec 10, 2023
1 parent ab46d1a commit fa9f559
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,35 +569,29 @@ function redirect(url, type, initiator, forceRedirection, incognito) {
return `${randomInstance}?url=${encodeURIComponent(url.href)}`
}
case "priviblur": {
// www.tumblr.com
if (url.hostname === "www.tumblr.com")
return `${randomInstance}${url.pathname}${url.search}`;
if (url.hostname == "www.tumblr.com")
return `${randomInstance}${url.pathname}${url.search}`

// assets.tumblr.com
if (url.hostname.startsWith("assets"))
return `${randomInstance}/tblr/assets${url.pathname}${url.search}`;
return `${randomInstance}/tblr/assets${url.pathname}${url.search}`

// static.tumblr.com
if (url.hostname.startsWith("static"))
return `${randomInstance}/tblr/static${url.pathname}${url.search}`;
return `${randomInstance}/tblr/static${url.pathname}${url.search}`

// *.media.tumblr.com
const reg = /^([0-9]+)\.media\.tumblr\.com/.exec(url.hostname);
const reg = /^([0-9]+)\.media\.tumblr\.com/.exec(url.hostname) // *.media.tumblr.com
if (reg)
return `${randomInstance}/tblr/media/${reg[1]}${url.pathname}${url.search}`;

// <blog>.tumblr.com
const blogregex = /^(www.)?([a-z\d]{1}[a-z\d-]{0,30}[a-z\d]{0,1})\.tumblr\.com/.exec(url.hostname);
const blog_name = blogregex[2];

if (blogregex)
return `${randomInstance}/tblr/media/${reg[1]}${url.pathname}${url.search}`

const blogregex = /^(?:www\.)?([a-z\d]+)\.tumblr\.com/.exec(url.hostname) // <blog>.tumblr.com
if (blogregex) {
const blog_name = blogregex[1];
// Under the <blog>.tumblr.com domain posts are under a /post path
if (url.pathname.startsWith("/post")) {
return `${randomInstance}/${blog_name}${url.pathname.slice(5)}${url.search}`;
return `${randomInstance}/${blog_name}${url.pathname.slice(5)}${url.search}`
} else {
return `${randomInstance}/${blog_name}${url.pathname}${url.search}`;
}

}
return `${randomInstance}${url.pathname}${url.search}`;
}
default: {
Expand Down

0 comments on commit fa9f559

Please sign in to comment.