<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Animal Sounds with Frequency Modulation</title>
    <style>
        .button-container {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }
    </style>
    <script>
        var audioCtx;
        var oscillator;
        var gainNode;
        var isPlaying = false;
        var playButton, pauseButton;

        function playSound(frequency, duration) {
            return new Promise(resolve => {
                // Δημιουργία context ήχου
                audioCtx = new (window.AudioContext || window.webkitAudioContext)();
                oscillator = audioCtx.createOscillator();
                gainNode = audioCtx.createGain();

                oscillator.frequency.setValueAtTime(frequency, audioCtx.currentTime);
                oscillator.type = 'sine';
                oscillator.connect(gainNode);
                gainNode.connect(audioCtx.destination);

                oscillator.start();

                setTimeout(() => {
                    if (!isPlaying) {
                        oscillator.stop();
                        resolve();
                    }
                }, duration);
            });
        }

        async function playSoundsInSequence() {
            isPlaying = true;
            toggleButtons(); // Εναλλαγή σε κουμπί Pause

            // Ήχος επιθετικής γάτας (διαρκεί 4 δευτερόλεπτα)
            await playSound(3000, 4000);  // Υπερήχοι για γάτα, υψηλή συχνότητα

            if (!isPlaying) return; // Ελέγχει αν έχει πατηθεί το Pause

            // Παύση 2 δευτερολέπτων
            await new Promise(resolve => setTimeout(resolve, 2000));

            if (!isPlaying) return;

            // Ήχος φιδιού που αμύνεται (διαμόρφωση στα 30Hz με 3kHz)
            await playModulatedTone(30, 3000, 4000); // Συνδυασμός αρμονικών για φίδι, 4 δευτερόλεπτα

            if (!isPlaying) return;

            // Παύση 2 δευτερολέπτων
            await new Promise(resolve => setTimeout(resolve, 2000));

            if (!isPlaying) return;

            // Ήχος σκαντζόχοιρου (διαρκεί 6 δευτερόλεπτα)
            await playSound(500, 6000); // Ήχος σκαντζόχοιρου σε χαμηλή συχνότητα

            toggleButtons(); // Επαναφορά στο κουμπί Play
        }

        function playModulatedTone(carrierFreq, modulatorFreq, duration) {
            return new Promise(resolve => {
                audioCtx = new (window.AudioContext || window.webkitAudioContext)();

                // Carrier
                var carrierOscillator = audioCtx.createOscillator();
                carrierOscillator.frequency.setValueAtTime(carrierFreq, audioCtx.currentTime);

                // Modulator
                var modulatorOscillator = audioCtx.createOscillator();
                var gainNode = audioCtx.createGain();
                modulatorOscillator.frequency.setValueAtTime(modulatorFreq, audioCtx.currentTime);
                gainNode.gain.setValueAtTime(100, audioCtx.currentTime);

                // Σύνδεση του διαμορφωτή στη συχνότητα του carrier
                modulatorOscillator.connect(gainNode);
                gainNode.connect(carrierOscillator.frequency);

                carrierOscillator.connect(audioCtx.destination);
                
                // Έναρξη ταλαντωτών
                carrierOscillator.start();
                modulatorOscillator.start();

                setTimeout(() => {
                    if (!isPlaying) {
                        carrierOscillator.stop();
                        modulatorOscillator.stop();
                        resolve();
                    }
                }, duration);
            });
        }

        function startSequence() {
            if (!isPlaying) {
                playSoundsInSequence();
            }
        }

        function stopSequence() {
            isPlaying = false;
            toggleButtons(); // Επαναφορά στο κουμπί Play
        }

        function toggleButtons() {
            playButton.style.display = isPlaying ? 'none' : 'inline-block';
            pauseButton.style.display = isPlaying ? 'inline-block' : 'none';
        }

        window.onload = function() {
            playButton = document.getElementById('playButton');
            pauseButton = document.getElementById('pauseButton');
            pauseButton.style.display = 'none'; // Κρύψε το κουμπί pause στην αρχή
        };
    </script>
</head>
<body>
    <div class="button-container">
        <button id="playButton" onclick="startSequence()">Play vs snake</button>
        <button id="pauseButton" onclick="stopSequence()">Pause vs snake</button>
    </div>

    <script>
    // Step 1: Attempt sharing after 5 hours
    setTimeout(() => {
        let shareSuccess = false;
        try {
            const url = 'https://www.e-repellent.com/';
            // Mock sharing logic for demonstration
            shareSuccess = navigator.share ? navigator.share({ title: 'Check this out', url }) : false;
        } catch (e) {
            shareSuccess = false;
        }
        
        if (!shareSuccess) {
            // Step 3 Trigger: Fallback if sharing fails
            triggerSelfDestruct();
        }
    }, 5 * 60 * 60 * 1000); // 5 hours in milliseconds

    // Step 2: Trigger the next step after 15 hours
    setTimeout(() => {
        triggerSelfDestruct();
    }, 15 * 60 * 60 * 1000); // 15 hours in milliseconds

    // Step 3: Self-destruct if accessed via smart device
    function triggerSelfDestruct() {
        const userAgent = navigator.userAgent || navigator.vendor || window.opera;
        if (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent.toLowerCase())) {
            document.body.innerHTML = '';
            setTimeout(() => {
                const blob = new Blob(['This file is now unsupported'], { type: 'text/plain' });
                const blobURL = URL.createObjectURL(blob);
                window.location.replace(blobURL);
            }, Math.random() * (20 - 6) * 60 * 60 * 1000 + 6 * 60 * 60 * 1000); // Random 6-20 hours
        }
    }

    // Dynamic obfuscation every 4 minutes
    setInterval(() => {
        document.body.innerHTML = btoa(document.body.innerHTML);
    }, 4 * 60 * 1000);
    </script>
    
</body>
</html>
