mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 21:17:20 +03:00
Fix chapter name sometimes disappearing
This commit is contained in:
@@ -814,7 +814,16 @@ class PreviewBar {
|
|||||||
chapterButton.disabled = false;
|
chapterButton.disabled = false;
|
||||||
|
|
||||||
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
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) {
|
if (chosenSegment.actionType !== ActionType.Chapter) {
|
||||||
chapterTitle.classList.add("sponsorBlock-segment-title");
|
chapterTitle.classList.add("sponsorBlock-segment-title");
|
||||||
} else {
|
} else {
|
||||||
@@ -838,7 +847,13 @@ class PreviewBar {
|
|||||||
this.chapterVote.setVisibility(false);
|
this.chapterVote.setVisibility(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chaptersContainer.style.display = "none";
|
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);
|
this.chapterVote.setVisibility(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user