From 7e8d0667efbf1f952a5b90011175c8fc1c1208fe Mon Sep 17 00:00:00 2001 From: Omar Alodwan <31454776+Omar-Alodwan@users.noreply.github.com> Date: Mon, 12 Oct 2026 03:08:37 +0200 Subject: [PATCH] Keep YouTube trailer captions off the home rows Trailers whose uploader set default captions show them at the bottom of the player. The trailer fills the bar behind the home rows, so the captions are drawn over them. Add a trailerCaptions option (default off, "Trailer captions" switch in the settings panel). While it is off, the caption module is unloaded on ready and again when playback starts, since YouTube loads it on play. --- slideshowpure.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/slideshowpure.js b/slideshowpure.js index bb1f05b..532e749 100644 --- a/slideshowpure.js +++ b/slideshowpure.js @@ -73,6 +73,9 @@ const CONFIG = { // 0-100. Volume once unmuted. Trailers always start muted. trailerVolume: 50, + // true|false. Show the uploader's default captions on YouTube trailers. Off by default: the trailer fills the bar behind the home rows, so captions land on top of them. + trailerCaptions: false, + // px. At or below this width the layout is swipe-only: no arrows, no trailer, no volume. touchLayoutMaxWidth: 767, @@ -412,6 +415,17 @@ const STATE = { }, }; +// YouTube loads its caption module once playback starts, so this runs on ready and again on play. +const hideTrailerCaptions = (player) => { + if (CONFIG.trailerCaptions) return; + try { + player.unloadModule("captions"); + player.unloadModule("cc"); + } catch (err) { + // player not ready or no caption module: nothing to hide + } +}; + const loadYouTubeAPI = () => { if (STATE.slideshow.ytPromise) return STATE.slideshow.ytPromise; @@ -2923,13 +2937,18 @@ const SlideCreator = { start: startTime, }, events: { - onStateChange: (e) => + onStateChange: (e) => { + if (e.data === YT.PlayerState.PLAYING) hideTrailerCaptions(e.target); SlideshowManager.onPlayerStateChange( e, itemId, trailerContainer, - ), - onReady: (e) => e.target.mute(), + ); + }, + onReady: (e) => { + e.target.mute(); + hideTrailerCaptions(e.target); + }, onError: (e) => SlideshowManager.onPlayerError(e, itemId, trailerContainer), @@ -3956,6 +3975,7 @@ const SettingsPanel = { step: 5, format: (value) => `${value}%`, }, + { key: "trailerCaptions", label: "Trailer captions", type: "switch" }, { key: "trailerLibraries", label: "Trailers from",