const redirect = 'https://go.enderman.ch/youtube';
let video = document.querySelector('#player');

async function sleep(ms) {
    await new Promise(resolve => setTimeout(resolve, ms));
}

document.querySelector('.fullscreen').onclick = () => {
    document.title = 'Downloading...';

    video.style.cursor = 'default';
    video.play();
}

video.addEventListener('ended', async () => {
    document.title = 'Download complete!';

    await sleep(3000);
    window.location.replace(redirect);
});