// ==UserScript== // @name MangaDex Reader fullscreen // @namespace Teasday // @version 0.3 // @license CC-BY-NC-SA-4.0 // @description Adds a fullscreen viewer to MangaDex // @author Teasday, Eva // @match https://mangadex.com/chapter/* // @icon https://mangadex.com/favicon.ico // @homepage https://ewasion.github.io/userscripts/mangadex-fullscreen/ // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // add css const addStyle = function (css) { const head = document.getElementsByTagName('head')[0]; if (!head) return; const style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style); }; addStyle(` #reader-container { position: relative; width: calc(100vw - 15px); left: calc(-50vw + 50%); padding: 0 5px; } #reader-container.fullscreen { z-index: 2000; position: absolute; top: 0; left: 0; right: 0; padding: 0; margin: 0; background: #111; display: flex; align-items: center; justify-content: center; height: 100%; min-height: 100%; width: auto; } #reader-container.fullscreen.fitwidth { height: auto; } img.reader { width: auto; max-height: calc(100vh - 50px); } #reader-container.fullscreen img.reader { height: 100%; max-height: 100%; max-width: none; } #reader-container.fitwidth img.reader { height: auto; max-height: none; max-width: 100%; } #reader-size-controls { display: none; cursor: pointer; float: right; text-align: right; margin: 5px; font-size: 2em; color: #ddd; text-shadow: #000 1px 1px 4px; } #reader-container.fullscreen ~ #reader-size-controls { z-index: 2020; position: fixed; display: block; top: 5px; right: 5px; opacity: 0.3; transition: all 0.4s; } #reader-container.fullscreen ~ #reader-size-controls:hover { opacity: 1; background: rgba(0, 0, 0, .4); box-shadow: 0 0 25px 15px rgba(0, 0, 0, .4); } #reader-container.fullscreen ~ #reader-size-controls > div:hover { color: #fff; text-shadow: #fff 0 0 10px; transition: all 0.25s; } #reader-page-controls, #reader-page-controls div { position: absolute; top: 0; width: 100%; height: 100%; } #reader-page-controls .prev-page { left: 0; width: 50%; } #reader-page-controls .next-page { right: 0; width: 50%; } #reader-page-controls .prev-chapter { left: 0; width: 20%; } #reader-page-controls .next-chapter { right: 0; width: 20%; } #reader-page-controls .prev-chapter, #reader-page-controls .next-chapter { opacity: 0; font-weight: bold; font-size: 5vh; background: radial-gradient(ellipse at center, rgba(10, 10, 10, .6) 0%, rgba(10, 10, 10, 0) 60%); transition: opacity 0.2s; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, .8); } #reader-page-controls .prev-chapter:before { content: '\xAB'; left: 0; } #reader-page-controls .next-chapter:before { content: '\xBB'; right: 0; } #reader-page-controls .prev-chapter:hover, #reader-page-controls .next-chapter:hover { opacity: 0.9; } .footer { height: auto; } .footer > p { margin-bottom: 0; } `); // control button data const controls = { fullscreen: { icon: 'expand-arrows-alt', titles: ['Enter fullscreen', 'Exit fullscreen'] }, fitwidth: { icon: 'expand', titles: ['Fit to width (or auto)', 'Fit to height'] } }; // add html const content = document.getElementById('content'); const sizeControls = document.createElement('div'); sizeControls.id = 'reader-size-controls'; sizeControls.innerHTML = Object.entries(controls).reduce(function(acc, ctrl) { return `${acc}