<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'">
    <title>F-Stopium</title>
    <link href="./styles.css" rel="stylesheet">
  </head>
  <body>
    <div id="navBar">
    <div id="gptResponse"></div>
    <input id="txt" placeholder="Put the request here" name="url" type="text"/>
    <button onclick="go(document.getElementById('txt').value); return false;" id="goBtn">✅</button>
    <script>
      function go(q) {
        let xhr = new XMLHttpRequest();
        xhr.open('GET', 'chatgpt.min.js');
        xhr.onload = function () {
          if (xhr.status === 200) {
            var chatgptJS = document.createElement('script');
            chatgptJS.textContent = xhr.responseText;
            document.head.append(chatgptJS);
            return (async () => {
              const response = await yourCode(q);
              clearSiteData("https://chat.openai.com")
              clearSiteData("https://api.openai.com")
              clearSiteData("https://openai.com")
              clearSiteData("https://microsoft.com")
              document.getElementById("gptResponse").innerHTML = `<p>${response}</p><hr>`
              return response
            });
          }
        };
        xhr.send();
      }

      async function yourCode(q) {
          chatgpt.clearChats();
          const response = await chatgpt.askAndGetReply(q);
          return response;
      }
    </script>
  </body>
</html>