Resize Image On "Open image in new tab"

Support: Google(G+ blogspot picasa)\Tumblr\Twitter\weibo.com (And more...

当前为 2015-10-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name       Resize Image On "Open image in new tab"
// @name:zh-cn 右键在新标签中打开图片时显示最优化图像质量
// @version    0.4.17
// @description  Support: Google(G+ blogspot picasa)\Tumblr\Twitter\weibo.com (And more...
// @description:zh-cn 支持:谷歌(G+ blogspot picasa)、Tumblr、推特、新浪微博、腾讯微博、知乎、豆瓣
// @run-at     document-start
// @match      http://*.googleusercontent.com/*
// @match      https://*.googleusercontent.com/*
// @match      http://*.media.tumblr.com/*
// @match      https://*.media.tumblr.com/*
// @match      http://*.bp.blogspot.com/*
// @match      https://*.bp.blogspot.com/*
// @match      http://*.sinaimg.cn/*
// @match      https://*.sinaimg.cn/*
// @match      http://*.qpic.cn/*
// @match      http://*.twimg.com/*
// @match      https://*.twimg.com/*
// @match      http://*.zhimg.com/*
// @match      https://*.zhimg.com/*
// @match      http://*.douban.com/view/*
// @match      https://*.douban.com/view/*
// @match      http://*.doubanio.com/view/*
// @match      https://*.doubanio.com/view/*
// @namespace https://greasyfork.org/users/2646
// @copyright  2015+, CLE
// ==/UserScript==

var url = document.location.toString();
var m = null;

//google
if( (m = url.match(/^(https?:\/\/\w+\.googleusercontent\.com\/.+\/)([^\/]+)(\/[^\/]+(\.(jpg|jpeg|gif|png|bmp|webp))?)$/i)) ) {
    if(m[2] != "s0") {
        document.location = m[1] + "s0" + m[3];
    }
}
else if( (m = url.match(/^(https?:\/\/\w+\.googleusercontent\.com\/.+=)(.+)$/i)) ) {
    if(m[2] != "s0") {
        document.location = m[1] + "s0";
    }
}

//blogspot
else if( (m = url.match(/^(https?:\/\/\w+\.bp\.blogspot\.com\/.+\/)([^\/]+)(\/[^\/]+(\.(jpg|jpeg|gif|png|bmp|webp))?)$/i)) ) {
    if(m[2] != "s0") {
        document.location = m[1] + "s0" + m[3];
    }
}

//tumblr
else if( (m = url.match(/^(https?:\/\/\d+\.media\.tumblr\.com\/.*tumblr_\w+_)(\d+)(\.(jpg|jpeg|gif|png|bmp|webp))$/i)) ) {
    if(m[2]<1280) {
        var ajax = new XMLHttpRequest();
        ajax.onreadystatechange=function() {
            if(ajax.status==200) {
                document.location = m[1] + "1280" + m[3];
            }
        }
        ajax.open("HEAD", m[1]+"1280"+m[3], true);
        ajax.send();
    }
}

//性浪微博
else if( (m = url.match(/^(https?:\/\/ww[\d]+\.sinaimg\.cn\/)([^\/]+)(\/.+)$/i)) ) {
    if(m[2] != "large") {
        document.location = m[1] + "large" + m[3];
    }
}

//疼逊微博
else if( (m = url.match(/^(http:\/\/[\w\d]+\.qpic\.cn\/.+\/)(\d+)$/i)) ) {
    if(m[2]<2000) {
        document.location = m[1] + "2000";
    }
    /*if(m[2]!=0) {
        document.location = m[1] + "0";
    }*/
}

//twitter
else if( (m = url.match(/^https?:\/\/\w+\.twimg\.com\/media\/([^\/:]+\.(jpg|jpeg|gif|png|bmp|webp))$/i)) ) {
    document.location = m[0] + ":large";
}
/*m = url.match(/^https?:\/\/\w+\.twimg\.com\/media\/([^\/:]+\.(jpg|jpeg|gif|png|bmp|webp))$/i);
if(m) {
    document.location = m[0] + ":large?" + m[1];
}
m = url.match(/^(https?:\/\/\w+\.twimg\.com\/media\/([^\/]+\.(jpg|jpeg|gif|png|bmp|webp)))\:(\w+)$/i);
if(m) {
	if(m[4]!="large") {
        document.location = m[1] + ":large?" + m[2];
    }
}*/

//zhihu
else if( (m = url.match(/^(https?:\/\/.+\.zhimg\.com\/\w+_)(\w+)(\.(jpg|jpeg|gif|png|bmp|webp))$/i)) ){
    if(m[2]!="r") {
        document.location = m[1] + "r" + m[3];
    }
}

//douban
else if( (m = url.match(/^(https?:\/\/\w+\.douban(?:io)?\.com\/view\/(?:photo|commodity_story)\/)(\w+)(\/public\/.+\.(jpg|jpeg|gif|png|bmp|webp))$/i)) ){
    if(m[2] != "large"){
        var ajax = new XMLHttpRequest();
        ajax.onreadystatechange=function() {
            if(ajax.status==200) {
                document.location = m[1] + "large" + m[3];
            }else if(ajax.status==404) {
                if(m[2] != "photo"){
                    document.location = m[1] + "photo" + m[3];
                }
            }
        }
        ajax.open("GET", m[1]+"large"+m[3], true);
        ajax.send();
    }
}