Sleazy Fork is available in English.

e621 Thumbnail Enhancer 2

Resizes thumbnails on e621.net and replaces them with hi-rez version. Modified for the new site design sometime around 2020-03-06

Od 09.03.2020.. Pogledajte najnovija verzija.

  1. // ==UserScript==
  2. // @name e621 Thumbnail Enhancer 2
  3. // @version 1.05
  4. // @description Resizes thumbnails on e621.net and replaces them with hi-rez version. Modified for the new site design sometime around 2020-03-06
  5. // @author justrunmyscripts
  6. // @include *://*e621.net*
  7. // @grant GM.xmlHttpRequest
  8. // @namespace https://sleazyfork.org/en/users/96703-justrunmyscripts
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12.  
  13. // original script creator https://greasyfork.org/de/users/398891
  14. // to edit the size of the thumbnails, change the 25vw values below (the ones marked with !important... ;D )
  15.  
  16. try {
  17. let isMyAbsoluteFavoritePath = window.location.toString().endsWith('/favorites');
  18. let postContainerHash = isMyAbsoluteFavoritePath ? '#posts' : '#posts-container';
  19.  
  20. let sty =document.createElement("style");
  21. sty.innerHTML=[
  22. ""
  23. ,".thumbEnh_cont {"
  24. ," display: flex;"
  25. ," flex-flow: row wrap;"
  26. ,"}"
  27. ,".thumbEnh_cont img.thumbEnh_img {"
  28. ," max-height: 100%;"
  29. ," max-width: 100%;"
  30. ,"}"
  31. ,"article.post-preview {"
  32. ," height: 25vw !important;"
  33. ," width: 25vw !important;"
  34. ,"}"
  35. ,"article.post-preview > a, article.post-preview > a > picture {"
  36. ," height: 94%;"
  37. ," width: 100%;"
  38. ,"}"
  39. ].join("");
  40. document.head.appendChild(sty);
  41.  
  42.  
  43. /* Replace image thumbnails with higher resolution */
  44. const imageThumb = (thumb) => {
  45. let newThumb = document.createElement('img');
  46. let replace = function (thumb) {
  47. thumb.src = this.src;
  48. };
  49. let tryNoSample = function (thumb) {
  50. this.onerror = tryPng.bind(this, thumb);
  51. this.src = thumb.src.replace('/preview/', '/');
  52. };
  53. let tryPng = function (thumb) {
  54. this.onerror = tryGif.bind(this, thumb);
  55. this.src = thumb.src.replace('/preview/', '/').replace('.jpg', '.png');
  56. };
  57. let tryGif = function (thumb) {
  58. this.onerror = null;
  59. this.src = thumb.src.replace('/preview/', '/').replace('.jpg', '.gif');
  60. };
  61. newThumb.onload = replace.bind(newThumb, thumb);
  62. newThumb.onerror = tryNoSample.bind(newThumb, thumb);
  63. newThumb.src = thumb.src.replace('/preview/', '/sample/');
  64. }
  65.  
  66. const main = () => {
  67. let contDiv = document.querySelector(postContainerHash);
  68. contDiv.className = "thumbEnh_cont";
  69.  
  70. let imgs = document.querySelectorAll('article.post-preview img');
  71. for (img of imgs) {
  72. img.className = "thumbEnh_img";
  73. imageThumb(img);
  74. }
  75.  
  76. // remove extra sources, since we're just using the "high rez" version anyways!
  77. let sources = document.querySelectorAll('article.post-preview source');
  78. for (source of sources) {
  79. let parent = source.parentNode;
  80. parent.removeChild(source);
  81. }
  82. };
  83.  
  84. main();
  85.  
  86. } catch (e) {
  87. // due to the way greasemonkey 'traps' errors, it kinda hides where the problem is!
  88. // this is an attempt at "fixing" that
  89. console.error(e);
  90. }