<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Darvk</title>
    <link
      rel="shortcut icon"
      type="image/png"
      href="https://clipart-library.com/images/rTjrbKygc.png"
    />
    <link
      rel="stylesheet"
      href="https://fonts.googleapis.com/css2?family=Varela+Round&display=swap"
    />
    <style>
      body {
        font-family: "Varela Round", sans-serif;
        margin: 0;
        padding: 0;
        color: #ffffff;
        line-height: 1.6;
        position: relative;
        overflow: hidden;
        background: url("https://giffiles.alphacoders.com/483/48368.gif")
          no-repeat center center fixed;
        background-size: cover;
      }

      header {
        background-color: rgba(10, 17, 36, 0);
        color: #000000;
        padding: 10px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      header h1 {
        font-size: 24px;
      }

      header img.logo {
        width: 120px; /* Ensure the logo is a reasonable size */
        height: auto; /* Maintain aspect ratio */
        margin-right: 10px; /* Space between logo and title */
      }

      .container,
      button {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
      }

      .container:hover,
      button:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
      }

      #killButton {
        display: none;
        background-color: #e4243751;
        color: #ffffff;
        border: none;
        padding: 10px 20px;
        font-size: 16px;
        cursor: pointer;
        border-radius: 5px;
        transition: background-color 0.3s ease;
      }

      .logo {
        width: 120px;
        height: fit-content;
        border-radius: 59%;
        margin-right: 10px;
      }

      #killExtensionText {
        display: none;
        margin-top: 20px;
        color: #ffffff;
        font-size: 18px;
        text-align: center;
        background: rgba(10, 17, 36, 0);
        padding: 20px;
        border-radius: 59px;
      }

      .welcome-message {
        background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent background */
        color: #ffffff; /* White text color */
        padding: 15px 20px; /* Padding for spacing */
        border-radius: 8px; /* Rounded corners */
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); /* Subtle shadow */
        position: fixed; /* Fixed position */
        top: 20px; /* Distance from the top */
        left: 50%; /* Center horizontally */
        transform: translateX(-50%); /* Center alignment */
        z-index: 1000; /* Ensure it appears above other content */
        font-size: 18px; /* Font size */
        transition: opacity 0.5s ease; /* Smooth transition for appearance */
        opacity: 0; /* Start as invisible */
      }

      .welcome-message.show {
        opacity: 1; /* Fully visible when shown */
      }

      .container {
        max-width: 800px;
        margin: 50px auto;
        padding: 20px;
        text-align: center;
        background: rgba(10, 17, 36, 0);
        border-radius: 59px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
      }

      button {
        background-color: #351b6054;
        color: #ffffff;
        border: none;
        cursor: pointer;
        padding: 10px 20px;
        border-radius: 5px;
        font-size: 16px;
        margin: 10px auto;
        transition: background-color 0.3s ease, transform 0.3s ease,
          box-shadow 0.3s ease;
      }

      button:hover {
        background-color: #0a1124;
        transform: translateY(-5px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
      }

      input[type="text"],
      input[type="password"],
      select {
        font-family: "Varela Round", sans-serif;
        margin: 10px auto;
        padding: 12px;
        font-size: 15px;
        border-radius: 5px;
        border: 1px solid rgba(10, 17, 36, 0);
        width: 100%;
        transition: border-color 0.3s ease;
      }

      input:focus,
      select:focus {
        border-color: #4b6b77;
        outline: none;
      }

      .modal {
        display: flex; /* Ensure it uses flexbox for centering */
        position: fixed; /* Fixed position to cover the entire viewport */
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(
          10,
          17,
          36,
          0.8
        ); /* Semi-transparent background */
        justify-content: center; /* Center the content */
        align-items: center; /* Center the content */
        z-index: 9999; /* Ensure it is on top of other content */
        visibility: hidden; /* Initially hidden */
        opacity: 0; /* Initially transparent */
        transition: visibility 0s, opacity 0.5s linear; /* Smooth transition */
      }

      .modal-content {
        padding: 30px;
        border-radius: 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        color: white;
        text-align: center;
      }

      #killButton:hover {
        background-color: #0a1124;
      }

      header img.logo {
        width: 50px; /* Ensure the logo is a reasonable size */
        height: auto; /* Maintain aspect ratio */
        margin-right: 10px; /* Space between logo and title */
      }

      .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.8);
        display: none;
        justify-content: center;
        align-items: center;
        z-index: 9999;
        color: #ffffff;
        font-size: 24px;
        flex-direction: column;
        text-align: center;
      }

      html,
      body {
        height: 100%; /* Ensure the html and body take up the full height */
        margin: 0; /* Remove default margin */
        padding: 0; /* Remove default padding */
      }
      textarea {
        width: 100%;
        height: 100px;
        margin-top: 10px;
        background-color: rgba(255, 255, 255, 0.1);
        color: white;
        border: 1px solid #61dafb;
        border-radius: 5px;
      }

      .spinner {
        border: 6px solid rgba(0, 0, 0, 0.3);
        border-top: 6px solid #4b6b77;
        border-radius: 59%;
        width: 40px;
        height: 40px;
        animation: spin 1s linear infinite;
        margin-bottom: 20px;
      }

      @keyframes spin {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }

      footer {
        background-color: rgba(10, 17, 36, 0);
        color: #ffffff;
        text-align: center;
        padding: 15px;
        position: fixed;
        bottom: 0;
        width: 100%;
      }

      footer a {
        color: #cbcbcb;
        text-decoration: none;
      }

      footer a:hover {
        text-decoration: underline;
      }

      .modal.show {
        visibility: visible; /* Show the modal */
        opacity: 1; /* Fully opaque */
      }

      #customUrlSection {
        display: none; /* Hide the custom URL section initially */
      }

      .background-media {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        object-fit: cover;
      }
    </style>
  </head>
  <body>
    <header>
      <img
        src="https://clipart-library.com/images/rTjrbKygc.png"
        alt="Logo"
        class="logo"
      />
      <h1>DarvkV4</h1>
    </header>

    <div
      id="welcomeMessage"
      style="display: none; color: white; text-align: center; font-size: 20px"
    ></div>

    <div class="modal" id="loginModal">
      <div class="modal-content">
        <h2>Login to Darvk</h2>
        <input type="text" id="usernameInput" placeholder="Username" />
        <input type="password" id="passwordInput" placeholder="Password" />
        <button onclick="checkLogin()">Login</button>
      </div>
    </div>

    <div class="container" id="mainContent" style="display: none">
      <p>
        DarvkV4 is an external tool made by Anonymous, it works as of December
        2024.
      </p>
      <label for="iframeSelect" id="labelForIframeSelect"
        >Select extension:</label
      >
      <select id="iframeSelect"></select>
      <button
        onclick="warning();"
        id="hangButton"
        title="Freezes the selected extension"
      >
        Freeze Extension
      </button>
      <button
        onclick="openCrashPopup();"
        id="crashButton"
        title="Opens the code executor"
      >
        Code Executor
      </button>
      <button
        id="killButton"
        onclick="openExtensionPopup();"
        title="Terminate the selected extension"
      >
        Kill Extension!
      </button>
      <button
        id="tutcrash"
        title="This OP feature only works on 90's as of now."
      >
        Crash Google Classroom
      </button>
      <button
        id="openGoogleButton"
        title="Opens only 1 selected website out of the 3(You can choose it.)"
      >
        Bypassed websites
      </button>
      <button
        id="openallgg"
        title="It opens all of the selected websites by doing it repeatedly you can bypass goguardian from blocking the website."
      >
        Open all websites
      </button>
      <button
        id="openWebsiteButton"
        title="Run JavaScript on the chosen websites (New update allows you to run it on custom websites proxy coming soon!)"
      >
        Run JavaScript on selected sites
      </button>

      <!-- Button to show the custom URL input section -->
      <button id="showCustomUrlButton" title="Open custom URL input section">
        Open Custom URL Input
      </button>

      <div id="customUrlSection">
        <input
          type="text"
          id="customUrlInput"
          placeholder="Enter custom website URL"
        />
        <button id="openCustomUrlButton" title="Open the entered custom URL">
          Open Custom URL
        </button>
        <button
          id="closeCustomUrlButton"
          title="Close the custom URL input section"
        >
          Close
        </button>
      </div>
    </div>
    <div>
      <script>
        // Show the custom URL input section when the button is clicked
        document
          .getElementById("showCustomUrlButton")
          .addEventListener("click", function () {
            document.getElementById("customUrlSection").style.display = "block";
            this.style.display = "none"; // Hide the button after it's clicked
          });

        // Functionality to open custom URL
        document
          .getElementById("openCustomUrlButton")
          .addEventListener("click", function () {
            var customUrl = document.getElementById("customUrlInput").value;

            // Validate the URL
            if (!customUrl) {
              alert("Please enter a valid URL.");
              return;
            }

            // Open the custom URL in a new popup window
            var popup = window.open(
              "about:blank",
              "_blank",
              "width=800,height=600"
            );
            popup.document.write(`
            <html>
                <head>
                    <title>Loaded Website</title>
                    <style>
                        body {
                            margin: 0;
                            padding: 0;
                            background: url('https://giffiles.alphacoders.com/483/48368.gif') no-repeat center center fixed;
                            background-size: cover;
                        }
                        #websiteFrame {
                            width: 100vw;
                            height: 100vh;
                            border: none;
                        }
                    </style>
                </head>
                <body>
                    <iframe id="websiteFrame" src="${customUrl}"></iframe>
                </body>
            </html>
        `);
            popup.document.close();

            // Add event listener to detect F11 key for fullscreen
            popup.document.addEventListener("keydown", function (event) {
              if (event.key === "F11") {
                event.preventDefault(); // Prevent the default F11 behavior
                var iframe = popup.document.getElementById("websiteFrame");
                if (iframe.requestFullscreen) {
                  iframe.requestFullscreen();
                } else if (iframe.mozRequestFullScreen) {
                  // Firefox
                  iframe.mozRequestFullScreen();
                } else if (iframe.webkitRequestFullscreen) {
                  // Chrome, Safari and Opera
                  iframe.webkitRequestFullscreen();
                } else if (iframe.msRequestFullscreen) {
                  // IE/Edge
                  iframe.msRequestFullscreen();
                }
              }
            });

            // Hide the custom URL section and reset the input field
            document.getElementById("customUrlSection").style.display = "none";
            document.getElementById("customUrlInput").value = ""; // Clear the input field
          });

        // Functionality to close the custom URL input section
        document
          .getElementById("closeCustomUrlButton")
          .addEventListener("click", function () {
            document.getElementById("customUrlSection").style.display = "none";
            document.getElementById("showCustomUrlButton").style.display =
              "block"; // Show the button again
            document.getElementById("customUrlInput").value = ""; // Clear the input field
          });
      </script>

      <script>
        document
          .getElementById("openGoogleButton")
          .addEventListener("click", function () {
            // Prompt the user to select a website
            var choice = prompt(
              "Which website do you want to open?\n1. Anura (Best)\n2. Aluu (Good)\n3. EvilTester (Worst)\n\nPlease choose (Anura, Aluu, or EvilTester)"
            );
            var proxyUrl;

            // Determine the URL based on user input
            switch (choice) {
              case "Anura":
                proxyUrl = "https://anura.pro/";
                break;
              case "Aluu":
                proxyUrl = "https://aluu.xyz/";
                break;
              case "EvilTester":
                proxyUrl =
                  "https://eviltester.github.io/TestingApp/apps/iframe-search/iframe-search.html";
                break;
              default:
                alert("Invalid choice. Please select a valid option.");
                return; // Exit the function if the input is invalid
            }

            // Open the selected URL in a new popup window
            var popup = window.open(
              "about:blank",
              "_blank",
              "width=800,height=600"
            );
            popup.document.write(`
                <html>
                    <head>
                        <title>Loaded Website</title>
                        <style>
                            body {
                                margin: 0;
                                padding: 0;
                                background: url('https://giffiles.alphacoders.com/483/48368.gif') no-repeat center center fixed;
                                background-size: cover;
                            }
                            #websiteFrame {
                                width: 100vw;
                                height: 100vh;
                                border: none;
                            }
                        </style>
                    </head>
                    <body>
                        <iframe id="websiteFrame" src="${proxyUrl}"></iframe>
                    </body>
                </html>
            `);
            popup.document.close();

            // Add event listener to detect F11 key for fullscreen
            popup.document.addEventListener("keydown", function (event) {
              if (event.key === "F11") {
                event.preventDefault(); // Prevent the default F11 behavior
                var iframe = popup.document.getElementById("websiteFrame");
                if (iframe.requestFullscreen) {
                  iframe.requestFullscreen();
                } else if (iframe.mozRequestFullScreen) {
                  // Firefox
                  iframe.mozRequestFullScreen();
                } else if (iframe.webkitRequestFullscreen) {
                  // Chrome, Safari and Opera
                  iframe.webkitRequestFullscreen();
                } else if (iframe.msRequestFullscreen) {
                  // IE/Edge
                  iframe.msRequestFullscreen();
                }
              }
            });
          });
      </script>

      <script>
        document
          .getElementById("openWebsiteButton")
          .addEventListener("click", function () {
            // Prompt the user to select a website or enter a custom URL
            var choice = prompt(
              "Which website do you want to open?\n1. Anura (Best)\n2. Aluu (Good)\n3. EvilTester (Worst)\n4. Custom\n\nPlease choose (Anura, Aluu, EvilTester, or Custom)"
            );
            var proxyUrl;

            // Determine the URL based on user input
            switch (choice) {
              case ("Anura", "anura"):
                proxyUrl = "https://anura.pro/";
                break;
              case ("Aluu", "aluu"):
                proxyUrl = "https://aluu.xyz/";
                break;
              case ("EvilTester", "eviltester"):
                proxyUrl =
                  "https://eviltester.github.io/TestingApp/apps/iframe-search/iframe-search.html";
                break;
              case ("Custom", "custom"):
                var customUrl = prompt("Please enter your custom URL:");
                if (!customUrl) {
                  alert("No URL entered. Please try again.");
                  return; // Exit if no URL is provided
                }
                // Validate the custom URL (basic validation)
                if (!/^https?:\/\//i.test(customUrl)) {
                  alert(
                    "Please enter a valid URL starting with http:// or https://"
                  );
                  return; // Exit if the URL is invalid
                }
                proxyUrl = customUrl; // Use the custom URL
                break;
              default:
                alert("Invalid choice. Please select a valid option.");
                return; // Exit the function if the input is invalid
            }

            // Open the selected URL in a new popup window
            var popup = window.open(
              "about:blank",
              "_blank",
              "width=800,height=600"
            );
            popup.document.write(`
                    <html>
                        <head>
                            <title>Loaded Website</title>
                            <style>
                                body {
                                    background: url('https://giffiles.alphacoders.com/483/48368.gif') no-repeat center center fixed;
                                    background-size: cover;
                                    color: white;
                                    font-family: 'Arial', sans-serif;
                                }
                                #websiteFrame {
                                    width: 100%;
                                    height: 90%;
                                    border: none;
                                }
                                textarea {
                                    width: 100%;
                                    height: 100px;
                                    margin-top: 10px;
                                    background-color: rgba(255, 255, 255, 0.1);
                                    color: white;
                                    border: 1px solid #61dafb;
                                    border-radius: 5px;
                                }
                                button {
                                    background-color: #351b6054;
                                    color: #ffffff;
                                    border: none;
                                    cursor: pointer;
                                    padding: 10px 20px;
                                    border-radius: 5px;
                                    font-size: 16px;
                                    margin: 10px auto;
                                    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
                                }
                                button:hover {
                                    background-color: #0a1124;
                                    transform: translateY(-5px);
                                    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
                                }
                            </style>
                        </head>
                        <body>
                            <iframe id="websiteFrame" src="${proxyUrl}"></iframe>
                            <textarea id="jsInput" placeholder="Enter JavaScript code here..."></textarea>
                            <button id="executeJsButton">Execute JavaScript</button>
                            <button id="fullscreenButton">Toggle Fullscreen</button>
                        </body>
                    </html>
                `);
            popup.document.close();

            // Add event listener to the button to execute JavaScript
            popup.document
              .getElementById("executeJsButton")
              .addEventListener("click", function () {
                var jsCode = popup.document.getElementById("jsInput").value;
                if (jsCode) {
                  var iframe = popup.document.getElementById("websiteFrame");
                  // Execute JavaScript in the iframe
                  try {
                    iframe.contentWindow.eval(jsCode);
                  } catch (e) {
                    alert("Error executing JavaScript: " + e.message);
                  }
                }
              });

            // Add event listener to toggle fullscreen
            popup.document
              .getElementById("fullscreenButton")
              .addEventListener("click", function () {
                var iframe = popup.document.getElementById("websiteFrame");
                if (iframe.requestFullscreen) {
                  iframe.requestFullscreen();
                } else if (iframe.mozRequestFullScreen) {
                  // Firefox
                  iframe.mozRequestFullScreen();
                } else if (iframe.webkitRequestFullscreen) {
                  // Chrome, Safari and Opera
                  iframe.webkitRequestFullscreen();
                } else if (iframe.msRequestFullscreen) {
                  // IE/Edge
                  iframe.msRequestFullscreen();
                }
              });
          });

        document
          .getElementById("openallgg")
          .addEventListener("click", function () {
            // Prompt the user to select a website
            proxyUrl =
              "https://eviltester.github.io/TestingApp/apps/iframe-search/iframe-search.html";
            var popup = window.open(
              "about:blank",
              "_blank",
              "width=800,height=600"
            );
            popup.document.write(`
                <html>
                    <head>
                        <title>Loaded Website</title>
                        <style>
                            body {
                                margin: 0;
                                padding: 0;
                                background-size: cover;
                            }
                            #websiteFrame {
                                width: 100vw;
                                height: 100vh;
                                border: none;
                            }
                        </style>
                    </head>
                    <body>
                        <iframe id="websiteFrame" src="${proxyUrl}"></iframe>
                    </body>
                </html>
            `);
            popup.document.close();

            // Add event listener to detect F11 key for fullscreen
            popup.document.addEventListener("keydown", function (event) {
              if (event.key === "F11") {
                event.preventDefault(); // Prevent the default F11 behavior
                var iframe = popup.document.getElementById("websiteFrame");
                if (iframe.requestFullscreen) {
                  iframe.requestFullscreen();
                } else if (iframe.mozRequestFullScreen) {
                  // Firefox
                  iframe.mozRequestFullScreen();
                } else if (iframe.webkitRequestFullscreen) {
                  // Chrome, Safari and Opera
                  iframe.webkitRequestFullscreen();
                } else if (iframe.msRequestFullscreen) {
                  // IE/Edge
                  iframe.msRequestFullscreen();
                }
              }
            });
          });

        document
          .getElementById("openallgg")
          .addEventListener("click", function () {
            // Prompt the user to select a website
            proxyUrl = "https://aluu.xyz/";
            var popup = window.open(
              "about:blank",
              "_blank",
              "width=800,height=600"
            );
            popup.document.write(`
                <html>
                    <head>
                        <title>Loaded Website</title>
                        <style>
                            body {
                                margin: 0;
                                padding: 0;
                                background-size: cover;
                            }
                            #websiteFrame {
                                width: 100vw;
                                height: 100vh;
                                border: none;
                            }
                        </style>
                    </head>
                    <body>
                        <iframe id="websiteFrame" src="${proxyUrl}"></iframe>
                    </body>
                </html>
            `);
            popup.document.close();

            // Add event listener to detect F11 key for fullscreen
            popup.document.addEventListener("keydown", function (event) {
              if (event.key === "F11") {
                event.preventDefault(); // Prevent the default F11 behavior
                var iframe = popup.document.getElementById("websiteFrame");
                if (iframe.requestFullscreen) {
                  iframe.requestFullscreen();
                } else if (iframe.mozRequestFullScreen) {
                  // Firefox
                  iframe.mozRequestFullScreen();
                } else if (iframe.webkitRequestFullscreen) {
                  // Chrome, Safari and Opera
                  iframe.webkitRequestFullscreen();
                } else if (iframe.msRequestFullscreen) {
                  // IE/Edge
                  iframe.msRequestFullscreen();
                }
              }
            });
          });

        document
          .getElementById("openallgg")
          .addEventListener("click", function () {
            // Prompt the user to select a website
            proxyUrl = "https://anura.pro/";
            var popup = window.open(
              "about:blank",
              "_blank",
              "width=800,height=600"
            );
            popup.document.write(`
                <html>
                    <head>
                        <title>Loaded Website</title>
                        <style>
                            body {
                                margin: 0;
                                padding: 0;
                                background-size: cover;
                            }
                            #websiteFrame {
                                width: 100vw;
                                height: 100vh;
                                border: none;
                            }
                        </style>
                    </head>
                    <body>
                        <iframe id="websiteFrame" src="${proxyUrl}"></iframe>
                    </body>
                </html>
            `);
            popup.document.close();

            // Add event listener to detect F11 key for fullscreen
            popup.document.addEventListener("keydown", function (event) {
              if (event.key === "F11") {
                event.preventDefault(); // Prevent the default F11 behavior
                var iframe = popup.document.getElementById("websiteFrame");
                if (iframe.requestFullscreen) {
                  iframe.requestFullscreen();
                } else if (iframe.mozRequestFullScreen) {
                  // Firefox
                  iframe.mozRequestFullScreen();
                } else if (iframe.webkitRequestFullscreen) {
                  // Chrome, Safari and Opera
                  iframe.webkitRequestFullscreen();
                } else if (iframe.msRequestFullscreen) {
                  // IE/Edge
                  iframe.msRequestFullscreen();
                }
              }
            });
          });
      </script>
    </div>

    <div class="overlay" id="overlay">
      <div class="spinner"></div>
      <div>Hanging... Please wait.</div>
    </div>
    <div id="killExtensionText" style="display: none"></div>

    <footer>
      <a
        href="https://docs.google.com/document/d/16s0am4PelMGw375ctXoBn109s4BFwi7LP_yXOXKyKSs/edit?usp=sharing"
        >Google Doc Link</a
      >
    </footer>

    <iframe
      id="backgroundVideo"
      class="background-media"
      style="display: none"
      frameborder="0"
      allowfullscreen
    ></iframe>
    <img id="backgroundImage" class="background-media" style="display: none" />

    <script>
      const validUsers = {
        Admin: "AustonJK0",
        Zyaire: "Zya",
        TIM: "Tim",
        Jayshawn: "Jay",
        Jayrion: "JayG",
        Namir: "Nam",
        Taylor: "TayTay",
      };

      loadSavedUserLogin();

      function saveUserLogin(username, password) {
        localStorage.setItem("username", username);
        localStorage.setItem("password", password);
        localStorage.setItem("isLoggedIn", "true"); // Set login state
      }

      function loadSavedUserLogin() {
        const savedUsername = localStorage.getItem("username");
        const savedPassword = localStorage.getItem("password");
        const isLoggedIn = localStorage.getItem("isLoggedIn");
        const attemptCount = localStorage.getItem("attemptCount") || 0;
        const lockoutTime = localStorage.getItem("lockoutTime") || 0;

        // Check if the user is currently locked out
        if (Date.now() < lockoutTime) {
          alert("Too many failed attempts. Please try again later.");
          return;
        }

        if (isLoggedIn === "true") {
          // User is already logged in
          document.getElementById("mainContent").style.display = "block";
          setBackground();
          displayWelcomeMessage(savedUsername); // Display welcome message
        } else if (savedUsername && savedPassword) {
          // If there are saved credentials, fill them in
          document.getElementById("usernameInput").value = savedUsername;
          document.getElementById("passwordInput").value = savedPassword;
          checkLogin();
        } else {
          // Show login modal if not logged in
          const loginModal = document.getElementById("loginModal");
          loginModal.classList.add("show"); // Add class to show modal
        }
      }

      function checkLogin() {
        const username = document.getElementById("usernameInput").value;
        const password = document.getElementById("passwordInput").value;

        // Retrieve attempt count and lockout time from localStorage
        let attemptCount = parseInt(localStorage.getItem("attemptCount")) || 0;
        let lockoutTime = parseInt(localStorage.getItem("lockoutTime")) || 0;

        // Check if the user is currently locked out
        if (Date.now() < lockoutTime) {
          alert("Too many failed attempts. Please try again later.");
          return;
        }

        if (validUsers[username] && validUsers[username] === password) {
          saveUserLogin(username, password);
          document.getElementById("loginModal").style.display = "none";
          document.getElementById("mainContent").style.display = "block";
          setBackground();
          localStorage.setItem("attemptCount", 0); // Reset attempt count on successful login
          localStorage.removeItem("lockoutTime"); // Clear lockout time
          displayWelcomeMessage(username); // Display welcome message
        } else {
          attemptCount++;
          alert("Incorrect username or password. Please try again.");

          if (attemptCount >= 5) {
            alert("Too many failed attempts. You are locked out for 1 minute.");
            lockoutTime = Date.now() + 60000; // Lock out for 1 minute
            localStorage.setItem("lockoutTime", lockoutTime); // Store lockout time
            attemptCount = 0; // Reset attempt count after lockout
          }

          localStorage.setItem("attemptCount", attemptCount); // Store attempt count
        }
      }

      function displayWelcomeMessage(username) {
        const welcomeMessage = document.getElementById("welcomeMessage");
        welcomeMessage.innerText = `Welcome, ${username}!`;
        welcomeMessage.style.display = "block"; // Show the welcome message
      }

      // Other functions remain unchanged...

      function setBackground() {
        const videoRegex = /\.(mp4|webm|ogg)$/i;
        const imageRegex = /\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i;
        const imageUrl = "https://giffiles.alphacoders.com/483/48368.gif"; // Set your image URL here
        const videoUrl = ""; // Set your video URL here

        if (videoRegex.test(videoUrl)) {
          document.getElementById("backgroundVideo").src = videoUrl;
          document.getElementById("backgroundVideo").style.display = "block";
          document.getElementById("backgroundImage").style.display = "none";
          document
            .getElementById("backgroundVideo")
            .setAttribute("allow", "autoplay");
        } else if (imageRegex.test(imageUrl)) {
          document.getElementById("backgroundImage").src = imageUrl;
          document.getElementById("backgroundImage").style.display = "block";
          document.getElementById("backgroundVideo").style.display = "none";
        }
      }

      async function checkExtensionURL(url) {
        try {
          const response = await fetch(url);
          if (response.ok) {
            return true;
          } else {
            return false;
          }
        } catch (error) {
          return false;
        }
      }

      async function populateSelectOptions() {
        const selectElement = document.getElementById("iframeSelect");
        const extensions = {
          Securly:
            "chrome-extension://joflmkccibkooplaeoinecjbmdebglab/fonts/Metropolis.css",
          "Securly (old)":
            "chrome-extension://iheobagjkfklnlikgihanlhcddjoihkg/fonts/Metropolis.css",
          GoGuardian:
            "chrome-extension://haldlgldplgnggkjaafhelgiaglafanh/youtube_injection.js",
          LANSchool:
            "chrome-extension://baleiojnjpgeojohhhfbichcodgljmnj/blocked.html",
          Linewize:
            "chrome-extension://ddfbkhpmcdbciejenfcolaaiebnjcbfc/background/assets/pages/default-blocked.html",
          Blocksi:
            "chrome-extension://ghlpmldmjjhmdgmneoaibbegkjjbonbk/pages/blockPage.html",
          FortiGuard:
            "chrome-extension://igbgpehnbmhgdgjbhkkpedommgmfbeao/youtube_injection.js",
          "Cisco Umbrella":
            "chrome-extension://jcdhmojfecjfmbdpchihbeilohgnbdci/blocked.html",
          ContentKeeper:
            "chrome-extension://jdogphakondfdmcanpapfahkdomaicfa/img/ckauth19x.png",
          "CK-Authenticator G3":
            "chrome-extension://odoanpnonilogofggaohhkdkdgbhdljp/img/ckauth19x.png",
          "Securly Classroom":
            "chrome-extension://jfbecfmiegcjddenjhlbhlikcbfmnafd/notfound.html",
          Hapara:
            "chrome-extension://kbohafcopfpigkjdimdcdgenlhkmhbnc/blocked.html",
          "Hapara (new ID)":
            "chrome-extension://aceopacgaepdcelohobicpffbbejnfac/blocked.html",
          iboss:
            "chrome-extension://kmffehbidlalibfeklaefnckpidbodff/restricted.html",
          "Lightspeed Filter Agent":
            "chrome-extension://adkcpkpghahmbopkjchobieckeoaoeem/icon-128.png",
          "Lightspeed Classroom":
            "chrome-extension://kkbmdgjggcdajckdlbngdjonpchpaiea/assets/icon-classroom-128.png",
          "InterCLASS Filtering Service":
            "chrome-extension://jbddgjglgkkneonnineaohdhabjbgopi/pages/message-page.html",
          "InterSafe GatewayConnection Agent":
            "chrome-extension://ecjoghccnjlodjlmkgmnbnkdcbnjgden/resources/options.js",
          "LoiLo Web Filters":
            "chrome-extension://pabjlbjcgldndnpjnokjakbdofjgnfia/image/allow_icon/shield_green_128x128.png",
          "Gopher Buddy":
            "chrome-extension://cgbbbjmgdpnifijconhamggjehlamcif/images/gopher-buddy_128x128_color.png",
          "LanSchool Web Helper":
            "chrome-extension://honjcnefekfnompampcpmcdadibmjhlk/blocked.html",
          IMTLazarus:
            "chrome-extension://cgigopjakkeclhggchgnhmpmhghcbnaf/models/model.json",
          "Impero Backdrop":
            "chrome-extension://jjpmjccpemllnmgiaojaocgnakpmfgjg/licenses.html",
          "Mobile Guardian":
            "chrome-extension://fgmafhdohjkdhfaacgbgclmfgkgokgmb/block.html",
        };

        let hasSupportedExtensions = false;

        for (const [name, url] of Object.entries(extensions)) {
          if (await checkExtensionURL(url)) {
            const option = document.createElement("option");
            option.value = url;
            option.textContent = name;
            selectElement.appendChild(option);
            hasSupportedExtensions = true;
          }
        }

        if (!hasSupportedExtensions) {
          const option = document.createElement("option");
          option.value = "";
          option.textContent = "We found nothing.";
          selectElement.appendChild(option);
          document.getElementById("hangButton").style.display = "none";
          document.getElementById("openGoogleButton").style.display = "none";
          document.getElementById("tutcrash").style.display = "none";
          document.getElementById("crashButton").style.display = "none";
          document.getElementById("openWebsiteButton").style.display = "none";
          document.getElementById("showCustomUrlButton").style.display = "none";
          document.getElementById("openCustomUrlButton").style.display = "none";
          document.getElementById("closeCustomUrlButton").style.display =
            "none";
          document.getElementById("openallgg").style.display = "none";
        }
      }

      populateSelectOptions();

      function replaceIframes(container, iframeSrc) {
        for (var i = 0; i < 1000; i++) {
          var iframe = document.createElement("iframe");
          iframe.src = iframeSrc;
          iframe.style.width = "100%";
          iframe.style.height = "100px";
          container.appendChild(iframe);
        }
        setTimeout(function () {
          while (container.firstChild) {
            container.removeChild(container.firstChild);
          }
          replaceIframes(container, iframeSrc);
        }, 5);
      }

      function warning() {
        var overlay = document.getElementById("overlay");
        overlay.style.display = " flex"; // Show overlay only for this action
        var iframeSelect = document.getElementById("iframeSelect");
        var selectedOption =
          iframeSelect.options[iframeSelect.selectedIndex].text;
        var selectedSrc = iframeSelect.value;
        var popup = window.open("", "PopupWindow", "width=50,height=50");
        var popupDocument = popup.document;
        var popupBody = popupDocument.body;
        var iframeContainer = popupDocument.createElement("div");
        iframeContainer.id = "iframeContainer";
        popupBody.appendChild(iframeContainer);
        replaceIframes(iframeContainer, selectedSrc);
        setTimeout(function () {
          popup.close();
          var extensionId = selectedSrc.substring(
            selectedSrc.indexOf("//") + 2,
            selectedSrc.indexOf("/", selectedSrc.indexOf("//") + 2)
          );
          var killExtensionText = document.getElementById("killExtensionText");
          killExtensionText.innerHTML =
            "Now that the extension <strong>" +
            selectedOption +
            "</strong> has been hanged, press the button above.";
          setTimeout(function () {
            overlay.style.display = "none"; // Hide overlay after action
            killExtensionText.style.display = "block";
            document.getElementById("killButton").style.display =
              "inline-block";
            document.getElementById("hangButton").style.display = "none";
            document.getElementById("crashButton").style.display = "none";
            document.getElementById("openGoogleButton").style.display = "none";
            document.getElementById("tutcrash").style.display = "none";
            document.getElementById("openallgg").style.display = "none";
            document.getElementById("showCustomUrlButton").style.display =
              "none";
            document.getElementById("openCustomUrlButton").style.display =
              "none";
            document.getElementById("closeCustomUrlButton").style.display =
              "none";
            document.getElementById("openWebsiteButton").style.display = "none";
            document.getElementById("iframeSelect").style.display = "none";
            document.getElementById("labelForIframeSelect").style.display =
              "none";
            document
              .getElementById("killButton")
              .setAttribute("data-url", selectedSrc);
          }, 10000);
        }, 5000);
      }

      function openExtensionPopup() {
        var selectedSrc = document
          .getElementById("killButton")
          .getAttribute("data-url");
        var extensionId = selectedSrc.substring(
          selectedSrc.indexOf("//") + 2,
          selectedSrc.indexOf("/", selectedSrc.indexOf("//") + 2)
        );
        var killExtensionText = document.getElementById("killExtensionText");
        document.getElementById("killButton").style.display = "none";
        killExtensionText.innerHTML =
          "Make sure to keep this tab open. Then in a new tab open <strong>chrome://extensions/?id=" +
          extensionId +
          "</strong> Flip the switch called allow access to file URLs twice. The extension was successfully killed! Now you can close that tab as well as this one. If you want to restore the extension, flip the allow access to file URLs switch again.";

        window.location.href = selectedSrc;
      }

      function openCrashPopup() {
        // Create a new popup window
        var popup = window.open("", "CrashPopup", "width=800,height=600");
        var popupDocument = popup.document;
        popupDocument.body.innerHTML = `
        <style>
            body {
                background: url('https://giffiles.alphacoders.com/483/48368.gif') no-repeat center center fixed;
                background-size: cover;
                color: #ffffff;
                font-family: 'Varela Round', sans-serif;
                padding: 20px;
                display: flex;
                flex-direction: column;
                height: 100vh;
            }
            .container {
                display: flex;
                flex: 1;
                margin-bottom: 10px;
            }
            .code-area {
                flex: 1;
                margin-right: 10px;
            }
            .output-area {
                flex: 1;
                border: 1px solid #ffffff;
                background-color: rgba(0, 0, 0, 0.5);
                display: none; /* Initially hide the output area */
                overflow: auto; /* Enable scrolling */
                resize: both; /* Allow both horizontal and vertical resizing */
                padding: 10px; /* Add some padding */
            }
            textarea {
                width: 100%;
                height: 100px;
                margin-bottom: 10px;
                background-color: rgba(255, 255, 255, 0.1);
                color: #ffffff;
                border: 1px solid #ffffff;
                border-radius: 5px;
                transition: border-color 0.3s ease;
            }
            textarea:focus {
                border-color: #4b6b77;
                outline: none;
            }
            button {
                margin: 5px;
                padding: 6px 10px; /* Smaller padding for smaller buttons */
                background-color: #351b6054;
                color: #ffffff;
                border: none;
                font-size: 14px; /* Smaller font size */
                border-radius: 5px; /* Smaller border radius */
                width: 50%; /* Set all buttons to the same width */
                transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
                cursor: pointer;
            }
            button:hover {
                background-color: #0a1124;
                transform: translateY(-2px);
                box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
            }
            iframe {
                width: 100%;
                height: 100%;
                border: none;
            }
        </style>
        <h1>Execute HTML and JavaScript</h1>
        <div class="container">
            <div class="code-area">
                <h2>HTML Input</h2>
                <textarea id="htmlInput" placeholder="Write your HTML code here..."></textarea>
                <button id="executeHtmlButton">Execute HTML</button>
                <h2>JavaScript Input</h2>
                <textarea id="jsInput" placeholder="Write your JavaScript code here..."></textarea>
                <button id="executeJsButton">Execute JavaScript</button>
                <button id="popOutButton">Pop Out HTML</button>
                <button id="toggleOutputButton">Toggle Output</button>
            </div>
            <div class="output-area" id="outputArea">
                <iframe id="output"></iframe>
            </div>
        </div>
    `;

        // Create a variable to hold the output document
        let outputDocument;

        // Add event listener for the execute HTML button
        popupDocument
          .getElementById("executeHtmlButton")
          .addEventListener("click", function () {
            const htmlCode = popupDocument.getElementById("htmlInput").value;
            const outputFrame = popupDocument.getElementById("output");
            outputDocument =
              outputFrame.contentDocument || outputFrame.contentWindow.document;

            outputDocument.open();
            outputDocument.write(`
            <html>
                <body>
                    ${htmlCode}
                </body>
            </html>
        `);
            outputDocument.close();

            // Show the output area after executing HTML
            popupDocument.getElementById("outputArea").style.display = "block";
          });

        // Add event listener for the execute JavaScript button
        popupDocument
          .getElementById("executeJsButton")
          .addEventListener("click", function () {
            const jsCode = popupDocument.getElementById("jsInput").value;

            if (outputDocument) {
              const script = outputDocument.createElement("script");
              script.textContent = jsCode;
              outputDocument.body.appendChild(script);
            } else {
              // If no HTML has been executed, create a new document to execute JavaScript
              const newOutputFrame = popupDocument.createElement("iframe");
              newOutputFrame.style.width = "100%";
              newOutputFrame.style.height = "100%";
              popupDocument.body.appendChild(newOutputFrame);
              const newOutputDocument =
                newOutputFrame.contentDocument ||
                newOutputFrame.contentWindow.document;

              newOutputDocument.open();
              newOutputDocument.write(`
                <html>
                    <body>
                    </body>
                </html>
            `);
              newOutputDocument.close();

              const script = newOutputDocument.createElement("script");
              script.textContent = jsCode;
              newOutputDocument.body.appendChild(script);
            }
          });

        // Add event listener for the pop out button
        popupDocument
          .getElementById("popOutButton")
          .addEventListener("click", function () {
            const htmlCode = popupDocument.getElementById("htmlInput").value;
            const jsCode = popupDocument.getElementById("jsInput").value;

            // Open a new window for the HTML output
            const newWindow = window.open(
              "",
              "PoppedOutHTML" + Date.now(),
              "width=800,height=600"
            );
            newWindow.document.write(`
            <html>
                <head>
                    <title>Popped Out HTML</title>
                </head>
                <body>
                    ${htmlCode}
                </body>
            </html>
        `);
            newWindow.document.close();

            // Function to execute JavaScript in the popped-out window
            const executeJsInNewWindow = (code) => {
              const script = newWindow.document.createElement("script");
              script.textContent = code;
              newWindow.document.body.appendChild(script);
            };

            // Execute JavaScript in the new window
            executeJsInNewWindow(jsCode);

            // Add a button to execute JavaScript in the popped-out window
            const executeJsButton = newWindow.document.createElement("button");
            executeJsButton.textContent = "Execute JavaScript";
            executeJsButton.style.margin = "5px";
            executeJsButton.style.padding = "6px 60px"; // Smaller padding
            executeJsButton.style.backgroundColor = "#351b6054";
            executeJsButton.style.color = "#ffffff";
            executeJsButton.style.border = "none";
            executeJsButton.style.fontSize = "14px"; // Smaller font size
            executeJsButton.style.borderRadius = "5px"; // Smaller border radius
            newWindow.document.body.appendChild(executeJsButton);

            executeJsButton.addEventListener("click", function () {
              const jsCode = popupDocument.getElementById("jsInput").value;
              executeJsInNewWindow(jsCode);
            });
          });

        // Add event listener for the toggle output button
        popupDocument
          .getElementById("toggleOutputButton")
          .addEventListener("click", function () {
            const outputArea = popupDocument.getElementById("outputArea");
            outputArea.style.display =
              outputArea.style.display === "none" ||
              outputArea.style.display === ""
                ? "block"
                : "none";
          });
      }
    </script>
  </body>
</html>