From c17cf743898003727f2ca30b2fbc5c7a27013586 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 22 Sep 2022 16:34:17 -0400 Subject: [PATCH] Fix preview bar on mobile --- src/js-components/previewBar.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index a54796d7..b7b27a1f 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -234,14 +234,15 @@ class PreviewBar { const allProgressBars = document.querySelectorAll('.ytp-progress-bar') as NodeListOf; this.progressBar = findValidElement(allProgressBars) ?? allProgressBars?.[0]; - const newChapterBar = this.progressBar.querySelector(".ytp-chapters-container:not(.sponsorBlockChapterBar)") as HTMLElement; - if (this.originalChapterBar !== newChapterBar) { - // Make sure changes are undone on old bar - this.originalChapterBar?.style?.removeProperty("display"); + if (this.progressBar) { + const newChapterBar = this.progressBar.querySelector(".ytp-chapters-container:not(.sponsorBlockChapterBar)") as HTMLElement; + if (this.originalChapterBar !== newChapterBar) { + // Make sure changes are undone on old bar + this.originalChapterBar?.style?.removeProperty("display"); - this.originalChapterBar = newChapterBar; + this.originalChapterBar = newChapterBar; + } } - } private update(): void {