diff options
author | Maciej Wilk <[email protected]> | 2021-05-15 00:24:27 +0200 |
---|---|---|
committer | Maciej Wilk <[email protected]> | 2021-05-15 00:24:27 +0200 |
commit | 5fad4509f06302931002d40bd3e74a7bb0751150 (patch) | |
tree | 9a5d5e78969d62ee50d8d5489010582908e33a18 | |
parent | bd44c4721bbb1321ced511bff9740d4667fa5105 (diff) | |
download | SponsorBlock-5fad4509f06302931002d40bd3e74a7bb0751150.tar.gz SponsorBlock-5fad4509f06302931002d40bd3e74a7bb0751150.zip |
applied proposed fixes
-rw-r--r-- | src/content.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/content.ts b/src/content.ts index 071d284c..9e5b32ca 100644 --- a/src/content.ts +++ b/src/content.ts @@ -117,6 +117,9 @@ const skipNoticeContentContainer: ContentContainer = () => ({ getRealCurrentTime: getRealCurrentTime }); +// value determining when to count segment as skipped and send telemetry to server (percent based) +const manualSkipPercentCount = 0.5; + //get messages from the background script and the popup chrome.runtime.onMessage.addListener(messageListener); @@ -988,12 +991,14 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: for (const segment of skippingSegments) { const index = sponsorTimes.indexOf(segment); if (index !== -1 && !sponsorSkipped[index]) { - if (!counted) { - Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60; - Config.config.skipCount = Config.config.skipCount + 1; - counted = true + if (Config.config.trackViewCount) { + if (!counted) { + Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60; + Config.config.skipCount = Config.config.skipCount + 1; + counted = true + } + if (fullSkip) utils.asyncRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + segment.UUID); } - if (fullSkip) utils.asyncRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + segment.UUID); sponsorSkipped[index] = true; } } @@ -1022,7 +1027,7 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S } //send telemetry that a this sponsor was skipped - if (Config.config.trackViewCount && autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true) + if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true) } function unskipSponsorTime(segment: SponsorTime) { @@ -1032,13 +1037,10 @@ function unskipSponsorTime(segment: SponsorTime) { } } -// value determining when to count segment as skipped and send telemetry to server (percent based) -let manualSkipPercentCount = 0.5; - function reskipSponsorTime(segment: SponsorTime) { - let skippedTime = segment.segment[1] - video.currentTime; - let segmentDuration = segment.segment[1] - segment.segment[0]; - let fullSkip = skippedTime / segmentDuration > manualSkipPercentCount ? true : false + const skippedTime = segment.segment[1] - video.currentTime; + const segmentDuration = segment.segment[1] - segment.segment[0]; + const fullSkip = skippedTime / segmentDuration > manualSkipPercentCount ? true : false video.currentTime = segment.segment[1]; sendTelemetryAndCount([segment], skippedTime, fullSkip) startSponsorSchedule(true, segment.segment[1], false); |