2021-07-04 06:40:40 +02:00
|
|
|
window.addEventListener("load", rotateTurntable = () => {
|
|
|
|
if (!Spicetify.Player.origin || !document.querySelector("#fad-art-image")) {
|
|
|
|
setTimeout(rotateTurntable, 250);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const fullAppDisplay = document.querySelector("#full-app-display");
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
let playState;
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
function handleRotate(fromEvent) {
|
|
|
|
const fadArt = document.querySelector("#fad-art-image");
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
if (!fromEvent && Spicetify.Player.isPlaying() || fromEvent && !playState) {
|
|
|
|
fadArt.style.animationPlayState = "running";
|
|
|
|
return playState = true;
|
|
|
|
} else {
|
|
|
|
fadArt.style.animationPlayState = "paused";
|
|
|
|
return playState = false;
|
2021-05-23 23:19:59 +02:00
|
|
|
}
|
2021-07-04 06:40:40 +02:00
|
|
|
}
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
handleRotate();
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
Spicetify.Player.addEventListener("onplaypause", () => handleRotate(true));
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
fullAppDisplay.addEventListener("contextmenu", () => {
|
|
|
|
const configSwitchBtns = document.querySelectorAll("#popup-config-container button.switch");
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
for (const configSwitch of configSwitchBtns) {
|
|
|
|
configSwitch.addEventListener("click", () => handleRotate());
|
|
|
|
}
|
|
|
|
});
|
2021-05-23 23:19:59 +02:00
|
|
|
});
|