diff --git a/src/content.ts b/src/content.ts index a9e92f10..26318c45 100644 --- a/src/content.ts +++ b/src/content.ts @@ -761,7 +761,7 @@ function getYouTubeVideoID(url: string) { */ function updatePreviewBarPositionMobile(parent: HTMLElement) { if (document.getElementById("previewbar") === null) { - previewBar.updatePosition(parent); + previewBar.createElement(parent); } } diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index 67d28c1a..0235727e 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -1,5 +1,5 @@ /* -This is based on code from VideoSegments. +Parts of this are inspired from code from VideoSegments, but rewritten and under the LGPLv3 license https://github.com/videosegments/videosegments/commits/f1e111bdfe231947800c6efdd51f62a4e7fef4d4/segmentsbar/segmentsbar.js */ @@ -37,7 +37,7 @@ class PreviewBar { this.onMobileYouTube = onMobileYouTube; this.onInvidious = onInvidious; - this.updatePosition(parent); + this.createElement(parent); this.setupHoverText(); } @@ -134,7 +134,7 @@ class PreviewBar { }); } - updatePosition(parent: HTMLElement): void { + createElement(parent: HTMLElement): void { this.parent = parent; if (this.onMobileYouTube) { @@ -148,16 +148,6 @@ class PreviewBar { this.parent.prepend(this.container); } - // TODO: call on config changes - updateColor(segmentType: string, color: string, opacity: number): void { - const bars = > document.querySelectorAll('[data-vs-segment-type=' + segmentType + ']'); - - for (const bar of bars) { - bar.style.backgroundColor = color; - bar.style.opacity = String(opacity); - } - } - clear(): void { this.videoDuration = 0; this.segments = []; @@ -169,7 +159,6 @@ class PreviewBar { set(segments: PreviewBarSegment[], videoDuration: number): void { this.clear(); - if (!segments) return; this.segments = segments; @@ -195,7 +184,7 @@ class PreviewBar { bar.setAttribute('data-vs-segment-type', barSegmentType); bar.style.backgroundColor = Config.config.barTypes[barSegmentType]?.color; - if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[barSegmentType].opacity; + if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[barSegmentType]?.opacity; bar.style.position = "absolute"; bar.style.width = this.timeToPercentage(segment[1] - segment[0]);