Skip to content

Commit

Permalink
Adding option to enable playback rate in the time with skips calculat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
vicente-higino committed Sep 5, 2023
1 parent e5472eb commit aac73da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
14 changes: 14 additions & 0 deletions public/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,20 @@
<div class="small-description">__MSG_showTimeWithSkipsDescription__</div>
</div>

<div data-type="toggle" data-sync="usePlaybackRate">
<div class="switch-container">
<label class="switch">
<input id="usePlaybackRate" type="checkbox">
<span class="slider round"></span>
</label>
<label class="switch-label" for="usePlaybackRate">
__MSG_usePlaybackRate__
</label>
</div>

<div class="small-description">__MSG_usePlaybackRateDescription__</div>
</div>

<div data-type="toggle" data-sync="darkMode">
<div class="switch-container">
<label class="switch">
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface SBConfig {
sponsorTimesContributed: number;
submissionCountSinceCategories: number; // New count used to show the "Read The Guidelines!!" message
showTimeWithSkips: boolean;
usePlaybackRate: boolean; // used to calculate showTimeWithSkips using the current playback rate
disableSkipping: boolean;
muteSegments: boolean;
fullVideoSegments: boolean;
Expand Down Expand Up @@ -269,6 +270,7 @@ const syncDefaults = {
sponsorTimesContributed: 0,
submissionCountSinceCategories: 0,
showTimeWithSkips: true,
usePlaybackRate: false,
disableSkipping: false,
muteSegments: true,
fullVideoSegments: true,
Expand Down
5 changes: 3 additions & 2 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2525,8 +2525,9 @@ function showTimeWithoutSkips(skippedDuration: number): void {

display.appendChild(duration);
}

const durationAfterSkips = getFormattedTime((getVideo()?.duration - skippedDuration)/(getVideo()?.playbackRate ?? 1));

const playbackRate = Config.config.usePlaybackRate ? (getVideo()?.playbackRate ?? 1) : 1;
const durationAfterSkips = getFormattedTime((getVideo()?.duration - skippedDuration)/playbackRate);

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

0 comments on commit aac73da

Please sign in to comment.