mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 04:27:15 +03:00
Add autogenerated type for source in advance skip options
This commit is contained in:
@@ -299,14 +299,14 @@ class PreviewBar {
|
||||
set(segments: PreviewBarSegment[], videoDuration: number): void {
|
||||
this.segments = segments ?? [];
|
||||
this.videoDuration = videoDuration ?? 0;
|
||||
this.hasYouTubeChapters = segments.some((segment) => segment.source === SponsorSourceType.YouTube);
|
||||
this.hasYouTubeChapters = segments.some((segment) => [SponsorSourceType.YouTube, SponsorSourceType.Autogenerated].includes(segment.source));
|
||||
|
||||
// Remove unnecessary original chapters if submitted replacements exist
|
||||
for (const chapter of this.segments.filter((s) => s.actionType === ActionType.Chapter && s.source === SponsorSourceType.Server)) {
|
||||
const segmentDuration = chapter.segment[1] - chapter.segment[0];
|
||||
|
||||
const duplicate = this.segments.find((s) => s.actionType === ActionType.Chapter
|
||||
&& s.source === SponsorSourceType.YouTube
|
||||
&& [SponsorSourceType.YouTube, SponsorSourceType.Autogenerated].includes(s.source)
|
||||
&& Math.abs(s.segment[0] - chapter.segment[0]) < Math.min(3, segmentDuration / 3)
|
||||
&& Math.abs(s.segment[1] - chapter.segment[1]) < Math.min(3, segmentDuration / 3));
|
||||
|
||||
@@ -354,7 +354,7 @@ class PreviewBar {
|
||||
this.chapterMargin = 2;
|
||||
if (this.originalChapterBar) {
|
||||
this.originalChapterBarBlocks = this.originalChapterBar.querySelectorAll(":scope > div") as NodeListOf<HTMLElement>
|
||||
this.existingChapters = this.segments.filter((s) => s.source === SponsorSourceType.YouTube).sort((a, b) => a.segment[0] - b.segment[0]);
|
||||
this.existingChapters = this.segments.filter((s) => [SponsorSourceType.YouTube, SponsorSourceType.Autogenerated].includes(s.source)).sort((a, b) => a.segment[0] - b.segment[0]);
|
||||
|
||||
if (this.existingChapters?.length > 0) {
|
||||
const margin = parseFloat(this.originalChapterBarBlocks?.[0]?.style?.marginRight?.replace("px", ""));
|
||||
@@ -376,7 +376,7 @@ class PreviewBar {
|
||||
this.createChaptersBar(this.segments.sort((a, b) => a.segment[0] - b.segment[0]));
|
||||
|
||||
if (chapterChevron) {
|
||||
if (this.segments.some((segment) => segment.source === SponsorSourceType.YouTube)) {
|
||||
if (this.segments.some((segment) => [SponsorSourceType.YouTube, SponsorSourceType.Autogenerated].includes(segment.source))) {
|
||||
chapterChevron.style.removeProperty("display");
|
||||
} else if (this.segments) {
|
||||
chapterChevron.style.display = "none";
|
||||
@@ -438,10 +438,10 @@ class PreviewBar {
|
||||
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
||||
}
|
||||
|
||||
if ((segments.every((segments) => segments.source === SponsorSourceType.YouTube)
|
||||
if ((segments.every((segment) => [SponsorSourceType.YouTube, SponsorSourceType.Autogenerated].includes(segment.source))
|
||||
|| (!Config.config.renderSegmentsAsChapters
|
||||
&& segments.every((segment) => segment.actionType !== ActionType.Chapter
|
||||
|| segment.source === SponsorSourceType.YouTube)))
|
||||
|| [SponsorSourceType.YouTube, SponsorSourceType.Autogenerated].includes(segment.source))))
|
||||
&& !(hasAutogeneratedChapters() && !Config.config.showAutogeneratedChapters)) {
|
||||
|
||||
if (this.customChaptersBar) this.customChaptersBar.style.display = "none";
|
||||
|
||||
Reference in New Issue
Block a user