mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 21:47:06 +03:00
Fix chapter name sometimes disappearing
This commit is contained in:
@@ -867,3 +867,7 @@ input::-webkit-inner-spin-button {
|
|||||||
.sponsorThumbnailLabel:hover span {
|
.sponsorThumbnailLabel:hover span {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sponsorblock-chapter-visible {
|
||||||
|
display: inherit !important;
|
||||||
|
}
|
||||||
@@ -774,10 +774,11 @@ class PreviewBar {
|
|||||||
if (!Config.config.showSegmentNameInChapterBar
|
if (!Config.config.showSegmentNameInChapterBar
|
||||||
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
|
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
|
||||||
const chaptersContainer = this.getChaptersContainer();
|
const chaptersContainer = this.getChaptersContainer();
|
||||||
const chapterButton = this.getChapterButton(chaptersContainer);
|
chaptersContainer.querySelector(".sponsorChapterText")?.remove();
|
||||||
if (chapterButton && chapterButton.classList.contains("ytp-chapter-container-disabled")) {
|
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
||||||
chaptersContainer.style.display = "none";
|
|
||||||
}
|
chapterTitle.style.removeProperty("display");
|
||||||
|
chaptersContainer.classList.remove("sponsorblock-chapter-visible");
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -802,7 +803,7 @@ class PreviewBar {
|
|||||||
|
|
||||||
if (chaptersContainer) {
|
if (chaptersContainer) {
|
||||||
if (segments.length > 0) {
|
if (segments.length > 0) {
|
||||||
chaptersContainer.style.removeProperty("display");
|
chaptersContainer.classList.add("sponsorblock-chapter-visible");
|
||||||
|
|
||||||
const chosenSegment = segments.sort((a, b) => {
|
const chosenSegment = segments.sort((a, b) => {
|
||||||
if (a.actionType === ActionType.Chapter && b.actionType !== ActionType.Chapter) {
|
if (a.actionType === ActionType.Chapter && b.actionType !== ActionType.Chapter) {
|
||||||
@@ -819,11 +820,11 @@ 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 = "";
|
chapterTitle.style.display = "none";
|
||||||
|
|
||||||
const chapterCustomText = (chapterTitle.querySelector(".sponsorChapterText") || (() => {
|
const chapterCustomText = (chapterTitle.parentElement.querySelector(".sponsorChapterText") || (() => {
|
||||||
const elem = document.createElement("div");
|
const elem = document.createElement("div");
|
||||||
chapterTitle.appendChild(elem);
|
chapterTitle.parentElement.insertBefore(elem, chapterTitle);
|
||||||
elem.classList.add("sponsorChapterText");
|
elem.classList.add("sponsorChapterText");
|
||||||
return elem;
|
return elem;
|
||||||
})()) as HTMLDivElement;
|
})()) as HTMLDivElement;
|
||||||
@@ -854,11 +855,10 @@ class PreviewBar {
|
|||||||
} else {
|
} else {
|
||||||
chaptersContainer.querySelector(".sponsorChapterText")?.remove();
|
chaptersContainer.querySelector(".sponsorChapterText")?.remove();
|
||||||
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
||||||
if (chapterTitle.innerText === "") {
|
|
||||||
chaptersContainer.style.display = "none";
|
chapterTitle.style.removeProperty("display");
|
||||||
} else {
|
chaptersContainer.classList.remove("sponsorblock-chapter-visible");
|
||||||
chaptersContainer.style.removeProperty("display");
|
|
||||||
}
|
|
||||||
this.chapterVote.setVisibility(false);
|
this.chapterVote.setVisibility(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user