Skip to content

Commit aac73da

Browse files
Adding option to enable playback rate in the time with skips calculations
1 parent e5472eb commit aac73da

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

public/options/options.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,20 @@
357357
<div class="small-description">__MSG_showTimeWithSkipsDescription__</div>
358358
</div>
359359

360+
<div data-type="toggle" data-sync="usePlaybackRate">
361+
<div class="switch-container">
362+
<label class="switch">
363+
<input id="usePlaybackRate" type="checkbox">
364+
<span class="slider round"></span>
365+
</label>
366+
<label class="switch-label" for="usePlaybackRate">
367+
__MSG_usePlaybackRate__
368+
</label>
369+
</div>
370+
371+
<div class="small-description">__MSG_usePlaybackRateDescription__</div>
372+
</div>
373+
360374
<div data-type="toggle" data-sync="darkMode">
361375
<div class="switch-container">
362376
<label class="switch">

src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface SBConfig {
2323
sponsorTimesContributed: number;
2424
submissionCountSinceCategories: number; // New count used to show the "Read The Guidelines!!" message
2525
showTimeWithSkips: boolean;
26+
usePlaybackRate: boolean; // used to calculate showTimeWithSkips using the current playback rate
2627
disableSkipping: boolean;
2728
muteSegments: boolean;
2829
fullVideoSegments: boolean;
@@ -269,6 +270,7 @@ const syncDefaults = {
269270
sponsorTimesContributed: 0,
270271
submissionCountSinceCategories: 0,
271272
showTimeWithSkips: true,
273+
usePlaybackRate: false,
272274
disableSkipping: false,
273275
muteSegments: true,
274276
fullVideoSegments: true,

src/content.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,8 +2525,9 @@ function showTimeWithoutSkips(skippedDuration: number): void {
25252525

25262526
display.appendChild(duration);
25272527
}
2528-
2529-
const durationAfterSkips = getFormattedTime((getVideo()?.duration - skippedDuration)/(getVideo()?.playbackRate ?? 1));
2528+
2529+
const playbackRate = Config.config.usePlaybackRate ? (getVideo()?.playbackRate ?? 1) : 1;
2530+
const durationAfterSkips = getFormattedTime((getVideo()?.duration - skippedDuration)/playbackRate);
25302531

25312532
duration.innerText = (durationAfterSkips == null || skippedDuration <= 0) ? "" : " (" + durationAfterSkips + ")";
25322533
}

0 commit comments

Comments
 (0)