Greasy Fork镜像 支持简体中文。

manga sites tweaks

image loading indicators, prevent headers from being sticky

  1. // ==UserScript==
  2. // @name manga sites tweaks
  3. // @namespace Itsnotlupus Industries
  4. // @match https://1stkissmanga.io/*
  5. // @match https://manga-tx.com/*
  6. // @match https://isekaiscan.com/*
  7. // @match https://manhuaplus.com/*
  8. // @grant none
  9. // @version 1.5
  10. // @author -
  11. // @description image loading indicators, prevent headers from being sticky
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. // TODO: Add applicable manga domains as needed.
  16. // TODO: maybe try to auto-reload broken images?
  17.  
  18. // utilities
  19. const crel = (e, attrs) => Object.assign(document.createElement(e), attrs);
  20. const observe = (fn, e = document.body, config = { attributes: 1, childList: 1, subtree: 1 }) => {
  21. const observer = new MutationObserver(fn);
  22. observer.observe(e, config);
  23. return () => observer.disconnect();
  24. };
  25.  
  26. // yin yang SVG derived from https://icons8.com/preloaders/en/filtered-search/all/free;svg/
  27. const loading_svg = 'data:image/svg+xml;base64,'+btoa`
  28. <svg xmlns="http://www.w3.org/2000/svg" width="64" height="128" viewBox="0 -128 128 256">
  29. <circle cx="64" cy="64" r="63.31" fill="#fff"/>
  30. <g>
  31. <path d="M3.13 44.22a64 64 0 1 0 80.65-41.1 64 64 0 0 0-80.65 41.1zm34.15-4.83a10.63 10.63 0 1 1-13.4 6.8 10.63 10.63 0 0 1 13.4-6.8zm7.85 82.66A61.06 61.06 0 0 1 5.7 45.86 30.53 30.53 0 0 0 64 64a30.53 30.53 0 0 1 58.3 18.12l.35-1.14-.58 1.9a61.06 61.06 0 0 1-76.94 39.2zM106.9 73.2A10.63 10.63 0 1 0 93.5 80a10.63 10.63 0 0 0 13.4-6.8z"/>
  32. <animateTransform attributeName="transform" dur="1200ms" from="0 64 64" repeatCount="indefinite" to="-360 64 64" type="rotate"/>
  33. </g>
  34. </svg>`;
  35.  
  36. // show a clear loading state when a page is missing
  37. document.head.append(crel('style', {
  38. type: 'text/css',
  39. textContent: `img.wp-manga-chapter-img,img[class^="wp-image-"] {
  40. min-height: 300px;
  41. background: fixed repeat-y center #777 url('${loading_svg}');
  42. }
  43. .c-blog-post .entry-content .entry-content_wrap {
  44. line-height: 1em;
  45. }
  46. `}));
  47.  
  48. observe(() => {
  49. // don't bring up a distracting sticky header on every scroll up
  50. document.querySelectorAll('.sticky').forEach(e => e.classList.remove('sticky'));
  51. // unset min-height on loaded images, to render thin slices correctly
  52. document.querySelectorAll(`img.wp-manga-chapter-img:not([style*='min-height']),img[class^="wp-image-"]:not([style*='min-height'])`).forEach(img => {
  53. if (img.naturalWidth) img.style.minHeight=0;
  54. });
  55. });

QingJ © 2025

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