aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2021-05-19 11:18:25 -0400
committerGitHub <[email protected]>2021-05-19 11:18:25 -0400
commit995ed929ca03e4591cc85517a2f3c7ee55c94a1b (patch)
tree38572d896cdeebbdc67062c655741ec8bb31ab1d
parent592af4e20f08549b2afb63c3e94cadb791d27b93 (diff)
parentfea8f93b5a0fe50255fb22c83e722176f3d6bcb4 (diff)
downloadSponsorBlock-995ed929ca03e4591cc85517a2f3c7ee55c94a1b.tar.gz
SponsorBlock-995ed929ca03e4591cc85517a2f3c7ee55c94a1b.zip
Merge pull request #744 from wilkmaciej/master
Skip count sending and counting on manual skip
-rw-r--r--.gitignore3
-rw-r--r--public/help/index_en.html8
-rw-r--r--src/content.ts53
3 files changed, 35 insertions, 29 deletions
diff --git a/.gitignore b/.gitignore
index a3112c1c..2833884c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,5 @@ node_modules
web-ext-artifacts
.vscode/
dist/
-tmp/ \ No newline at end of file
+tmp/
+.DS_Store \ No newline at end of file
diff --git a/public/help/index_en.html b/public/help/index_en.html
index 7eaabf6a..5e4bcef0 100644
--- a/public/help/index_en.html
+++ b/public/help/index_en.html
@@ -42,12 +42,12 @@
<img src="https://i.imgur.com/caf5Bju.png">
</span>
- Videos will automatically be skipped if they are found in the database. You can open the popup by clicking the extension icon to get a preview of what they are.
+ Video segments will automatically be skipped if they are found in the database. You can open the popup by clicking the extension icon to get a preview of what they are.
<br/>
<br/>
- Whenever you skip a video, you will get a notice report that submission. If the timing seems wrong, report it! You can also vote in the popup. The extension auto upvotes it if you don't report it, so make sure to report when necessary (this can be disabled in the options).
+ Whenever you skip a segment, you will get notice. If the timing seems wrong vote down by clicking downvote! You can also vote in the popup.
</p>
<div class="center"><img height="120px" src="https://user-images.githubusercontent.com/12688112/63067735-5a638700-bede-11e9-8147-f321b57527ec.gif"></div>
@@ -81,8 +81,8 @@
<h1>This is too slow</h1>
<p>
- There are hotkeys if you want to use them. You must be focused on the YouTube player to use them. Press the semicolon key to indicate the start/end of a sponsor segment and click the appostrophe to submit.
- These can be changed in the options. If you don't use QWERTY, you should probably change the keybinds.
+ There are hotkeys if you want to use them. You must be focused on the YouTube player to use them. Press the semicolon key to indicate the start/end of a sponsor segment and click the apostrophe to submit.
+ These can be changed in the options. If you don't use QWERTY, you should probably change the keybinding.
</p>
<h1>I hate these buttons, they are so ugly</h1>
diff --git a/src/content.ts b/src/content.ts
index 22ab7c3e..1092121e 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -120,6 +120,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);
@@ -970,6 +973,26 @@ function previewTime(time: number, unpause = true) {
}
}
+//send telemetry and count skip
+function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: number, fullSkip: boolean) {
+ if (!Config.config.trackViewCount) return;
+
+ let counted = false;
+ for (const segment of skippingSegments) {
+ const index = sponsorTimes.indexOf(segment);
+ if (index !== -1 && !sponsorSkipped[index]) {
+ sponsorSkipped[index] = true;
+ 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);
+ }
+ }
+}
+
//skip from the start time to the end time for a certain index sponsor time
function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: SponsorTime[], openNotice: boolean) {
// There will only be one submission if it is manual skip
@@ -993,29 +1016,7 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S
}
//send telemetry that a this sponsor was skipped
- if (Config.config.trackViewCount && autoSkip) {
- let alreadySkipped = false;
- let isPreviewSegment = false;
-
- for (const segment of skippingSegments) {
- const index = sponsorTimes.indexOf(segment);
- if (index !== -1 && !sponsorSkipped[index]) {
- utils.asyncRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + segment.UUID);
-
- sponsorSkipped[index] = true;
- } else if (sponsorSkipped[index]) {
- alreadySkipped = true;
- }
-
- if (index === -1) isPreviewSegment = true;
- }
-
- // Count this as a skip
- if (!alreadySkipped && !isPreviewSegment) {
- Config.config.minutesSaved = Config.config.minutesSaved + (skipTime[1] - skipTime[0]) / 60;
- Config.config.skipCount = Config.config.skipCount + 1;
- }
- }
+ if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true);
}
function unskipSponsorTime(segment: SponsorTime) {
@@ -1026,8 +1027,12 @@ function unskipSponsorTime(segment: SponsorTime) {
}
function reskipSponsorTime(segment: SponsorTime) {
+ const skippedTime = Math.max(segment.segment[1] - video.currentTime, 0);
+ const segmentDuration = segment.segment[1] - segment.segment[0];
+ const fullSkip = skippedTime / segmentDuration > manualSkipPercentCount;
+
video.currentTime = segment.segment[1];
-
+ sendTelemetryAndCount([segment], skippedTime, fullSkip);
startSponsorSchedule(true, segment.segment[1], false);
}