Greasy Fork is available in English.

Tumblr Images to HD Redirector

Automatically promotes Tumblr image links to raw HD versions

À partir de 2017-08-01. Voir la dernière version.

// ==UserScript==
// @name         Tumblr Images to HD Redirector
// @namespace    TumblrImgReszr
// @description  Automatically promotes Tumblr image links to raw HD versions
// @version      0.7
// @author       Kai Krause
// @match        http*://*.media.tumblr.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

// Check if this page contains a single image whose source is also the location.
var image = document.getElementsByTagName('img')[0];
var loc = location.toString();
var http = loc.match(/[^.]*$/);
var imageType = loc.match(/[^.]*$/);

if (image && image.getAttribute('src') == loc) {
	// Do not create a looped redirect by redirecting already HD images to itself
	if (!loc.includes('_1280') && !loc.includes('_raw')) {
		// If the URL is HTTP, change it to HTTPS
		if (!loc.startsWith('https://')) {
			loc = loc.replace(/^http/, 'https');
		}
		// Create the HD image url pattern and redirect to it
		loc = loc.replace(/[^/]*media.tumblr.com/, 'media.tumblr.com');
		loc = loc.replace(/[^_]*$/, 'raw.' + imageType[0]);
		window.location = loc;
	}
}