Auto Load Big Image

Auto expand image width height quality for image urls with custom sizes.

安装此脚本?
作者推荐脚本

您可能也喜欢Google Image Direct View

安装此脚本
  1. // ==UserScript==
  2. // @name Auto Load Big Image
  3. // @version 1.6
  4. // @description Auto expand image width height quality for image urls with custom sizes.
  5. // @author navchandar
  6. // @match http*://*/*
  7. // @exclude http*:*guim.co*/*
  8. // @grant none
  9. // @license MPL-2.0
  10. // @run-at document-start
  11. // @homepage https://navchandar.github.io/
  12. // @homepage https://github.com/navchandar/
  13. // @homepageURL https://navchandar.github.io/
  14. // @contributionURL https://paypal.me/navchandar
  15. // @contributionAmount $1.00
  16. // @copyright 2019, navchandar (https://github.com/navchandar)
  17. // @supportURL https://openuserjs.org/scripts/navchandar/Auto_Load_Big_Image/issues
  18. // @setupURL https://openuserjs.org/install/navchandar/Auto_Load_Big_Image.user.js
  19. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO3gAAAABJRU5ErkJggg==
  20. // @namespace https://gf.qytechs.cn/users/302262
  21. // ==/UserScript==
  22.  
  23. function isNum(num) {
  24. return !isNaN(num)
  25. }
  26.  
  27. function getNum(text) {
  28. return parseInt(text.replace(/[^0-9\.]/g, ''), 10);
  29. }
  30.  
  31. function Load(uri) {
  32. window.location.href = uri
  33. }
  34.  
  35. function has(String, search) {
  36. try {
  37. if (String.indexOf(search) > -1) {
  38. return true;
  39. }
  40. }
  41. catch (err) {}
  42. return false;
  43. }
  44.  
  45. function getRegexMatch(String, regex) {
  46. var finalText = "";
  47. try {
  48. var arr = String.match(regex);
  49. if (arr != null && arr.length >= 1) {
  50. finalText = arr[0];
  51. }
  52. }
  53. catch (err) {}
  54. return finalText;
  55. }
  56.  
  57. function widthUpdate(uri, w) {
  58. if (has(uri, w)) {
  59. var res = uri.split(w);
  60. if (res.length == 2) {
  61. if (res[1] != "10000" && isNum(res[1])) {
  62. var newuri = res[0] + w + "10000";
  63. Load(newuri);
  64. }
  65. }
  66. }
  67. }
  68.  
  69. function sizeUpdate(uri, w) {
  70. if (has(uri, w)) {
  71. var res = uri.split(w);
  72. if (res.length == 2) {
  73. var end = "";
  74. var width = "";
  75. if (has(res[1], "&")) {
  76. var arr = res[1].split("&");
  77. for (var i = 1; i < arr.length; i++) {
  78. end += "&" + arr[i];
  79. }
  80. width = arr[0]
  81. }
  82. else {
  83. width = res[1]
  84. }
  85. if (width != "6000" && isNum(width)) {
  86. var newuri = res[0] + w + "6000" + end;
  87. Load(newuri);
  88. }
  89. }
  90. }
  91. }
  92.  
  93. function WidthandHeightUpdate(uri, format, width, height) {
  94. if (has(uri, format) && has(uri, width) && has(uri, height)) {
  95. var res1 = uri.split(width);
  96. if (res1.length == 2) {
  97. var res2 = res1[1].split(height);
  98. if (res2.length == 2) {
  99. if (res2[0] != "6000" && isNum(res2[0]) && isNum(res2[1])) {
  100. var w = getNum(res2[0]);
  101. var h = getNum(res2[1]);
  102. var newh = parseInt((h / w) * 6000);
  103. var newuri = res1[0] + width + "6000" + height + newh;
  104. Load(newuri);
  105. }
  106. else {
  107. if (res2[0] != "6000" && has(res2[1], "&") && (has(res2[1], "quality=") || has(res2[1], "q="))) {
  108. var qual = "";
  109. if (has(res2[1], "quality=")) {
  110. qual = "&quality=";
  111. }
  112. if (has(res2[1], "q=")) {
  113. qual = "&q=";
  114. }
  115. var res3 = res2[1].split(qual);
  116. if (res3.length >= 2 && isNum(res2[0]) && isNum(res3[0]) && isNum(res3[1])) {
  117. w = getNum(res2[0]);
  118. h = getNum(res3[0]);
  119. newh = parseInt((h / w) * 6000);
  120. newuri = res1[0] + width + "6000" + height + newh + qual + "100";
  121. Load(newuri);
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129.  
  130. function HeightandWidthUpdate(uri, format, height, width) {
  131. if (has(uri, format) && has(uri, width) && has(uri, height)) {
  132. var res1 = uri.split(height);
  133. if (res1.length == 2) {
  134. var res2 = res1[1].split(width);
  135. if (res2.length >= 2) {
  136. var end = "";
  137. var w = "";
  138. var h = res2[0];
  139. if (has(res2[1], "&")) {
  140. var arr = res2[1].split("&");
  141. for (var i = 1; i < arr.length; i++) {
  142. end += "&" + arr[i];
  143. }
  144. w = arr[0]
  145. }
  146. else {
  147. w = res2[1]
  148. }
  149. if (w != "6000" && isNum(w) && isNum(h)) {
  150. var w1 = getNum(w);
  151. var h1 = getNum(h);
  152. var newh = parseInt((h1 / w1) * 6000);
  153. var newuri = res1[0] + height + newh + width + "6000" + end;
  154. Load(newuri);
  155. }
  156. }
  157. }
  158. }
  159. }
  160.  
  161. function QualityUpdate(uri, format, start, end) {
  162. if (has(uri, format) && has(uri, start) && has(uri, end)) {
  163. var res1 = uri.split(start);
  164. if (res1.length >= 2 && has(res1[1], end)) {
  165. var res2 = res1[1].split(end);
  166. if (res2.length > 0 && res2[0] != 100 && isNum(res2[0])) {
  167. var newuri = uri.replace((start + res2[0] + end), (start + "100" + end));
  168. Load(newuri);
  169. }
  170. }
  171. }
  172. }
  173.  
  174. function ReplaceCustomCrop(uri, format, regex, replacement) {
  175. if (has(uri, format)) {
  176. try {
  177. if (regex.test(uri)) {
  178. var newuri = uri.replace(regex, replacement);
  179. Load(newuri);
  180. }
  181. }
  182. catch (err) {}
  183. }
  184. }
  185.  
  186. function UpdateCustomWidthandHeight(uri, format, regex) {
  187. if (has(uri, format)) {
  188. try {
  189. if (regex.test(uri)) {
  190. var res = getRegexMatch(uri, regex);
  191. var rep = res.replace("/", "");
  192. rep = rep.replace("/", "");
  193. if (has(rep, "x") && has(rep, ",")) {
  194. var res1 = rep.split("x");
  195. var res2 = res1[1].split(",");
  196. if (res1[0] != "6000" && res2.length >= 2 && isNum(res1[0]) && isNum(res2[0]) && isNum(res2[1])) {
  197. var w = getNum(res1[0]);
  198. var h = getNum(res2[0]);
  199. var newh = parseInt((h / w) * 6000);
  200. var replacement = "/" + 6000 + "x" + newh + ",100" + "/";
  201. var newuri = uri.replace(res, replacement);
  202. Load(newuri);
  203. }
  204. }
  205. }
  206. }
  207. catch (err) {}
  208. }
  209. }
  210.  
  211. function CustomWidthandHeightUpdate(uri, width, height) {
  212. if (has(uri, width) && has(uri, height)) {
  213. var res1 = uri.split(width);
  214. var res2 = res1[1].split(height);
  215. if (isNum(res2[0]) && res2[0] != "6000") {
  216. var w = getNum(res2[0]);
  217. var h = getNum(res2[1].split("-")[0]);
  218. var res = width + w + height + h;
  219. var newh = parseInt((h / w) * 6000);
  220. var replacement = width + 6000 + height + newh;
  221. var newuri = uri.replace(res, replacement);
  222. if (uri != newuri) {
  223. Load(newuri);
  224. }
  225. }
  226. }
  227. }
  228.  
  229. function DPRUpdate(uri, d) {
  230. if (has(uri, d)) {
  231. var res = uri.split(d);
  232. if (isNum(res[1]) && res[1] < 3) {
  233. var newuri = res[0] + d + "3";
  234. Load(newuri);
  235. }
  236. else if (!isNum(res[1]) && has(res[1], "&")) {
  237. var res2 = res[1].split("&")[0];
  238. if (isNum(res2) && res2 < 3) {
  239. newuri = uri.replace((d + res2), (d + "3"));
  240. Load(newuri);
  241. }
  242. }
  243. }
  244. }
  245.  
  246. function main(uri, format) {
  247.  
  248. if (has(uri, "image/upload/")) {
  249. ReplaceCustomCrop(uri, "." + format, /q\_auto\//g, "q_auto:best/");
  250. ReplaceCustomCrop(uri, "." + format, /f\_auto\,|fl\_lossy\,|c\_limit\,/g, "");
  251. ReplaceCustomCrop(uri, "." + format, /upload\/[hw]\_\d+\,[hw]\_\d+\//g, "upload/");
  252. }
  253.  
  254. if (has(uri, "wiki")) {
  255. ReplaceCustomCrop(uri, ".svg", /thumb\/|\/\d+px[-]?\w+(.)*.svg(.)*/g, "");
  256. ReplaceCustomCrop(uri, ".jpg", /thumb\/|\/\d+px[-]?\w+(.)*.jpg(.)*/g, "");
  257. ReplaceCustomCrop(uri, ".png", /thumb\/|\/\d+px[-]?\w+(.)*.png(.)*/g, "");
  258. ReplaceCustomCrop(uri, "." + format, /\/zoom\-crop\/(.)*/g, "");
  259. }
  260. if (has(uri, "blogspot") && !has(uri, "/s6000/")) {
  261. ReplaceCustomCrop(uri, "." + format, /\/s\d+\//g, "/s6000/");
  262. }
  263. if (has(uri, "twimg") && !has(uri, "video")) {
  264. ReplaceCustomCrop(uri, format, /\_normal\./g, ".");
  265. if (has(uri, "name")) {
  266. ReplaceCustomCrop(uri, format, /\?format\=jpg\&name\=(.)*/g, "?format=png&name=large");
  267. ReplaceCustomCrop(uri, format, /\?format\=png\&name\=[^(large)(4)](.*)/g, "?format=png&name=large");
  268. ReplaceCustomCrop(uri, format, /\?format\=png\&name\=medium/g, "?format=png&name=large");
  269. }
  270. else if (has(uri, "format")) {
  271. ReplaceCustomCrop(uri, format, /\?format\=jp(.)*/g, "?format=png");
  272. }
  273. }
  274.  
  275. if (has(uri, "usercontent")) {
  276. CustomWidthandHeightUpdate(uri, "=w", "-h");
  277. ReplaceCustomCrop(uri, format, /\?s\=\d+\&v\=\d+/g, "");
  278. }
  279.  
  280. widthUpdate(uri, "." + format + "?w=");
  281. widthUpdate(uri, "." + format + "?width=");
  282. WidthandHeightUpdate(uri, "." + format + "?", "w=", "&h=");
  283. WidthandHeightUpdate(uri, "." + format + "?", "width=", "&height=");
  284.  
  285. HeightandWidthUpdate(uri, "." + format + "?", "h=", "&w=");
  286. HeightandWidthUpdate(uri, "." + format + "?", "height=", "&width=");
  287.  
  288. // Remove crops
  289. ReplaceCustomCrop(uri, "." + format, /\/\d+\,\d+\,\d+\,\d+\//g, "/");
  290. ReplaceCustomCrop(uri, "." + format, /\?crop=\d+\%\d\w\d+\%\d\w\w+\%\w+/g, "");
  291. ReplaceCustomCrop(uri, "." + format, /\?crop=\d+\%3A\d+|\?crop=\d+\:\d+/g, "");
  292. ReplaceCustomCrop(uri, "." + format, /thumbor\/\d+x\d+\//g, "thumbor/origxorig/");
  293. if (!has(uri, "%2F2000")) {
  294. ReplaceCustomCrop(uri, "." + format, /\%2F\d+x0.jpg/g, "%2F2000x0.jpg");
  295. }
  296. if (!has(uri, "/2000")) {
  297. ReplaceCustomCrop(uri, "." + format, /\/\d+x0.jpg/g, "/2000x0.jpg");
  298. }
  299.  
  300. // Remove Blur and bring original
  301. if (has(uri, '.it/') && has(uri, 'blur') && !has(uri, 'external-preview.')) {
  302. if (has(uri, '?blur')) {
  303. ReplaceCustomCrop(uri, format, /\?blur\=(.)*/g, "");
  304. }
  305. else if (has(uri, '?width=')) {
  306. ReplaceCustomCrop(uri, format, /\?width\=(.)*/g, "");
  307. }
  308. if (has(uri, 'preview.')) {
  309. ReplaceCustomCrop(uri, format, /preview/, "i");
  310. }
  311. }
  312.  
  313. // Remove watermark
  314. ReplaceCustomCrop(uri, format, /\&mark64\=(.)*/g, "");
  315. // Auto Enhance
  316. ReplaceCustomCrop(uri, format, /auto\=compress/g, "auto=enhance");
  317. ReplaceCustomCrop(uri, format, /\&cs\=tinysrgb/g, "");
  318.  
  319. UpdateCustomWidthandHeight(uri, "." + format, /\/\d+\x\d+\,\d+\//g);
  320.  
  321. QualityUpdate(uri, "." + format, "/q_", "/");
  322. QualityUpdate(uri, "." + format, "/x,", "/");
  323. QualityUpdate(uri, format, "&q=", "&");
  324.  
  325. sizeUpdate(uri, "." + format + "?size=");
  326. DPRUpdate(uri, "&dpr=");
  327.  
  328. }
  329.  
  330. (function () {
  331. 'use strict';
  332. var uri = window.location.href;
  333. if (has(uri, "jpg")) {
  334. main(uri, "jpg");
  335. }
  336. else if (has(uri, "png")) {
  337. main(uri, "png");
  338. }
  339. else if (has(uri, "jpeg")) {
  340. main(uri, "jpeg");
  341. }
  342. else if (has(uri, "webp")) {
  343. main(uri, "webp");
  344. }
  345. else if (has(uri, "usercontent.com")) {
  346. main(uri, "usercontent");
  347. }
  348.  
  349. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址