Skip to content

Commit 03cd1b5

Browse files
committed
Count skips for chapters when viewed
1 parent 8cc3843 commit 03cd1b5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/content.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,9 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped:
15771577
sponsorSkipped[index] = true;
15781578
if (!counted) {
15791579
Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60;
1580-
Config.config.skipCount = Config.config.skipCount + 1;
1580+
if (segment.actionType !== ActionType.Chapter) {
1581+
Config.config.skipCount = Config.config.skipCount + 1;
1582+
}
15811583
counted = true;
15821584
}
15831585

@@ -2286,11 +2288,16 @@ function windowListenerHandler(event: MessageEvent): void {
22862288
}
22872289

22882290
function updateActiveSegment(currentTime: number): void {
2289-
previewBar?.updateChapterText(sponsorTimes, sponsorTimesSubmitting, currentTime);
2291+
const activeSegments = previewBar?.updateChapterText(sponsorTimes, sponsorTimesSubmitting, currentTime);
22902292
chrome.runtime.sendMessage({
22912293
message: "time",
22922294
time: currentTime
22932295
});
2296+
2297+
const chapterSegments = activeSegments?.filter((segment) => segment.actionType === ActionType.Chapter);
2298+
if (chapterSegments?.length > 0) {
2299+
sendTelemetryAndCount(chapterSegments, 0, true);
2300+
}
22942301
}
22952302

22962303
function nextChapter(): void {

src/js-components/previewBar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ class PreviewBar {
719719
}
720720
}
721721

722-
updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): void {
722+
updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): SponsorTime[] {
723723
if (!Config.config.showSegmentNameInChapterBar
724724
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
725725
const chaptersContainer = this.getChaptersContainer();
@@ -740,6 +740,7 @@ class PreviewBar {
740740
});
741741

742742
this.setActiveSegments(activeSegments);
743+
return activeSegments;
743744
}
744745

745746
/**

0 commit comments

Comments
 (0)