您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically promotes Tumblr image links to raw HD versions
当前为
// ==UserScript== // @name Tumblr Images to HD Redirector // @namespace TumblrImgReszr // @description Automatically promotes Tumblr image links to raw HD versions // @version 0.8 // @author Kai Krause <[email protected]> // @match *.media.tumblr.com/* // @grant GM_xmlhttpRequest // @connect media.tumblr.com // @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 imageType = loc.match(/[^.]*$/); var checkSize; if (image && image.getAttribute('src') == loc) { // Do not create a looped redirect by redirecting already HD images to itself if (!loc.includes('_raw') && !loc.includes('_1280')) { // If the URL is HTTP, change it to HTTPS if (!loc.startsWith('https://')) { loc = loc.replace(/^http/, 'https'); } checkSize = function(i) { // Define which patterns to check var i = i || 0; var imageSizes = ['raw', '1280']; if (i > imageSizes) return; // Create the HD image url pattern var newLoc = loc; if (imageSizes[i] == 'raw') { newLoc = newLoc.replace(/[^/]*media.tumblr.com/, 'media.tumblr.com'); newLoc = newLoc.replace(/[^_]*$/, imageSizes[i] + '.' + imageType[0]); } else { newLoc = newLoc.replace(/[^_]*$/, imageSizes[i] + '.' + imageType[0]); } // Check that the HD image exists, then redirect to it GM_xmlhttpRequest({ url: newLoc, method: 'HEAD', onload: function(response) { if (response.status != '200') { checkSize(i+1); return; } window.location = newLoc; } }); }; checkSize(); } }