fixed bug

This commit is contained in:
2024-09-20 11:36:29 +02:00
parent f9be93a28a
commit 6084f22518

View File

@@ -267,6 +267,33 @@ function loadWidget() {
model.y = parentHeight - model.height;
}
function initWidget() {
document.body.insertAdjacentHTML("beforeend", `<div id="waifu-toggle">
<span>猫 咪</span>
</div>`);
let toggle = document.getElementById("waifu-toggle");
toggle.addEventListener("click", () => {
toggle.classList.remove("waifu-toggle-active");
if (toggle.getAttribute("first-time")) {
loadWidget();
toggle.removeAttribute("first-time");
} else {
localStorage.removeItem("waifu-display");
document.getElementById("waifu").style.display = "";
setTimeout(() => {
document.getElementById("waifu").style.bottom = 0;
}, 0);
}
});
if (localStorage.getItem("waifu-display") && Date.now() - localStorage.getItem("waifu-display") <= 86400000) {
toggle.setAttribute("first-time", true);
setTimeout(() => {
toggle.classList.add("waifu-toggle-active");
}, 0);
} else {
loadWidget();
}
}
}
console.log('\n' + ' %c Live2D with Music Player' + ' %c https://github.com/crowya/live2d ' + '\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');