Safety on getChapterButton

Fix #1573
This commit is contained in:
Ajay 2022-11-04 15:44:14 -04:00
parent 4b4743f1f7
commit 2c5db670a4

View file

@ -740,7 +740,7 @@ class PreviewBar {
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
const chaptersContainer = this.getChaptersContainer();
const chapterButton = this.getChapterButton(chaptersContainer);
if (chapterButton.classList.contains("ytp-chapter-container-disabled")) {
if (chapterButton && chapterButton.classList.contains("ytp-chapter-container-disabled")) {
chaptersContainer.style.display = "none";
}
@ -820,7 +820,7 @@ class PreviewBar {
private getChapterButton(chaptersContainer: HTMLElement): HTMLButtonElement {
return (chaptersContainer ?? this.getChaptersContainer())
.querySelector("button.ytp-chapter-title") as HTMLButtonElement;
?.querySelector("button.ytp-chapter-title") as HTMLButtonElement;
}
remove(): void {