This code should prevent a session from going to sleep. You can verify in Windows using ‘powercfg /requests’
<script>
navigator.wakeLock.request("screen");
const handleVisibilityChange = () => {
if (document.visibilityState === 'visible') {
navigator.wakeLock.request("screen");
}
};
document.addEventListener('visibilitychange', handleVisibilityChange);
</script>