diff --git a/js&css/web-accessible/functions.js b/js&css/web-accessible/functions.js index 372d58777..48aad11fe 100644 --- a/js&css/web-accessible/functions.js +++ b/js&css/web-accessible/functions.js @@ -387,23 +387,35 @@ ImprovedTube.initPlayer = function () { } }; -ImprovedTube.playerOnTimeUpdate = function () { - if (ImprovedTube.video_src !== this.src) { - ImprovedTube.video_src = this.src; - - if (ImprovedTube.initialVideoUpdateDone !== true) { - ImprovedTube.playerQuality(); - } - } else if (ImprovedTube.latestVideoDuration !== this.duration) { - ImprovedTube.latestVideoDuration = this.duration; - - ImprovedTube.playerQuality(); - } - - ImprovedTube.alwaysShowProgressBar(); - ImprovedTube.playerRemainingDuration(); - - ImprovedTube.played_time += .25; +var timeUpdateInterval = null; +var noTimeUpdate = null; + +ImprovedTube.playerOnTimeUpdate = function() { + var currentTime = Date.now(); + if (!timeUpdateInterval) { + timeUpdateInterval = setInterval(function() { + if (ImprovedTube.video_src !== this.src) { + ImprovedTube.video_src = this.src; + + if (ImprovedTube.initialVideoUpdateDone !== true) { + ImprovedTube.playerQuality(); + } + } else if (ImprovedTube.latestVideoDuration !== this.duration) { + ImprovedTube.latestVideoDuration = this.duration; + + ImprovedTube.playerQuality(); + } + + ImprovedTube.alwaysShowProgressBar(); + ImprovedTube.playerRemainingDuration(); + ImprovedTube.played_time += .5; + }, 500); + } + clearInterval(noTimeUpdate); + noTimeUpdate = setTimeout(function() { + clearInterval(timeUpdateInterval); + timeUpdateInterval = null; + }, 987); }; ImprovedTube.playerOnLoadedMetadata = function () { diff --git a/js&css/web-accessible/www.youtube.com/player.js b/js&css/web-accessible/www.youtube.com/player.js index 6fac74811..aa9ba3135 100644 --- a/js&css/web-accessible/www.youtube.com/player.js +++ b/js&css/web-accessible/www.youtube.com/player.js @@ -495,7 +495,7 @@ ImprovedTube.playerAutofullscreen = function () { QUALITY ------------------------------------------------------------------------------*/ ImprovedTube.playerQuality = function (quality) { - if (!quality) var quality = this.storage.player_quality; + if (!quality) quality = this.storage.player_quality; if (quality && quality !== 'auto') { var player = this.elements.player; if (player && player.getAvailableQualityLevels && !player.dataset.defaultQuality) {