Add Tumblr blog redirects for Priviblur

This commit is contained in:
syeopite 2023-12-10 01:47:15 -08:00
parent 2e5b23c83f
commit 4741eb2439
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
2 changed files with 27 additions and 9 deletions

View File

@ -572,19 +572,36 @@ function redirect(url, type, initiator, forceRedirection, incognito) {
return `${randomInstance}?url=${encodeURIComponent(url.href)}` return `${randomInstance}?url=${encodeURIComponent(url.href)}`
} }
case "priviblur": { case "priviblur": {
if (url.hostname.startsWith("blog")) // www.tumblr.com
return `${randomInstance}/blog${url.pathname}${url.search}` if (url.hostname === "www.tumblr.com")
return `${randomInstance}${url.pathname}${url.search}`;
// assets.tumblr.com
if (url.hostname.startsWith("assets")) if (url.hostname.startsWith("assets"))
return `${randomInstance}/assets${url.pathname}${url.search}` return `${randomInstance}/tblr/assets${url.pathname}${url.search}`;
// static.tumblr.com
if (url.hostname.startsWith("static")) if (url.hostname.startsWith("static"))
return `${randomInstance}/static${url.pathname}${url.search}` return `${randomInstance}/tblr/static${url.pathname}${url.search}`;
const reg = /^([0-9]+)\.media\.tumblr\.com/.exec(url.hostname) // *.media.tumblr.com
const reg = /^([0-9]+)\.media\.tumblr\.com/.exec(url.hostname);
if (reg) if (reg)
return `${randomInstance}/media/${reg[1]}${url.pathname}${url.search}` return `${randomInstance}/tblr/media/${reg[1]}${url.pathname}${url.search}`;
return `${randomInstance}${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)
// 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}`;
} else {
return `${randomInstance}/${blog_name}${url.pathname}${url.search}`;
}
return `${randomInstance}${url.pathname}${url.search}`;
} }
default: { default: {
return `${randomInstance}${url.pathname}${url.search}` return `${randomInstance}${url.pathname}${url.search}`

View File

@ -1006,8 +1006,9 @@
} }
}, },
"targets": [ "targets": [
"^https?:\\/{2}(media\\.|blog\\.|assets\\.|static\\.)?tumblr\\.com\\/", "^https?:\\/{2}(media\\.|assets\\.|static\\.)?tumblr\\.com\\/",
"^https?:\\/{2}[0-9]+\\.media\\.tumblr\\.com\\/" "^https?:\\/{2}[0-9]+\\.media\\.tumblr\\.com\\/",
"^https?:\\/{2}(www\\.)?(.*)\\.tumblr.com\\/"
], ],
"name": "Tumblr", "name": "Tumblr",
"options": { "options": {