Last active
June 22, 2018 01:35
-
-
Save heavyLobster2/fb062fac9d3290330154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Redirect Tumblr Images | |
// @description Redirects to full size Tumblr images | |
// @version 1.0.3 | |
// @author heavyLobster2 | |
// @namespace github.com/heavyLobster2 | |
// @downloadURL https://gist.github.com/heavyLobster2/fb062fac9d3290330154/raw/RedirectTumblrImages.user.js | |
// @match *://*.media.tumblr.com/* | |
// @run-at document-start | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
"use strict"; | |
var extensions = new Set(["jpg", "png"]); | |
var sizes = new Set(["640", "540", "500", "400", "250", "100"]); | |
var urlPieces = window.location.href.split("_"); | |
if (urlPieces.length < 2) return; | |
var sizeAndExt = urlPieces[urlPieces.length - 1]; | |
var sizeAndExtPieces = sizeAndExt.split("."); | |
if (sizeAndExtPieces.length !== 2) return; | |
var size = sizeAndExtPieces[0]; | |
var extension = sizeAndExtPieces[1]; | |
if (extensions.has(extension) && sizes.has(size)) { | |
var urlPrefix = ""; | |
for (var i = 0; i < urlPieces.length - 1; i++) { | |
urlPrefix = urlPrefix + (urlPrefix === "" ? "" : "_") + urlPieces[i]; | |
} | |
window.location.replace(urlPrefix + "_1280." + extension); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment