mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 22:17:21 +03:00
applied proposed fixes
This commit is contained in:
@@ -117,6 +117,9 @@ const skipNoticeContentContainer: ContentContainer = () => ({
|
|||||||
getRealCurrentTime: getRealCurrentTime
|
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
|
//get messages from the background script and the popup
|
||||||
chrome.runtime.onMessage.addListener(messageListener);
|
chrome.runtime.onMessage.addListener(messageListener);
|
||||||
|
|
||||||
@@ -988,12 +991,14 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped:
|
|||||||
for (const segment of skippingSegments) {
|
for (const segment of skippingSegments) {
|
||||||
const index = sponsorTimes.indexOf(segment);
|
const index = sponsorTimes.indexOf(segment);
|
||||||
if (index !== -1 && !sponsorSkipped[index]) {
|
if (index !== -1 && !sponsorSkipped[index]) {
|
||||||
|
if (Config.config.trackViewCount) {
|
||||||
if (!counted) {
|
if (!counted) {
|
||||||
Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60;
|
Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60;
|
||||||
Config.config.skipCount = Config.config.skipCount + 1;
|
Config.config.skipCount = Config.config.skipCount + 1;
|
||||||
counted = true
|
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;
|
sponsorSkipped[index] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1022,7 +1027,7 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S
|
|||||||
}
|
}
|
||||||
|
|
||||||
//send telemetry that a this sponsor was skipped
|
//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) {
|
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) {
|
function reskipSponsorTime(segment: SponsorTime) {
|
||||||
let skippedTime = segment.segment[1] - video.currentTime;
|
const skippedTime = segment.segment[1] - video.currentTime;
|
||||||
let segmentDuration = segment.segment[1] - segment.segment[0];
|
const segmentDuration = segment.segment[1] - segment.segment[0];
|
||||||
let fullSkip = skippedTime / segmentDuration > manualSkipPercentCount ? true : false
|
const fullSkip = skippedTime / segmentDuration > manualSkipPercentCount ? true : false
|
||||||
video.currentTime = segment.segment[1];
|
video.currentTime = segment.segment[1];
|
||||||
sendTelemetryAndCount([segment], skippedTime, fullSkip)
|
sendTelemetryAndCount([segment], skippedTime, fullSkip)
|
||||||
startSponsorSchedule(true, segment.segment[1], false);
|
startSponsorSchedule(true, segment.segment[1], false);
|
||||||
|
|||||||
Reference in New Issue
Block a user