Skip to content

Commit

Permalink
Update player.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube authored Oct 11, 2024
1 parent 658135d commit d4fff38
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,20 @@ ImprovedTube.playbackSpeed = function (newSpeed) {
return newSpeed;
};
/*------------------------------------------------------------------------------
FORCED PLAYBACK SPEED
PERMANENT PLAYBACK SPEED
------------------------------------------------------------------------------*/
ImprovedTube.playerPlaybackSpeed = function () { if (this.storage.player_forced_playback_speed === true) {
var player = this.elements.player,
video = player.querySelector('video'),
option = this.storage.player_playback_speed;
var player = this.elements.player; if (!player) return;
var video = this.elements.video || player.querySelector('video');
option = this.storage.player_playback_speed;
if (this.isset(option) === false) { option = 1; }
else if ( option !== 1 && video.playbackRate !== option && (video.playbackRate > 1 || video.playbackRate < 1) )
else if ( option !== 1 ) {
const speed = video?.playbackRate ? Number(video.playbackRate.toFixed(2)) : (player?.getPlaybackRate ? Number(player.getPlaybackRate().toFixed(2)) : null);
if ( speed !== option && (speed > 1 || speed < 1) )
{ console.log("skipping permanent speed, since speed was manually set differently for this video to:" + video.playbackRate); return; }
if ( !player.getVideoData().isLive || player.getVideoData().isLive === false)
{ player.setPlaybackRate(Number(option)); video.playbackRate = Number(option); // #1729 q2 // hi! @raszpl
}
if (!(player.getVideoData() && player.getVideoData().isLive))
{ player.setPlaybackRate(Number(option)); if (!video) { video = { playbackRate: 1 }; }; video.playbackRate = Number(option); // #1729 q2 // hi! @raszpl
if ( (this.storage.player_force_speed_on_music !== true || this.storage.player_dont_speed_education === true)
&& option !== 1) {
ImprovedTube.speedException = function () {
Expand Down

0 comments on commit d4fff38

Please sign in to comment.