Greasy Fork is available in English.

Comicslate PicZoom

Подгонка комиксов под ширину экрана

// ==UserScript==
// @name			Comicslate PicZoom
// @version			2019.11.28.1
// @description		Fit comics to screen width
// @description:ru	Подгонка комиксов под ширину экрана
// @include			http*://*comicslate.org/*
// @author			Rainbow-Spike, lurker, Katod
// @namespace		https://greasyfork.org/users/7568
// @homepage		https://greasyfork.org/ru/users/7568-dr-yukon
// @icon			https://www.google.com/s2/favicons?domain=comicslate.org
// @grant			none
// @run-at			document-end
// ==/UserScript==

var	page = document.querySelector (".page"),
	pagewidth = page.offsetWidth - 3,
	ctc = page.querySelectorAll ( ".page > * > .ct-container, .page > * > .fn-container, .page > * > * > .ct-container, .page > * > * > .fn-container" ),
	i;

function zoom ( ) {
	for ( i = 0; i < ctc.length; i++ ) {
		var scale = pagewidth / img.width,
			margin = ( scale - 1 ) * img.height / 2;
		ctc[i].style.transform = "scale(" + scale + ")";
		ctc[i].style.margin = margin + "px auto";
		if ( scale < 1 ) ctc[i].style.transformOrigin = 'left';
	}
}

for ( i = 0; i < ctc.length; i++ ) {
	var img = ctc[i].querySelector ( "img" );
	img.onload = zoom;
}