From cb9e7ba4322c2e335d8f7e4fa9232a72d8225544 Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Fri, 23 Sep 2022 15:35:54 +0000 Subject: [PATCH] Add epubjs theme support to the book player Add a dark theme to the book player via epubjs. The theme itself uses the dark theme of Jellyfin and only changes the colour of the text. For everything but the text, the dark theme from Jellyfin is retained. Should any other theme than the dark theme be chosen by the user, epubjs falls back to it's default theme. --- src/plugins/bookPlayer/plugin.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/bookPlayer/plugin.js b/src/plugins/bookPlayer/plugin.js index 705a4757d4..a4f49b8b6e 100644 --- a/src/plugins/bookPlayer/plugin.js +++ b/src/plugins/bookPlayer/plugin.js @@ -9,6 +9,7 @@ import Screenfull from 'screenfull'; import TableOfContents from './tableOfContents'; import dom from '../../scripts/dom'; import { translateHtml } from '../../scripts/globalize'; +import * as userSettings from '../../scripts/settings/userSettings'; import '../../elements/emby-button/paper-icon-button-light'; @@ -294,6 +295,12 @@ export class BookPlayer { this.currentSrc = downloadHref; this.rendition = rendition; + rendition.themes.register('dark', { 'body': { 'color': '#fff' } }); + + if (userSettings.theme(undefined) === 'dark' || userSettings.theme(undefined) === null) { + rendition.themes.select('dark'); + } + return rendition.display().then(() => { const epubElem = document.querySelector('.epub-container'); epubElem.style.opacity = '0';