Greasy Fork 还支持 简体中文。

Resize Image On "Open image in new tab"

Support: Google(G+ blogspot YouTube)\Tumblr\Twitter\Steam(Only user content)\weibo.com (And more...

目前為 2016-12-21 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Resize Image On "Open image in new tab"
  3. // @name:zh-cn 右键在新标签中打开图片时显示最优化图像质量
  4. // @version 0.5.11
  5. // @description Support: Google(G+ blogspot YouTube)\Tumblr\Twitter\Steam(Only user content)\weibo.com (And more...
  6. // @description:zh-cn 支持:谷歌(G+ blogspot YouTube)、Tumblr、推特、Steam、新浪微博、知乎、豆瓣、百度贴吧
  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. // @match http://images.akamai.steamusercontent.com/*
  30. // @match http://*.artstation.com/*
  31. // @match https://*.artstation.com/*
  32. // @match http://i.ytimg.com/*
  33. // @match https://i.ytimg.com/*
  34. // @match http://*.ggpht.com/*
  35. // @match https://*.ggpht.com/*
  36. // @exclude http://webcache.googleusercontent.com/*
  37. // @exclude https://webcache.googleusercontent.com/*
  38. // @namespace https://greasyfork.org/users/2646
  39. // @copyright 2016+, CLE
  40. // ==/UserScript==
  41.  
  42. var url = document.location.toString();
  43. var m = null;
  44.  
  45. //google
  46. if( (m = url.match(/^(https?:\/\/\w+\.googleusercontent\.com\/.+\/)([^\/]+)(\/[^\/]+(\.(jpg|jpeg|gif|png|bmp|webp))?)(?:\?.+)?$/i)) ) {
  47. if(m[2] != "s0") {
  48. document.location = m[1] + "s0" + m[3];
  49. }
  50. }
  51. else if( (m = url.match(/^(https?:\/\/\w+\.googleusercontent\.com\/.+=)(.+)(?:\?.+)?$/i)) ) {
  52. if(m[2] != "s0") {
  53. document.location = m[1] + "s0";
  54. }
  55. }
  56. else if( (m = url.match(/^(https?:\/\/\w+\.ggpht\.com\/.+\/)([^\/]+)(\/[^\/]+(\.(jpg|jpeg|gif|png|bmp|webp))?)(?:\?.+)?$/i)) ) {
  57. if(m[2] != "s0") {
  58. document.location = m[1] + "s0" + m[3];
  59. }
  60. }
  61.  
  62. //blogspot
  63. else if( (m = url.match(/^(https?:\/\/\w+\.bp\.blogspot\.com\/.+\/)([^\/]+)(\/[^\/]+(\.(jpg|jpeg|gif|png|bmp|webp))?)(?:\?.+)?$/i)) ) {
  64. if(m[2] != "s0") {
  65. document.location = m[1] + "s0" + m[3];
  66. }
  67. }
  68.  
  69. //youtube
  70. else if( (m = url.match(/^(https?:\/\/i\.ytimg.com\/vi\/[^\/]+\/)(\w+)(\.(jpg|jpeg|gif|png|bmp|webp))(\?.+)?$/i)) ) {
  71. if(m[2] != "maxresdefault") {
  72. var ajax = new XMLHttpRequest();
  73. ajax.onreadystatechange=function() {
  74. if(ajax.status==200) {
  75. document.location = m[1] + "maxresdefault" + m[3];
  76. }else if(ajax.status==404) {
  77. if(m[5] || m[2] === "mqdefault")
  78. document.location = m[1] + "hqdefault" + m[3]; //need test
  79. }
  80. };
  81. ajax.open("HEAD", m[1] + "maxresdefault" + m[3], true);
  82. ajax.send();
  83. }
  84. }
  85.  
  86. //tumblr
  87. else if( (m = url.match(/^(https?:\/\/\d+\.media\.tumblr\.com\/.*tumblr_\w+_)(\d+)(\.(jpg|jpeg|gif|png|bmp|webp))(?:\?.+)?$/i)) ) {
  88. if(m[2]<1280) {
  89. var ajax = new XMLHttpRequest();
  90. ajax.onreadystatechange=function() {
  91. if(ajax.status==200) {
  92. document.location = m[1] + "1280" + m[3];
  93. }
  94. };
  95. ajax.open("HEAD", m[1]+"1280"+m[3], true);
  96. ajax.send();
  97. }
  98. }
  99.  
  100. //twitter
  101. else if( (m = url.match(/^(https?:\/\/\w+\.twimg\.com\/media\/(?:[^\/:]+\.(?:jpg|jpeg|gif|png|bmp|webp)))(:\w+)?(?:\?.+)?$/i)) ) {
  102. if ( m[2]===null || m[2] != ":orig" )
  103. document.location = m[1] + ":orig";
  104. }
  105.  
  106. //Steam (Only user content)
  107. else if( (m = url.match(/^(http:\/\/images\.akamai\.steamusercontent\.com\/[^\?]+)\?.+$/i)) ){
  108. document.location = m[1];
  109. }
  110.  
  111. //性浪微博
  112. else if( (m = url.match(/^(https?:\/\/w\w+\.sinaimg\.cn\/)([a-zA-Z]\w+)(\/.+)(?:\?.+)?$/i)) ) {
  113. if(m[2] != "large") {
  114. document.location = m[1] + "large" + m[3];
  115. }
  116. }
  117.  
  118. //疼逊微博
  119. //注意:腾讯服务器会经常性自动跳转到t100错误服务器,致使本条自动跳转规则失效
  120. //如果您的浏览器经常性出现错误提示,请删除或屏蔽此条规则,等我找到更好的方法跳转之后再更新
  121. //SB腾讯!
  122. else if( (m = url.match(/^(http:\/\/[\w\d]+\.qpic\.cn\/.+\/)(\d+)(?:\?.+)?$/i)) ) {
  123. if(m[2]<2000) {
  124. top.location=m[1] + "2000";
  125. }
  126. /*if(m[2]!=0) {
  127. document.location = m[1] + "0";
  128. }*/
  129. }
  130. /* 测试代码,依然无效...
  131. else if( (m = url.match(/^http:\/\/t(\d+)\.qpic\.cn\/(mblogpic\/\w+\/)(\d+)$/i)) ) {
  132. if(m[1]==100){
  133. document.location = "http://t1.qpic.cn/" + m[2] + "2000";
  134. }else if(m[3]<2000){
  135. document.location = "http://t"+m[1]+".qpic.cn/" + m[2] + "2000";
  136. }
  137. }*/
  138.  
  139. //zhihu
  140. else if( (m = url.match(/^(https?:\/\/.+\.zhimg\.com\/[\w\-]+_)(\w+)(\.(jpg|jpeg|gif|png|bmp|webp))(?:\?.+)?$/i)) ){
  141. if(m[2]!="r") {
  142. document.location = m[1] + "r" + m[3];
  143. }
  144. }
  145.  
  146. //douban
  147. else if( (m = url.match(/^(https?:\/\/\w+\.douban(?:io)?\.com\/view\/(?:photo|commodity_story)\/)(\w+)(\/public\/.+\.(jpg|jpeg|gif|png|bmp|webp))(?:\?.+)?$/i)) ){
  148. if(m[2] != "raw"){
  149. var ajax = new XMLHttpRequest();
  150. ajax.onreadystatechange=function() {
  151. if(ajax.status==200) {
  152. document.location = m[1] + "raw" + m[3];
  153. }else if(ajax.status==404) {
  154. if(m[2] != "photo"){
  155. document.location = m[1] + "photo" + m[3];
  156. }
  157. }
  158. };
  159. ajax.open("GET", m[1]+"raw"+m[3], true);
  160. ajax.send();
  161. }
  162. }
  163.  
  164. //artstation
  165. else if( (m = url.match(/^(https?:\/\/cdn\w+\.artstation\.com\/.+\/)(\w+)(\/[^\/]+)$/i)) ){
  166. if(m[2] != "original") {
  167. document.location = m[1] + "original" + m[3];
  168. }
  169. }
  170.  
  171. //百度贴吧(然而对于画质提升什么的并没有什么卵用...)
  172. else if( !(m = url.match(/^http:\/\/imgsrc\.baidu\.com\/forum\/pic\/item\/.+/i)) ){
  173. if( (m = url.match(/^http:\/\/(?:imgsrc|\w+\.hiphotos)\.(?:bdimg|baidu)\.com\/(?:forum|album)\/.+\/(\w+\.(?:jpg|jpeg|gif|png|bmp|webp))(?:\?.+)?$/i)) ){
  174. document.location = "http://imgsrc.baidu.com/forum/pic/item/" + m[1];
  175. }
  176. }