<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.3/howler.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        #pauseButton {
            display: none;
        }

        #facebookShare {
            display: none;
            margin-left: 10px;
        }

        #buttonContainer {
            display: flex;
            align-items: center;
        }

        #facebookShare i {
            color: #3b5998;
            font-size: 24px;
        }

        #message {
            display: none;
            font-size: 18px;
            color: red;
        }
    </style>
    <script>
        const EXPIRATION_TIME = 48 * 60 * 60 * 1000; // 48 hours in milliseconds
        const EXTENDED_TIME = 24 * 60 * 60 * 1000; // Additional 24 hours

        function getDeviceType() {
            const userAgent = navigator.userAgent;
            if (/Mobi|Android/i.test(userAgent)) {
                return "mobile";
            } else {
                return "desktop";
            }
        }

        function getStartTime() {
            return localStorage.getItem("startTime");
        }

        function setStartTime() {
            const now = Date.now();
            localStorage.setItem("startTime", now);
            return now;
        }

        function isExpired() {
            const startTime = getStartTime();
            if (!startTime) return true;
            const elapsedTime = Date.now() - startTime;
            return elapsedTime > EXPIRATION_TIME;
        }

        function extendExpiration() {
            const newTime = parseInt(getStartTime()) + EXTENDED_TIME;
            localStorage.setItem("startTime", newTime);
        }

        function handleFacebookShare() {
            const url = 'https://www.facebook.com/sharer/sharer.php?u=https://www.e-repellent.com';
            window.open(url, '_blank');
            extendExpiration();
            alert("You have extended your usage by 24 hours!");
        }

        function replaceWithMessage(message) {
            document.body.innerHTML = `<p style='color: red; font-size: 24px;'>${message}</p>`;
        }

        function handlePlayButtonClick() {
            if (getDeviceType() === "desktop") {
                replaceWithMessage("This program self-destructs completely when downloaded to a desktop.");
                return;
            }

            if (isExpired()) {
                replaceWithMessage("The application has expired.");
                return;
            }

            document.getElementById("playButton").style.display = "none";
            document.getElementById("pauseButton").style.display = "inline";
        }

        function handleExpirationCheck() {
            if (isExpired()) {
                replaceWithMessage("The application has expired.");
            }
        }

        window.onload = function () {
            if (!getStartTime()) {
                setStartTime();
            }
            handleExpirationCheck();
        };
    </script>
</head>
<body>
    <div id="buttonContainer">
        <button id="playButton" onclick="handlePlayButtonClick()">Super Play</button>
        <button id="pauseButton" onclick="alert('Paused')">Pause</button>
        <span id="facebookShare" onclick="handleFacebookShare()">
            <i class="fab fa-facebook"></i>
        </span>
    </div>
    <p id="message">The application has expired.</p>
</body>
</html>
