Prevent setting progress bar on player close if video is watched. (#182)

* Prevent setting progress bar on close if watched.
This commit is contained in:
Nathan DeTar 2022-02-26 03:11:09 -08:00 committed by GitHub
parent 6822ed380d
commit ad5e74cb27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -444,7 +444,7 @@ function getVideoPlayerDuration() {
function getVideoPlayerWatchStatus() {
var videoId = getVideoPlayerVideoId();
var watched = false;
if(document.getElementById(videoId).className != "unseen-icon") {
if(document.getElementById(videoId) != null && document.getElementById(videoId).className != "unseen-icon") {
watched = true;
}
return watched;
@ -608,8 +608,10 @@ function removePlayer() {
function setProgressBar(videoId, currentTime, duration) {
progressBar = document.getElementById("progress-" + videoId);
progressBarWidth = (currentTime / duration) * 100 + "%";
if (progressBar) {
if (progressBar && !getVideoPlayerWatchStatus()) {
progressBar.style.width = progressBarWidth;
} else if (progressBar) {
progressBar.style.width = "0%";
}
}