forked from mirrors/akkoma-fe
Compare commits
2 commits
028b513956
...
911e6f160c
Author | SHA1 | Date | |
---|---|---|---|
|
911e6f160c | ||
|
6c5def32ce |
1 changed files with 8 additions and 10 deletions
|
@ -77,7 +77,9 @@
|
||||||
volumeSet(Math.min(1, Math.max(0, audio.volume + number)));
|
volumeSet(Math.min(1, Math.max(0, audio.volume + number)));
|
||||||
}
|
}
|
||||||
function updateVolumeLabel() {
|
function updateVolumeLabel() {
|
||||||
document.getElementById("user-audio-percentage").innerHTML = Math.round(audio.volume * 100) + "%";
|
let txtElm = document.getElementById("user-audio-percentage");
|
||||||
|
if (txtElm)
|
||||||
|
txtElm.innerHTML = Math.round(audio.volume * 100) + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Registers a mutation observer for an element. Upon triggering and the callback
|
//Registers a mutation observer for an element. Upon triggering and the callback
|
||||||
|
@ -253,16 +255,10 @@
|
||||||
audio.volume = 0.2; //Default volume
|
audio.volume = 0.2; //Default volume
|
||||||
|
|
||||||
//Initialize audio controls and event listeners
|
//Initialize audio controls and event listeners
|
||||||
waitUntil("#music-controls").then((controls) => {
|
waitUntil("#music-up").then((btn) => btn.addEventListener('click', () => volumeAdd(0.05)));
|
||||||
updateVolumeLabel();
|
waitUntil("#music-down").then((btn) => btn.addEventListener('click', () => volumeAdd(-0.05)));
|
||||||
controls.querySelector("#music-up").onclick = () => volumeAdd(0.05);
|
|
||||||
controls.querySelector("#music-down").onclick = () => volumeAdd(-0.05);
|
|
||||||
});
|
|
||||||
|
|
||||||
waitUntil("#music-slider").then((slider) => {
|
waitUntil("#music-slider").then((slider) => slider.addEventListener('input', () => volumeSet(slider.value / 100)));
|
||||||
updateVolumeLabel();
|
|
||||||
slider.oninput = () => volumeSet(slider.value / 100);
|
|
||||||
});
|
|
||||||
|
|
||||||
waitUntil("#music-mute").then((box) => {
|
waitUntil("#music-mute").then((box) => {
|
||||||
audio.muted = box.checked = localStorage.audiomuted === "true";
|
audio.muted = box.checked = localStorage.audiomuted === "true";
|
||||||
|
@ -271,6 +267,8 @@
|
||||||
playMusic();
|
playMusic();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
waitUntil("#user-audio-percentage").then(updateVolumeLabel);
|
||||||
|
|
||||||
//Monkey patches and event listeners
|
//Monkey patches and event listeners
|
||||||
const oldPushState = history.pushState;
|
const oldPushState = history.pushState;
|
||||||
|
|
Loading…
Reference in a new issue