ExHentai | Fix Images

Fix wrong images url on exhentai website

  1. // ==UserScript==
  2. // @name ExHentai | Fix Images
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.0
  5. // @description Fix wrong images url on exhentai website
  6. // @author extra.lewd
  7. // @match https://exhentai.org/*
  8. // @exclude https://exhentai.org/g/*
  9. // @exclude https://exhentai.org/s/*
  10. // @icon https://exhentai.org/favicon.ico
  11. // @run-at document-end
  12. // @license CC BY-NC-ND 4.0
  13. // @license-url https://creativecommons.org/licenses/by-nc-nd/4.0/
  14. // @homepage https://discord.gg/TcWrM6pXWD
  15. // @homepageURL https://discord.gg/TcWrM6pXWD
  16. // @website https://discord.gg/TcWrM6pXWD
  17. // @source https://discord.gg/TcWrM6pXWD
  18. // @compatible firefox
  19. // @compatible chrome
  20. // @compatible opera
  21. // @compatible safari
  22. // @compatible edge
  23. // ==/UserScript==
  24. (function () {
  25. 'use strict';
  26. // thx to devs, best site ever! (no sarcasm, rly!)
  27. fix();
  28. const observer = new MutationObserver(fix);
  29. observer.observe(document.querySelector("body"), {
  30. childList: true,
  31. subtree: true,
  32. attributes: true,
  33. });
  34. function fix() {
  35. const images1 = document.querySelectorAll("img[src*='https://s.exhentai.org/']") || [];
  36. const images2 = document.querySelectorAll("img[data-src*='https://s.exhentai.org/']") || [];
  37. for (const image of [...images2, ...images1]) {
  38. const src = (image.getAttribute("data-src") || image.getAttribute("src")).replace("s.exhentai.org", "ehgt.org");
  39. image.setAttribute("src", src);
  40. image.setAttribute("data-src", src);
  41. }
  42. }
  43. })();