mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Show volume slider on volume change
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
const { ipcRenderer } = require("electron");
|
const { ipcRenderer } = require("electron");
|
||||||
const { setOptions } = require("../../config/plugins");
|
const { setOptions } = require("../../config/plugins");
|
||||||
|
|
||||||
function $(selector) { return document.querySelector(selector); }
|
function $(selector) { return document.querySelector(selector); }
|
||||||
|
|
||||||
module.exports = (options) => {
|
module.exports = (options) => {
|
||||||
@ -54,7 +54,7 @@ function setPlaybarOnwheel(options) {
|
|||||||
function changeVolume(increase, options) {
|
function changeVolume(increase, options) {
|
||||||
// Need to change both the actual volume and the slider
|
// Need to change both the actual volume and the slider
|
||||||
const videoStream = $(".video-stream");
|
const videoStream = $(".video-stream");
|
||||||
|
const slider = $("#volume-slider");
|
||||||
// Apply volume change if valid
|
// Apply volume change if valid
|
||||||
const steps = options.steps / 100;
|
const steps = options.steps / 100;
|
||||||
videoStream.volume = increase ?
|
videoStream.volume = increase ?
|
||||||
@ -64,9 +64,11 @@ function changeVolume(increase, options) {
|
|||||||
// Save the new volume
|
// Save the new volume
|
||||||
saveVolume(toPercent(videoStream.volume), options);
|
saveVolume(toPercent(videoStream.volume), options);
|
||||||
// Slider value automatically rounds to multiples of 5
|
// Slider value automatically rounds to multiples of 5
|
||||||
$("#volume-slider").value = options.savedVolume;
|
slider.value = options.savedVolume;
|
||||||
// Finally change tooltip to new value
|
// Change tooltips to new value
|
||||||
setTooltip(options.savedVolume);
|
setTooltip(options.savedVolume);
|
||||||
|
// Show volume slider on volume change
|
||||||
|
slider.classList.add("on-hover")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save volume + Update the volume tooltip when volume-slider is manually changed
|
// Save volume + Update the volume tooltip when volume-slider is manually changed
|
||||||
|
|||||||
Reference in New Issue
Block a user