<script>
    let ws;

    function connectWebSocket() {
        const ws = new WebSocket((window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host + window.location.pathname);


        ws.onmessage = async (event) => {
            if (event.data === 'update') {
                location.reload();
            }
        };

        ws.onclose = () => {
            setTimeout(connectWebSocket, 5000);
        };
    }

    connectWebSocket();
</script>