From 292f779ee8d86e18ede37ff16201682e058a18bb Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sun, 21 Jun 2026 02:04:49 +0200 Subject: [PATCH] style: format static/player/skip/segments.ts --- static/player/skip/segments.ts | 42 ++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/static/player/skip/segments.ts b/static/player/skip/segments.ts index 5aa156a..5770f06 100644 --- a/static/player/skip/segments.ts +++ b/static/player/skip/segments.ts @@ -7,8 +7,8 @@ const MAX_INTRO_START = 180; // intro must start before 3min const MIN_OUTRO_START_RATIO = 0.5; // outro must start at least 50% in /** - * Filters parsed segments to only those within video bounds and sensible duration. - * Validates intro/outro positioning. + * Filters parsed segments to only those within video bounds and sensible duration. Validates + * intro/outro positioning. */ export const resolveActiveSegments = (): void => { const bounds = state.elements.video.duration; @@ -19,24 +19,36 @@ export const resolveActiveSegments = (): void => { const normalizeType = (t: string): "op" | "ed" | null => { const v = (t || "").toLowerCase(); - if (v === "op" || v === "opening" || v === "intro") return "op"; - if (v === "ed" || v === "ending" || v === "outro") return "ed"; + if (v === "op" || v === "opening" || v === "intro") { + return "op"; + } + if (v === "ed" || v === "ending" || v === "outro") { + return "ed"; + } return null; }; state.skip.activeSegments = state.skip.parsedSegments.filter((s) => { const t = normalizeType(s.type); - if (!t) return false; + if (!t) { + return false; + } const isOverride = (s.source || "").toLowerCase() === "override"; const len = s.end - s.start; // duration filter - if (len < MIN_SEGMENT_DURATION || len > MAX_SEGMENT_DURATION) return false; + if (len < MIN_SEGMENT_DURATION || len > MAX_SEGMENT_DURATION) { + return false; + } // bounds check - if (s.start < 0 || s.end <= s.start || s.end > bounds + 1) return false; + if (s.start < 0 || s.end <= s.start || s.end > bounds + 1) { + return false; + } // User overrides should render even if they don't fit AniSkip's usual OP/ED heuristics. - if (isOverride) return true; + if (isOverride) { + return true; + } // intro: starts early, before 50% of video if (t === "op") { @@ -50,16 +62,18 @@ export const resolveActiveSegments = (): void => { }); }; -/** - * Renders segment markers on the timeline progress bar. - */ +/** Renders segment markers on the timeline progress bar. */ export const renderSegments = (): void => { const track = state.elements.container.querySelector("[data-segments]") as HTMLElement | null; - if (!track) return; + if (!track) { + return; + } track.replaceChildren(); const bounds = state.elements.video.duration; - if (bounds <= 0) return; + if (bounds <= 0) { + return; + } state.skip.activeSegments.forEach((s) => { const bar = document.createElement("div"); @@ -68,6 +82,6 @@ export const renderSegments = (): void => { bar.style.height = "calc(100% + 2px)"; bar.style.left = `${(s.start / bounds) * 100}%`; bar.style.width = `${((s.end - s.start) / bounds) * 100}%`; - track.appendChild(bar); + track.append(bar); }); };