Skip to content

Commit

Permalink
fixed greasymonkey setVideoVolume error on youtube
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyhalight committed Dec 7, 2023
1 parent 36adda7 commit b9752d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,10 @@ class VideoHandler {
// Set video volume in 0.00-1.00 format
setVideoVolume(volume) {
if (this.site.host === "youtube") {
return youtubeUtils.setVideoVolume(volume);
const videoVolume = youtubeUtils.setVideoVolume(volume);
if (videoVolume) {
return;
}
}
this.video.volume = volume;
}
Expand Down
6 changes: 5 additions & 1 deletion src/utils/youtubeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ function getVideoVolume() {
}

function setVideoVolume(volume) {
return getPlayer()?.setVolume(Math.round(volume * 100));
const player = getPlayer();
if (player?.setVolume) {
player.setVolume(Math.round(volume * 100));
return true;
}
}

function videoSeek(video, time) {
Expand Down

0 comments on commit b9752d1

Please sign in to comment.