let lock;
btn.addEventListener("click", async () => {
try {
if (lock) {
lock.release();
return;
}
lock = await navigator.wakeLock.request("screen");
lock.addEventListener("release", () => {
lock = null;
});
} catch (err) {
console.log(`${err.name}, ${err.message}`);
}
});