mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
lint
This commit is contained in:
@ -31,13 +31,13 @@ function injectVolumeHud(noVid) {
|
|||||||
if (noVid) {
|
if (noVid) {
|
||||||
const position = "top: 18px; right: 60px; z-index: 999; position: absolute;";
|
const position = "top: 18px; right: 60px; z-index: 999; position: absolute;";
|
||||||
const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1s";
|
const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1s";
|
||||||
|
|
||||||
$(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend",
|
$(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend",
|
||||||
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
|
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
|
||||||
} else {
|
} else {
|
||||||
const position = `top: 10px; left: 10px; z-index: 999; position: absolute;`;
|
const position = `top: 10px; left: 10px; z-index: 999; position: absolute;`;
|
||||||
const mainStyle = "font-size: xxx-large; padding: 10px; transition: opacity 0.6s; webkit-text-stroke: 1px black; font-weight: 600;";
|
const mainStyle = "font-size: xxx-large; padding: 10px; transition: opacity 0.6s; webkit-text-stroke: 1px black; font-weight: 600;";
|
||||||
|
|
||||||
$("#song-video").insertAdjacentHTML('afterend',
|
$("#song-video").insertAdjacentHTML('afterend',
|
||||||
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
|
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
|
||||||
}
|
}
|
||||||
@ -46,20 +46,20 @@ function injectVolumeHud(noVid) {
|
|||||||
let hudFadeTimeout;
|
let hudFadeTimeout;
|
||||||
|
|
||||||
function showVolumeHud(volume) {
|
function showVolumeHud(volume) {
|
||||||
let volumeHud = $("#volumeHud");
|
let volumeHud = $("#volumeHud");
|
||||||
if (!volumeHud) return;
|
if (!volumeHud) return;
|
||||||
|
|
||||||
volumeHud.textContent = volume + '%';
|
volumeHud.textContent = volume + '%';
|
||||||
volumeHud.style.opacity = 1;
|
volumeHud.style.opacity = 1;
|
||||||
|
|
||||||
if (hudFadeTimeout) {
|
if (hudFadeTimeout) {
|
||||||
clearTimeout(hudFadeTimeout);
|
clearTimeout(hudFadeTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
hudFadeTimeout = setTimeout(() => {
|
hudFadeTimeout = setTimeout(() => {
|
||||||
volumeHud.style.opacity = 0;
|
volumeHud.style.opacity = 0;
|
||||||
hudFadeTimeout = null;
|
hudFadeTimeout = null;
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add onwheel event to video player */
|
/** Add onwheel event to video player */
|
||||||
@ -83,12 +83,12 @@ function saveVolume(volume, options) {
|
|||||||
//without this function it would rewrite config 20 time when volume change by 20
|
//without this function it would rewrite config 20 time when volume change by 20
|
||||||
let writeTimeout;
|
let writeTimeout;
|
||||||
function writeOptions(options) {
|
function writeOptions(options) {
|
||||||
if (writeTimeout) clearTimeout(writeTimeout);
|
if (writeTimeout) clearTimeout(writeTimeout);
|
||||||
|
|
||||||
writeTimeout = setTimeout(() => {
|
writeTimeout = setTimeout(() => {
|
||||||
setOptions("precise-volume", options);
|
setOptions("precise-volume", options);
|
||||||
writeTimeout = null;
|
writeTimeout = null;
|
||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restore saved volume and setup tooltip */
|
/** Restore saved volume and setup tooltip */
|
||||||
@ -133,9 +133,9 @@ function changeVolume(toIncrease, options) {
|
|||||||
const videoStream = $(".video-stream");
|
const videoStream = $(".video-stream");
|
||||||
// Apply volume change if valid
|
// Apply volume change if valid
|
||||||
const steps = (options.steps || 1) / 100;
|
const steps = (options.steps || 1) / 100;
|
||||||
videoStream.volume = toIncrease ?
|
videoStream.volume = (toIncrease ?
|
||||||
Math.min(videoStream.volume + steps, 1) :
|
Math.min(videoStream.volume + steps, 1) :
|
||||||
Math.max(videoStream.volume - steps, 0).toFixed(2);
|
Math.max(videoStream.volume - steps, 0)).toFixed(2);
|
||||||
|
|
||||||
// Save the new volume
|
// Save the new volume
|
||||||
saveVolume(toPercent(videoStream.volume), options);
|
saveVolume(toPercent(videoStream.volume), options);
|
||||||
@ -152,7 +152,7 @@ function changeVolume(toIncrease, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupVolumeOverride(options) {
|
function setupVolumeOverride(options) {
|
||||||
const video = $('video');
|
const video = $('video');
|
||||||
|
|
||||||
video.addEventListener("canplay", () => {
|
video.addEventListener("canplay", () => {
|
||||||
if (typeof options.savedVolume === "number") {
|
if (typeof options.savedVolume === "number") {
|
||||||
|
|||||||
Reference in New Issue
Block a user