main
90e35a3 ยท 1 year ago 22 commits
 1function getDeviceType() {
 2  const ua = navigator.userAgent;
 3
 4  if (/mobile/i.test(ua)) {
 5    return "Mobile";
 6  } else if (/tablet/i.test(ua)) {
 7    return "Tablet";
 8  } else {
 9    return "Desktop";
10  }
11}
12
13document.addEventListener("DOMContentLoaded", () => {
14  if (getDeviceType() !== "Desktop") {
15    const disableWarning = document.body.getAttribute("data-disable-warning");
16    if (disableWarning === "true") return;
17    
18    if (location.pathname !== "/") {
19      location.href = "/";
20    }
21    const warning = document.getElementById("warning");
22    if (warning) {
23      warning.checked = true;
24    }
25  }
26});
27
28async function sleep(ms) {
29  return new Promise((resolve) => setTimeout(resolve, ms));
30}