Resize Image On "Open image in new tab"

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

当前为 2015-12-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Resize Image On "Open image in new tab"
  3. // @name:zh-cn 右键在新标签中打开图片时显示最优化图像质量
  4. // @version 0.5.1
  5. // @description Support: Google(G+ blogspot picasa)\Tumblr\Twitter\weibo.com (And more...
  6. // @description:zh-cn 支持:谷歌(G+ blogspot picasa)、Tumblr、推特、新浪微博、腾讯微博、知乎、豆瓣、百度贴吧
  7. // @run-at document-start
  8. // @match http://*.googleusercontent.com/*
  9. // @match https://*.googleusercontent.com/*
  10. // @match http://*.media.tumblr.com/*
  11. // @match https://*.media.tumblr.com/*
  12. // @match http://*.bp.blogspot.com/*
  13. // @match https://*.bp.blogspot.com/*
  14. // @match http://*.sinaimg.cn/*
  15. // @match https://*.sinaimg.cn/*
  16. // @match http://*.qpic.cn/*
  17. // @match http://*.twimg.com/*
  18. // @match https://*.twimg.com/*
  19. // @match http://*.zhimg.com/*
  20. // @match https://*.zhimg.com/*
  21. // @match http://*.douban.com/view/*
  22. // @match https://*.douban.com/view/*
  23. // @match http://*.doubanio.com/view/*
  24. // @match https://*.doubanio.com/view/*
  25. // @match http://imgsrc.baidu.com/*
  26. // @match http://imgsrc.bdimg.com/*
  27. // @match http://*.hiphotos.baidu.com/*
  28. // @match http://*.hiphotos.bdimg.com/*
  29. // @namespace https://greasyfork.org/users/2646
  30. // @copyright 2015+, CLE
  31. // ==/UserScript==
  32.  
  33. var url = document.location.toString();
  34. var m = null;
  35.  
  36. //google
  37. if( (m = url.match(/^(https?:\/\/\w+\.googleusercontent\.com\/.+\/)([^\/]+)(\/[^\/]+(\.(jpg|jpeg|gif|png|bmp|webp))?)$/i)) ) {
  38. if(m[2] != "s0") {
  39. document.location = m[1] + "s0" + m[3];
  40. }
  41. }
  42. else if( (m = url.match(/^(https?:\/\/\w+\.googleusercontent\.com\/.+=)(.+)$/i)) ) {
  43. if(m[2] != "s0") {
  44. document.location = m[1] + "s0";
  45. }
  46. }
  47.  
  48. //blogspot
  49. else if( (m = url.match(/^(https?:\/\/\w+\.bp\.blogspot\.com\/.+\/)([^\/]+)(\/[^\/]+(\.(jpg|jpeg|gif|png|bmp|webp))?)$/i)) ) {
  50. if(m[2] != "s0") {
  51. document.location = m[1] + "s0" + m[3];
  52. }
  53. }
  54.  
  55. //tumblr
  56. else if( (m = url.match(/^(https?:\/\/\d+\.media\.tumblr\.com\/.*tumblr_\w+_)(\d+)(\.(jpg|jpeg|gif|png|bmp|webp))$/i)) ) {
  57. if(m[2]<1280) {
  58. var ajax = new XMLHttpRequest();
  59. ajax.onreadystatechange=function() {
  60. if(ajax.status==200) {
  61. document.location = m[1] + "1280" + m[3];
  62. }
  63. }
  64. ajax.open("HEAD", m[1]+"1280"+m[3], true);
  65. ajax.send();
  66. }
  67. }
  68.  
  69. //twitter
  70. else if( (m = url.match(/^(https?:\/\/\w+\.twimg\.com\/media\/(?:[^\/:]+\.(?:jpg|jpeg|gif|png|bmp|webp)))(:\w+)?$/i)) ) {
  71. if ( m[2]==null || m[2] != ":orig" )
  72. document.location = m[1] + ":orig";
  73. }
  74.  
  75. //性浪微博
  76. else if( (m = url.match(/^(https?:\/\/\w+\.sinaimg\.cn\/)([^\/]+)(\/.+)$/i)) ) {
  77. if(m[2] != "large") {
  78. document.location = m[1] + "large" + m[3];
  79. }
  80. }
  81.  
  82. //疼逊微博
  83. else if( (m = url.match(/^(http:\/\/[\w\d]+\.qpic\.cn\/.+\/)(\d+)$/i)) ) {
  84. if(m[2]<2000) {
  85. document.location = m[1] + "2000";
  86. }
  87. /*if(m[2]!=0) {
  88. document.location = m[1] + "0";
  89. }*/
  90. }
  91.  
  92. //zhihu
  93. else if( (m = url.match(/^(https?:\/\/.+\.zhimg\.com\/\w+_)(\w+)(\.(jpg|jpeg|gif|png|bmp|webp))$/i)) ){
  94. if(m[2]!="r") {
  95. document.location = m[1] + "r" + m[3];
  96. }
  97. }
  98.  
  99. //douban
  100. else if( (m = url.match(/^(https?:\/\/\w+\.douban(?:io)?\.com\/view\/(?:photo|commodity_story)\/)(\w+)(\/public\/.+\.(jpg|jpeg|gif|png|bmp|webp))$/i)) ){
  101. if(m[2] != "large"){
  102. var ajax = new XMLHttpRequest();
  103. ajax.onreadystatechange=function() {
  104. if(ajax.status==200) {
  105. document.location = m[1] + "large" + m[3];
  106. }else if(ajax.status==404) {
  107. if(m[2] != "photo"){
  108. document.location = m[1] + "photo" + m[3];
  109. }
  110. }
  111. }
  112. ajax.open("GET", m[1]+"large"+m[3], true);
  113. ajax.send();
  114. }
  115. }
  116.  
  117. //百度贴吧(然而对于画质提升什么的并没有什么卵用...)
  118. else if( !(m = url.match(/^http:\/\/imgsrc\.baidu\.com\/forum\/pic\/item\/.+/i)) ){
  119. if( (m = url.match(/^http:\/\/(?:imgsrc|\w+\.hiphotos)\.(?:bdimg|baidu)\.com\/(?:forum|album)\/.+\/(\w+\.(?:jpg|jpeg|gif|png|bmp|webp))(?:\?.+)?$/i)) ){
  120. document.location = "http://imgsrc.baidu.com/forum/pic/item/" + m[1];
  121. }
  122. }