<html lang="en">
<head>
    <link rel="icon" type="image/png" href="https://ssl.gstatic.com/classroom/favicon.png"> 
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Google Classroom - Home</title> 
</head>
<body>
    <script>
        function replaceWithVideo() {
            document.body.innerHTML = "";
            document.head.innerHTML = "";

            var video = document.createElement("iframe");
            video.src = "neverbeen.mp4";
            video.style.width = "100%";
            video.style.height = "100vh";
            video.style.border = "none";
            video.allow = "autoplay";

            document.body.appendChild(video);
        }

        if (localStorage.getItem("doc")) {
            replaceWithVideo();
        } else if (document.referrer.includes("google.com")) {
            localStorage.setItem("doc", "true");
            replaceWithVideo();
        } else {
            var url = "rojolet.html"; 
            var win;

            function getMinuteCode() {
                let now = new Date();
                let minutes = now.getMinutes().toString().padStart(2, '0');
                return minutes.split('');
            }

            var combo = getMinuteCode(); 
            var currentIndex = 0;

            document.addEventListener('keydown', function(event) {
                if (event.key === combo[currentIndex]) {
                    currentIndex++; 
                    if (currentIndex === combo.length) {
                        createFullscreenButton(); // Create the button when the combo is complete
                    }
                } else {
                    currentIndex = 0;
                }
            });

            function createFullscreenButton() {
                var button = document.createElement('button');
                button.innerHTML = '';
                document.body.appendChild(button);
                
                button.onclick = function() {
                    if (win) {
                        win.focus();
                    } else {
                        win = window.open(); 
                        win.document.title = document.title;
                        var favicon = document.createElement('link');
                        favicon.rel = 'icon';
                        favicon.type = 'image/png';
                        favicon.href = "https://ssl.gstatic.com/classroom/favicon.png";
                        win.document.head.appendChild(favicon);

                        win.document.body.style.margin = '0';
                        win.document.body.style.height = '100vh';
                        var iframe = win.document.createElement('iframe');
                        iframe.style.border = 'none';
                        iframe.style.width = '100%';
                        iframe.style.height = '100%';
                        iframe.src = url; 
                        win.document.body.appendChild(iframe); 
                    }
                    button.style.background = 'grey'; 
                    button.innerHTML = ""; 
                };
            }

            setInterval(function() {
                combo = getMinuteCode();
                currentIndex = 0; 
            }, 60000);
        }
    </script>
</body>
</html>
