diff --git a/src/content.ts b/src/content.ts index a54256ae..7ea47e63 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1577,7 +1577,9 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: sponsorSkipped[index] = true; if (!counted) { Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60; - Config.config.skipCount = Config.config.skipCount + 1; + if (segment.actionType !== ActionType.Chapter) { + Config.config.skipCount = Config.config.skipCount + 1; + } counted = true; } @@ -2286,11 +2288,16 @@ function windowListenerHandler(event: MessageEvent): void { } function updateActiveSegment(currentTime: number): void { - previewBar?.updateChapterText(sponsorTimes, sponsorTimesSubmitting, currentTime); + const activeSegments = previewBar?.updateChapterText(sponsorTimes, sponsorTimesSubmitting, currentTime); chrome.runtime.sendMessage({ message: "time", time: currentTime }); + + const chapterSegments = activeSegments?.filter((segment) => segment.actionType === ActionType.Chapter); + if (chapterSegments?.length > 0) { + sendTelemetryAndCount(chapterSegments, 0, true); + } } function nextChapter(): void { diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index 1f1098ce..49b3676d 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -719,7 +719,7 @@ class PreviewBar { } } - updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): void { + updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): SponsorTime[] { if (!Config.config.showSegmentNameInChapterBar || ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) { const chaptersContainer = this.getChaptersContainer(); @@ -740,6 +740,7 @@ class PreviewBar { }); this.setActiveSegments(activeSegments); + return activeSegments; } /**