mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Fix chapter name sometimes disappearing
This commit is contained in:
parent
76aa472745
commit
8383699a68
1 changed files with 17 additions and 2 deletions
|
@ -814,7 +814,16 @@ class PreviewBar {
|
|||
chapterButton.disabled = false;
|
||||
|
||||
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
||||
chapterTitle.innerText = chosenSegment.description || shortCategoryName(chosenSegment.category);
|
||||
chapterTitle.innerText = "";
|
||||
|
||||
const chapterCustomText = (chapterTitle.querySelector(".sponsorChapterText") || (() => {
|
||||
const elem = document.createElement("div");
|
||||
chapterTitle.appendChild(elem);
|
||||
elem.classList.add("sponsorChapterText");
|
||||
return elem;
|
||||
})()) as HTMLDivElement;
|
||||
chapterCustomText.innerText = chosenSegment.description || shortCategoryName(chosenSegment.category);
|
||||
|
||||
if (chosenSegment.actionType !== ActionType.Chapter) {
|
||||
chapterTitle.classList.add("sponsorBlock-segment-title");
|
||||
} else {
|
||||
|
@ -838,7 +847,13 @@ class PreviewBar {
|
|||
this.chapterVote.setVisibility(false);
|
||||
}
|
||||
} else {
|
||||
chaptersContainer.querySelector(".sponsorChapterText")?.remove();
|
||||
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
||||
if (chapterTitle.innerText === "") {
|
||||
chaptersContainer.style.display = "none";
|
||||
} else {
|
||||
chaptersContainer.style.removeProperty("display");
|
||||
}
|
||||
this.chapterVote.setVisibility(false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue