mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Improved view count
This commit is contained in:
44
content.js
44
content.js
@@ -631,25 +631,6 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||
let currentUUID = UUIDs[index];
|
||||
lastSponsorTimeSkippedUUID = currentUUID;
|
||||
|
||||
//send telemetry that a this sponsor was skipped
|
||||
if (trackViewCount && !sponsorSkipped[index]) {
|
||||
sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
|
||||
|
||||
if (!disableAutoSkip) {
|
||||
// Count this as a skip
|
||||
chrome.storage.sync.get(["minutesSaved"], function(result) {
|
||||
if (result.minutesSaved === undefined) result.minutesSaved = 0;
|
||||
|
||||
chrome.storage.sync.set({"minutesSaved": result.minutesSaved + (sponsorTimes[index][1] - sponsorTimes[index][0]) / 60 });
|
||||
});
|
||||
chrome.storage.sync.get(["skipCount"], function(result) {
|
||||
if (result.skipCount === undefined) result.skipCount = 0;
|
||||
|
||||
chrome.storage.sync.set({"skipCount": result.skipCount + 1 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (openNotice) {
|
||||
//send out the message saying that a sponsor message was skipped
|
||||
if (!dontShowNotice) {
|
||||
@@ -670,6 +651,27 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//send telemetry that a this sponsor was skipped
|
||||
if (trackViewCount && !sponsorSkipped[index]) {
|
||||
sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
|
||||
|
||||
if (!disableAutoSkip) {
|
||||
// Count this as a skip
|
||||
chrome.storage.sync.get(["minutesSaved"], function(result) {
|
||||
if (result.minutesSaved === undefined) result.minutesSaved = 0;
|
||||
|
||||
chrome.storage.sync.set({"minutesSaved": result.minutesSaved + (sponsorTimes[index][1] - sponsorTimes[index][0]) / 60 });
|
||||
});
|
||||
chrome.storage.sync.get(["skipCount"], function(result) {
|
||||
if (result.skipCount === undefined) result.skipCount = 0;
|
||||
|
||||
chrome.storage.sync.set({"skipCount": result.skipCount + 1 });
|
||||
});
|
||||
|
||||
sponsorSkipped[index] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unskipSponsorTime(UUID) {
|
||||
@@ -944,6 +946,8 @@ function vote(type, UUID, skipNotice) {
|
||||
let factor = 1;
|
||||
if (type == 0) {
|
||||
factor = -1;
|
||||
|
||||
sponsorSkipped[sponsorIndex] = false;
|
||||
}
|
||||
|
||||
// Count this as a skip
|
||||
@@ -957,8 +961,6 @@ function vote(type, UUID, skipNotice) {
|
||||
|
||||
chrome.storage.sync.set({"skipCount": result.skipCount + factor * 1 });
|
||||
});
|
||||
|
||||
sponsorSkipped[sponsorIndex] = !sponsorSkipped[sponsorIndex];
|
||||
}
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
|
||||
Reference in New Issue
Block a user