From 5adcc3efadc985bbfa4d6552f0f6592255a5a887 Mon Sep 17 00:00:00 2001 From: Araxeus Date: Sat, 17 Apr 2021 02:38:45 +0300 Subject: [PATCH] fix set volume on first run after not using plugin --- plugins/precise-volume/front.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/precise-volume/front.js b/plugins/precise-volume/front.js index 395cee31..ce657fb1 100644 --- a/plugins/precise-volume/front.js +++ b/plugins/precise-volume/front.js @@ -13,11 +13,17 @@ function saveVolume(volume, options) { function firstRun(options) { const videoStream = document.querySelector(".video-stream"); - if (videoStream) { - // Set saved volume if it exists and is valid - if (options.savedVolume && options.savedVolume >= 0 && options.savedVolume <= 100) { + const slider = document.querySelector("#volume-slider"); + + if (videoStream && slider) { + // Set saved volume if it pass checks + if (options.savedVolume + && options.savedVolume >= 0 && options.savedVolume <= 100 + && Math.abs(slider.value - options.savedVolume) < 5 + // If plugin was disabled and volume changed then diff>4 + ) { videoStream.volume = options.savedVolume / 100; - document.querySelector("#volume-slider").value = options.savedVolume; + slider.value = options.savedVolume; } // Set current volume as tooltip