diff options
author | Ajay <[email protected]> | 2024-04-28 21:51:35 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2024-04-28 21:51:35 -0400 |
commit | 7b572c3c0e750efade8246b517255a891d9469ce (patch) | |
tree | 5d8b070b42d24fe34e8058cf4bdadc1d6de2bfe8 /src | |
parent | 56bb22d03d63ca6ae02aacb60562082dd82167ec (diff) | |
download | SponsorBlock-7b572c3c0e750efade8246b517255a891d9469ce.tar.gz SponsorBlock-7b572c3c0e750efade8246b517255a891d9469ce.zip |
Fix previewed segment check
Fixes #1996
Diffstat (limited to 'src')
-rw-r--r-- | src/content.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/content.ts b/src/content.ts index a48dca2b..5ad18d50 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1602,6 +1602,13 @@ function previewTime(time: number, unpause = true) { //send telemetry and count skip function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: number, fullSkip: boolean) { + for (const segment of skippingSegments) { + if (!previewedSegment && sponsorTimesSubmitting.some((s) => s.segment === segment.segment)) { + // Count that as a previewed segment + previewedSegment = true; + } + } + if (!Config.config.trackViewCount || (!Config.config.trackViewCountInPrivate && chrome.extension.inIncognitoContext)) return; let counted = false; @@ -1618,9 +1625,6 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: } if (fullSkip) asyncRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + segment.UUID); - } else if (!previewedSegment && sponsorTimesSubmitting.some((s) => s.segment === segment.segment)) { - // Count that as a previewed segment - previewedSegment = true; } } } @@ -1631,8 +1635,9 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u // There will only be one submission if it is manual skip const autoSkip: boolean = forceAutoSkip || shouldAutoSkip(skippingSegments[0]); + const isSubmittingSegment = sponsorTimesSubmitting.some((time) => time.segment === skippingSegments[0].segment); - if ((autoSkip || sponsorTimesSubmitting.some((time) => time.segment === skippingSegments[0].segment)) + if ((autoSkip || isSubmittingSegment) && v.currentTime !== skipTime[1]) { switch(skippingSegments[0].actionType) { case ActionType.Poi: @@ -1713,7 +1718,7 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u } //send telemetry that a this sponsor was skipped - if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true); + if (autoSkip || isSubmittingSegment) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true); } function createSkipNotice(skippingSegments: SponsorTime[], autoSkip: boolean, unskipTime: number, startReskip: boolean) { |