From 8337b54a44ad2acf9f9d7d28d12406ca6b786948 Mon Sep 17 00:00:00 2001
From: Maciej Wilk <73193760+wilkmaciej@users.noreply.github.com>
Date: Fri, 14 May 2021 14:32:32 +0200
Subject: telemetry sending and counting on manual skip
---
src/content.ts | 49 +++++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/src/content.ts b/src/content.ts
index e4e3cb4f..071d284c 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -982,6 +982,23 @@ function previewTime(time: number, unpause = true) {
}
}
+//send telemetry and count skip
+function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: number, fullSkip: boolean) {
+ let counted = false
+ 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 (fullSkip) utils.asyncRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + segment.UUID);
+ sponsorSkipped[index] = true;
+ }
+ }
+}
+
//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
@@ -1005,29 +1022,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 (Config.config.trackViewCount && autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true)
}
function unskipSponsorTime(segment: SponsorTime) {
@@ -1037,9 +1032,15 @@ 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
video.currentTime = segment.segment[1];
-
+ sendTelemetryAndCount([segment], skippedTime, fullSkip)
startSponsorSchedule(true, segment.segment[1], false);
}
--
cgit v1.2.3
From f18aa1917205a691cb0003e51fe4658c37f42ea4 Mon Sep 17 00:00:00 2001
From: Maciej Wilk <73193760+wilkmaciej@users.noreply.github.com>
Date: Fri, 14 May 2021 19:23:58 +0200
Subject: updated help changed few confusing names deleted auto upvote
information fixed minor typos
---
public/help/index_en.html | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/public/help/index_en.html b/public/help/index_en.html
index 7eaabf6a..80c13c04 100644
--- a/public/help/index_en.html
+++ b/public/help/index_en.html
@@ -42,12 +42,12 @@
- 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.
- 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 notification. If the timing seems wrong vote down by clicking down vote! You can also vote in the popup.
@@ -81,8 +81,8 @@
This is too slow
- 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.
I hate these buttons, they are so ugly
--
cgit v1.2.3
From bd44c4721bbb1321ced511bff9740d4667fa5105 Mon Sep 17 00:00:00 2001
From: Maciej Wilk
Date: Sat, 15 May 2021 00:10:30 +0200
Subject: Update public/help/index_en.html
Co-authored-by: Ajay Ramachandran
---
public/help/index_en.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/help/index_en.html b/public/help/index_en.html
index 80c13c04..5e4bcef0 100644
--- a/public/help/index_en.html
+++ b/public/help/index_en.html
@@ -47,7 +47,7 @@
- Whenever you skip a segment, you will get notification. If the timing seems wrong vote down by clicking down vote! You can also vote in the popup.
+ 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.
--
cgit v1.2.3
From 5fad4509f06302931002d40bd3e74a7bb0751150 Mon Sep 17 00:00:00 2001
From: Maciej Wilk <73193760+wilkmaciej@users.noreply.github.com>
Date: Sat, 15 May 2021 00:24:27 +0200
Subject: applied proposed fixes
---
src/content.ts | 26 ++++++++++++++------------
1 file 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);
--
cgit v1.2.3
From 2d14176542e70a5a2badde79d2dd89a0d39a471d Mon Sep 17 00:00:00 2001
From: Maciej Wilk <73193760+wilkmaciej@users.noreply.github.com>
Date: Sat, 15 May 2021 01:02:58 +0200
Subject: added .DS_Store to not commit by mistake
---
.gitignore | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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
--
cgit v1.2.3
From 08a063b6122ad42a6053f78030f442f9f9637ee8 Mon Sep 17 00:00:00 2001
From: Maciej Wilk <73193760+wilkmaciej@users.noreply.github.com>
Date: Sat, 15 May 2021 01:05:45 +0200
Subject: `if(config.trackViewCount) ` changed
---
src/content.ts | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/content.ts b/src/content.ts
index 9e5b32ca..d83c003f 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -991,15 +991,14 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped:
for (const segment of skippingSegments) {
const index = sponsorTimes.indexOf(segment);
if (index !== -1 && !sponsorSkipped[index]) {
- 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);
- }
sponsorSkipped[index] = true;
+ if (!Config.config.trackViewCount) return
+ 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);
}
}
}
--
cgit v1.2.3
From e432abe79d73df6f7cb0abd07d45644b572144ea Mon Sep 17 00:00:00 2001
From: Ajay Ramachandran
Date: Fri, 14 May 2021 21:15:03 -0400
Subject: Formatting changes + prevent negative value
---
src/content.ts | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/content.ts b/src/content.ts
index d83c003f..dcd2749a 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -987,17 +987,19 @@ 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 (!Config.config.trackViewCount) return
if (!counted) {
Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60;
Config.config.skipCount = Config.config.skipCount + 1;
- counted = true
+ counted = true;
}
+
if (fullSkip) utils.asyncRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + segment.UUID);
}
}
@@ -1037,11 +1039,12 @@ function unskipSponsorTime(segment: SponsorTime) {
}
function reskipSponsorTime(segment: SponsorTime) {
- const skippedTime = segment.segment[1] - video.currentTime;
+ const skippedTime = Math.max(segment.segment[1] - video.currentTime, 0);
const segmentDuration = segment.segment[1] - segment.segment[0];
- const fullSkip = skippedTime / segmentDuration > manualSkipPercentCount ? true : false
+ const fullSkip = skippedTime / segmentDuration > manualSkipPercentCount;
+
video.currentTime = segment.segment[1];
- sendTelemetryAndCount([segment], skippedTime, fullSkip)
+ sendTelemetryAndCount([segment], skippedTime, fullSkip);
startSponsorSchedule(true, segment.segment[1], false);
}
--
cgit v1.2.3
From 59f63f1b4b19e76b57ff118ca1c5d964f58c304c Mon Sep 17 00:00:00 2001
From: Ajay Ramachandran
Date: Fri, 14 May 2021 21:15:36 -0400
Subject: Add semi colon
---
src/content.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/content.ts b/src/content.ts
index dcd2749a..7a2b864d 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -1028,7 +1028,7 @@ function skipToTime(v: HTMLVideoElement, skipTime: number[], skippingSegments: S
}
//send telemetry that a this sponsor was skipped
- if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true)
+ if (autoSkip) sendTelemetryAndCount(skippingSegments, skipTime[1] - skipTime[0], true);
}
function unskipSponsorTime(segment: SponsorTime) {
--
cgit v1.2.3
From fea8f93b5a0fe50255fb22c83e722176f3d6bcb4 Mon Sep 17 00:00:00 2001
From: Ajay Ramachandran
Date: Sun, 16 May 2021 18:45:06 -0400
Subject: Semicolon
---
src/content.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/content.ts b/src/content.ts
index 7a2b864d..8f1a7b67 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -989,7 +989,7 @@ function previewTime(time: number, unpause = true) {
function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: number, fullSkip: boolean) {
if (!Config.config.trackViewCount) return;
- let counted = false
+ let counted = false;
for (const segment of skippingSegments) {
const index = sponsorTimes.indexOf(segment);
if (index !== -1 && !sponsorSkipped[index]) {
--
cgit v1.2.3