diff --git a/static/player/episodes/nav.ts b/static/player/episodes/nav.ts index c68d3c0..c61d3ca 100644 --- a/static/player/episodes/nav.ts +++ b/static/player/episodes/nav.ts @@ -1,5 +1,5 @@ import { state } from '../state'; -import { SkipSegment } from '../types'; +import type { SkipSegment } from '../types'; import { resolveActiveSegments, renderSegments } from '../skip/segments'; import { updateSubtitleOptions } from '../subtitles'; import { updateQualityOptions } from '../quality'; @@ -74,7 +74,9 @@ export const goToNextEpisode = async (): Promise => { const preferredQuality = localStorage.getItem('mal:preferred-quality') || 'best'; state.video.src = `${state.streamURL}?mode=${encodeURIComponent(fallback)}&token=${encodeURIComponent(state.modeSources[fallback].token)}${preferredQuality !== 'best' ? `&quality=${encodeURIComponent(preferredQuality)}` : ''}`; state.video.load(); - if (!state.video.paused) state.video.play().catch(() => {}); + if (!state.video.paused) { + state.video.play().catch(() => undefined); + } state.pendingSeekTime = null; state.completionSent = false; diff --git a/static/player/main.ts b/static/player/main.ts index 17d20a9..6272cff 100644 --- a/static/player/main.ts +++ b/static/player/main.ts @@ -116,7 +116,9 @@ const initPlayer = (): void => { } const onLoadedMetadata = (): void => { - loading && (loading.style.display = 'none'); + if (loading) { + loading.style.display = 'none'; + } invalidateBounds(); resolveActiveSegments(); @@ -136,7 +138,9 @@ const initPlayer = (): void => { state.transitionEpisode = null; } // autoplay if not already playing (inline script may have already called play()) - if (state.shouldAutoPlay || state.video.paused) state.video.play().catch(() => {}); + if (state.shouldAutoPlay || state.video.paused) { + state.video.play().catch(() => undefined); + } updateTimeline(state.video.currentTime); updateSkipButton(state.video.currentTime); @@ -150,10 +154,14 @@ const initPlayer = (): void => { } state.video.addEventListener('waiting', () => { - loading && (loading.style.display = 'flex'); + if (loading) { + loading.style.display = 'flex'; + } }); state.video.addEventListener('playing', () => { - loading && (loading.style.display = 'none'); + if (loading) { + loading.style.display = 'none'; + } }); // update progress bar during buffering state.video.addEventListener('progress', () => { diff --git a/static/player/mode.ts b/static/player/mode.ts index 99e069d..ea22806 100644 --- a/static/player/mode.ts +++ b/static/player/mode.ts @@ -21,7 +21,9 @@ const loadVideo = (url: string): void => { state.video.src = url; state.video.load(); state.pendingSeekTime = prevTime; // restored in loadedmetadata handler - if (wasPlaying) state.video.play().catch(() => {}); + if (wasPlaying) { + state.video.play().catch(() => undefined); + } }; /** @@ -51,13 +53,17 @@ export const updateModeButtons = (): void => { dub?.classList.toggle('text-foreground', m !== 'dub'); dub?.classList.toggle('opacity-50', !state.availableModes.includes('dub')); dub?.classList.toggle('cursor-not-allowed', !state.availableModes.includes('dub')); - dub && (dub.disabled = !state.availableModes.includes('dub')); + if (dub) { + dub.disabled = !state.availableModes.includes('dub'); + } sub?.classList.toggle('text-accent', m === 'sub'); sub?.classList.toggle('text-foreground', m !== 'sub'); sub?.classList.toggle('opacity-50', !state.availableModes.includes('sub')); sub?.classList.toggle('cursor-not-allowed', !state.availableModes.includes('sub')); - sub && (sub.disabled = !state.availableModes.includes('sub')); + if (sub) { + sub.disabled = !state.availableModes.includes('sub'); + } }; /** diff --git a/static/player/progress.ts b/static/player/progress.ts index 3e19c87..e8dd688 100644 --- a/static/player/progress.ts +++ b/static/player/progress.ts @@ -89,7 +89,7 @@ export const markEpisodeTransition = (episodeNumber: number): void => { headers: { 'Content-Type': 'application/json' }, keepalive: true, body: payload, - }).catch(() => {}); + }).catch(() => undefined); } }; diff --git a/static/player/quality.ts b/static/player/quality.ts index e41d612..425b323 100644 --- a/static/player/quality.ts +++ b/static/player/quality.ts @@ -17,7 +17,9 @@ const loadVideo = (url: string): void => { state.video.src = url; state.video.load(); state.pendingSeekTime = prevTime; - if (wasPlaying) state.video.play().catch(() => {}); + if (wasPlaying) { + state.video.play().catch(() => undefined); + } }; /** diff --git a/static/player/skip/index.ts b/static/player/skip/index.ts index cc08269..3f0256d 100644 --- a/static/player/skip/index.ts +++ b/static/player/skip/index.ts @@ -48,7 +48,8 @@ export const updateSkipButton = (currentTime: number): void => { */ export const updateAutoSkipButton = (): void => { const btn = document.querySelector('[data-autoskip]') as HTMLInputElement | null; - btn && (btn.checked = localStorage.getItem('mal:autoskip-enabled') === 'true'); + if (!btn) return; + btn.checked = localStorage.getItem('mal:autoskip-enabled') === 'true'; }; /**