Automatically promotes Tumblr video links to raw HD versions
目前為
// ==UserScript== // @name Tumblr Videos to HD Redirector // @namespace TumblrVideoReszr // @description Automatically promotes Tumblr video links to raw HD versions // @version 0.1 // @author Kai Krause <[email protected]> // @match http://*.media.tumblr.com/* // @match https://*.media.tumblr.com/* // @grant GM_xmlhttpRequest // @connect media.tumblr.com // @run-at document-start // ==/UserScript== // Check if this page contains a single video whose source is also the location. var loc = location.toString(); var video = document.getElementsByTagName('video')[0]; var videoSource = video.getElementsByTagName('source')[0]; if (!video && videoSource.getAttribute('src') != loc) return; // Do not redirect if already HD var lowQuality = /[$_]\d*.mp4$/; if (!loc.match(lowQuality)) return; // Change to HD loc = loc.replace(lowQuality, '.mp4'); // If the URL is HTTP, change it to HTTPS if (!loc.startsWith('https://')) { loc = loc.replace(/^http/, 'https'); } // Check that the HD video exists, then redirect to it GM_xmlhttpRequest({ url: loc, method: 'HEAD', onload: function(response) { if (response.status == '200') { window.location = loc; } } });