Skip to content

Commit 2c5db67

Browse files
committed
Safety on getChapterButton
Fix #1573
1 parent 4b4743f commit 2c5db67

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/js-components/previewBar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ class PreviewBar {
740740
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
741741
const chaptersContainer = this.getChaptersContainer();
742742
const chapterButton = this.getChapterButton(chaptersContainer);
743-
if (chapterButton.classList.contains("ytp-chapter-container-disabled")) {
743+
if (chapterButton && chapterButton.classList.contains("ytp-chapter-container-disabled")) {
744744
chaptersContainer.style.display = "none";
745745
}
746746

@@ -820,7 +820,7 @@ class PreviewBar {
820820

821821
private getChapterButton(chaptersContainer: HTMLElement): HTMLButtonElement {
822822
return (chaptersContainer ?? this.getChaptersContainer())
823-
.querySelector("button.ytp-chapter-title") as HTMLButtonElement;
823+
?.querySelector("button.ytp-chapter-title") as HTMLButtonElement;
824824
}
825825

826826
remove(): void {

0 commit comments

Comments
 (0)