2021-07-04 06:40:40 +02:00
|
|
|
window.addEventListener("load", rotateTurntable = () => {
|
2021-07-04 16:45:09 +02:00
|
|
|
const fadBtn = document.querySelector(".main-topBar-button[title='Full App Display']");
|
|
|
|
|
|
|
|
if (!Spicetify.Player.origin || !fadBtn) {
|
2021-07-04 06:40:40 +02:00
|
|
|
setTimeout(rotateTurntable, 250);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-06 17:36:30 +02:00
|
|
|
const adModalStyle = document.createElement("style");
|
2021-07-07 18:40:08 +02:00
|
|
|
const STYLE_FOR_AD_MODAL =
|
|
|
|
`
|
2021-07-06 17:36:30 +02:00
|
|
|
.ReactModalPortal {
|
|
|
|
display: none
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
adModalStyle.innerHTML = STYLE_FOR_AD_MODAL;
|
|
|
|
|
2021-07-07 18:40:08 +02:00
|
|
|
let playState, clickedFadBtn;
|
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) {
|
2021-07-06 16:42:25 +02:00
|
|
|
if (fadArt) fadArt.style.animationPlayState = "running";
|
|
|
|
playState = true;
|
2021-07-04 06:40:40 +02:00
|
|
|
} else {
|
2021-07-06 16:42:25 +02:00
|
|
|
if (fadArt) fadArt.style.animationPlayState = "paused";
|
|
|
|
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 16:45:09 +02:00
|
|
|
function handleFadControl(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
|
2021-07-04 07:06:54 +02:00
|
|
|
function handleFadDblclick() {
|
|
|
|
const fadControlsBtns = document.querySelectorAll("#fad-controls button");
|
|
|
|
|
|
|
|
for (const fadControl of fadControlsBtns) {
|
2021-07-04 16:45:09 +02:00
|
|
|
fadControl.addEventListener("dblclick", handleFadControl);
|
2021-07-04 07:06:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-04 16:45:09 +02:00
|
|
|
function handleConfigSwitch() {
|
|
|
|
const genericModal = document.querySelector("generic-modal");
|
|
|
|
|
2021-07-07 18:40:08 +02:00
|
|
|
document.querySelectorAll("#popup-config-container > div")[0].remove();
|
|
|
|
|
2021-07-04 16:45:09 +02:00
|
|
|
handleInitalStatus(genericModal);
|
|
|
|
}
|
|
|
|
|
2021-07-04 07:06:54 +02:00
|
|
|
function handleInitalStatus(genericModal) {
|
2021-07-04 16:45:09 +02:00
|
|
|
genericModal.remove();
|
2021-07-04 07:06:54 +02:00
|
|
|
|
|
|
|
handleRotate();
|
|
|
|
handleFadDblclick();
|
|
|
|
}
|
|
|
|
|
2021-07-07 18:40:08 +02:00
|
|
|
function handleBackdrop() {
|
|
|
|
const fadClassList = document.querySelector("#full-app-display").classList;
|
|
|
|
|
|
|
|
if (!+localStorage.getItem("enableBlurFad")) {
|
|
|
|
fadClassList.add("blur-fad");
|
|
|
|
|
|
|
|
localStorage.setItem("enableBlurFad", "1");
|
|
|
|
} else {
|
|
|
|
fadClassList.remove("blur-fad");
|
|
|
|
|
|
|
|
localStorage.setItem("enableBlurFad", "0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-04 16:45:09 +02:00
|
|
|
function handleContextMenu() {
|
2021-07-07 18:40:08 +02:00
|
|
|
const configPopupCloseBtn = document.querySelector(".main-trackCreditsModal-closeBtn");
|
|
|
|
const configContainer = document.querySelector("#popup-config-container");
|
|
|
|
const settingRowReferenceNode = document.querySelectorAll("#popup-config-container > div")[0];
|
|
|
|
|
|
|
|
const settingRowContainer = document.createElement("div");
|
|
|
|
const settingRow =
|
|
|
|
`
|
|
|
|
<div class="setting-row">
|
|
|
|
<label class="col description">Enable blur backdrop</label>
|
|
|
|
<div class="col action">
|
|
|
|
<button class="${+localStorage.getItem("enableBlurFad") ? "switch" : "switch disabled"}">
|
|
|
|
<svg height="16" width="16" viewBox="0 0 16 16" fill="currentColor">
|
|
|
|
<path d="M13.985 2.383L5.127 12.754 1.388 8.375l-.658.77 4.397 5.149 9.618-11.262z"></path>
|
|
|
|
</svg>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
|
|
|
|
settingRowContainer.innerHTML = settingRow;
|
|
|
|
configContainer.insertBefore(settingRowContainer, settingRowReferenceNode);
|
|
|
|
|
|
|
|
const setBlurBackdropNode = document.querySelectorAll("#popup-config-container > div")[0];
|
2021-07-04 06:40:40 +02:00
|
|
|
const configSwitchBtns = document.querySelectorAll("#popup-config-container button.switch");
|
2021-05-23 23:19:59 +02:00
|
|
|
|
2021-07-07 18:40:08 +02:00
|
|
|
configPopupCloseBtn.addEventListener("click", () => setBlurBackdropNode.remove());
|
|
|
|
|
2021-07-04 06:40:40 +02:00
|
|
|
for (const configSwitch of configSwitchBtns) {
|
2021-07-04 16:45:09 +02:00
|
|
|
configSwitch.addEventListener("click", handleConfigSwitch);
|
2021-07-04 06:40:40 +02:00
|
|
|
}
|
2021-07-07 18:40:08 +02:00
|
|
|
|
|
|
|
setBlurBackdropNode.querySelector("button").addEventListener("click", handleBackdrop);
|
2021-07-04 16:45:09 +02:00
|
|
|
}
|
|
|
|
|
2021-07-06 16:42:25 +02:00
|
|
|
function handleMainInterface() {
|
|
|
|
const mainInterface = document.querySelector("#main");
|
|
|
|
const mainPlayBtn = document.querySelector(".main-playButton-PlayButton");
|
|
|
|
const mainTopbarTitle = document.querySelector(".main-entityHeader-topbarTitle");
|
2021-07-06 17:36:30 +02:00
|
|
|
const billboard = document.querySelector("#view-billboard-ad");
|
2021-07-06 16:42:25 +02:00
|
|
|
|
|
|
|
mainInterface.style.display = "block";
|
2021-07-06 17:36:30 +02:00
|
|
|
if (billboard) billboard.closest(".ReactModalPortal").remove();
|
|
|
|
adModalStyle.remove();
|
2021-07-06 16:42:25 +02:00
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
mainPlayBtn.style.removeProperty("opacity");
|
|
|
|
if (mainTopbarTitle) mainTopbarTitle.style.removeProperty("opacity");
|
|
|
|
}, 250);
|
|
|
|
}
|
|
|
|
|
2021-07-04 16:45:09 +02:00
|
|
|
handleRotate();
|
|
|
|
|
|
|
|
Spicetify.Player.addEventListener("onplaypause", () => handleRotate(true));
|
|
|
|
|
|
|
|
fadBtn.addEventListener("click", () => {
|
2021-07-06 16:42:25 +02:00
|
|
|
const mainInterface = document.querySelector("#main");
|
|
|
|
const mainPlayBtn = document.querySelector(".main-playButton-PlayButton");
|
|
|
|
const mainTopbarTitle = document.querySelector(".main-entityHeader-topbarTitle");
|
|
|
|
const topbarContentFadeIn = document.querySelector(".main-entityHeader-topbarContentFadeIn");
|
2021-07-04 16:45:09 +02:00
|
|
|
const fullAppDisplay = document.querySelector("#full-app-display");
|
|
|
|
const fadArt = document.querySelector("#fad-art-image");
|
2021-07-07 18:40:08 +02:00
|
|
|
const fadClassList = document.querySelector("#full-app-display").classList;
|
|
|
|
|
|
|
|
if (!clickedFadBtn && +localStorage.getItem("enableBlurFad")) fadClassList.add("blur-fad");
|
|
|
|
if (!clickedFadBtn) clickedFadBtn = true;
|
2021-07-04 16:45:09 +02:00
|
|
|
|
|
|
|
playState
|
|
|
|
? fadArt.style.animationPlayState = "running"
|
|
|
|
: fadArt.style.animationPlayState = "paused";
|
|
|
|
|
|
|
|
handleFadDblclick();
|
|
|
|
|
2021-07-06 16:42:25 +02:00
|
|
|
if (!topbarContentFadeIn) {
|
|
|
|
mainPlayBtn.style.setProperty("opacity", "0", "important");
|
|
|
|
if (mainTopbarTitle) mainTopbarTitle.style.setProperty("opacity", "0", "important");
|
|
|
|
}
|
|
|
|
|
|
|
|
mainInterface.style.display = "none";
|
2021-07-06 17:36:30 +02:00
|
|
|
document.body.append(adModalStyle);
|
2021-07-06 16:42:25 +02:00
|
|
|
|
2021-07-04 16:45:09 +02:00
|
|
|
fullAppDisplay.addEventListener("contextmenu", handleContextMenu);
|
2021-07-06 16:42:25 +02:00
|
|
|
|
|
|
|
fullAppDisplay.addEventListener("dblclick", handleMainInterface);
|
2021-07-04 06:40:40 +02:00
|
|
|
});
|
2021-05-23 23:19:59 +02:00
|
|
|
});
|