MangaDexCentered

Centers images and hides scrollbar and right panel

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name          MangaDexCentered
// @namespace     MangaDexCentered
// @version       1.0
// @description   Centers images and hides scrollbar and right panel
// @author        Owyn
// @match         https://mangadex.com/chapter/*
// @match         https://mangadex.org/chapter/*
// @run-at        document-end
// @grant         none
// ==/UserScript==

let i = setInterval(dojob, 100);

function dojob()
{
	let img = document.querySelector("img.noselect");
	if(img && img.naturalWidth) // loaded
	{
		document.querySelector(".reader-controls-wrapper").remove();
		document.querySelector(".reader-main").classList.remove("reader-main");

		document.documentElement.style.overflow = "hidden"; // hide scrollbar
		document.body.style = "margin-right: -50px; padding-right: 50px; overflow-y: scroll; height: " +window.innerHeight+ "px;"; // wheel
		
		let sheet = document.createElement('style');
		sheet.innerHTML = ".reader.fit-horizontal .reader-images img { max-width: "+window.innerWidth+"px; }";
		document.body.appendChild(sheet);  // fix images not being 100% wide
		setInterval(function(){document.body.focus();}, 100); // fix arrows and space buttons not working
    
		clearInterval(i);
	}
}