0

I'm trying to make a chrome extension that stores text locally using the chrome.storage API as a sort of password manager. (I know chrome has one built-in but this is just for practice) But chrome refuses to run the script that runs when the form for the text is submitted.

HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <style>
      text {
        font-size: 30px;
      }
    </style>
  </head>
  <body>
    <div class="text">
      <p>Totally 100% secure password manager</p>
    </div>

    <form action="post" autocomplete="off" id="Form">
      <input type="text" name="password" id="Text" />
    </form>
    <script>
      //Executes when the html form is submitted
      document.getElementById("Form").addEventListener("submit", function () {
        chrome.storage.local.set(
          { password: document.getElementById("Text").value },
          function () {
            console.log(
              "Password stored: " + document.getElementById("Text").value
            );
          }
        );
      });
    </script>
  </body>
</html>

Chrome gives the error "Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-72rWUAkaANWFYjYfF6GlHKHpaIoOaw6UP63fa2/0VAQ='), or a nonce ('nonce-...') is required to enable inline execution.". I'm new to developing in both HTML and javascript so help would be appreciated.

0 Answers0