MangaDexCentered

Centers images and hides scrollbar and right panel

  1. // ==UserScript==
  2. // @name MangaDexCentered
  3. // @namespace MangaDexCentered
  4. // @version 1.0
  5. // @description Centers images and hides scrollbar and right panel
  6. // @author Owyn
  7. // @match https://mangadex.com/chapter/*
  8. // @match https://mangadex.org/chapter/*
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. let i = setInterval(dojob, 100);
  14.  
  15. function dojob()
  16. {
  17. let img = document.querySelector("img.noselect");
  18. if(img && img.naturalWidth) // loaded
  19. {
  20. document.querySelector(".reader-controls-wrapper").remove();
  21. document.querySelector(".reader-main").classList.remove("reader-main");
  22.  
  23. document.documentElement.style.overflow = "hidden"; // hide scrollbar
  24. document.body.style = "margin-right: -50px; padding-right: 50px; overflow-y: scroll; height: " +window.innerHeight+ "px;"; // wheel
  25. let sheet = document.createElement('style');
  26. sheet.innerHTML = ".reader.fit-horizontal .reader-images img { max-width: "+window.innerWidth+"px; }";
  27. document.body.appendChild(sheet); // fix images not being 100% wide
  28. setInterval(function(){document.body.focus();}, 100); // fix arrows and space buttons not working
  29. clearInterval(i);
  30. }
  31. }