I am trying to make a password manager for chrome (just for practice) that you simply enter a password in a textbox in a popup and chrome saves it using the chrome.storage API. However I have 2 problems: I cannot figure out how to set an event trigger when the text is entered and the problem mentioned above.
HTML code:
<!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 src="background.js"></script>
</body>
</html>
JavaScript:
//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
);
}
);
});
I'm new to HTML and JavaScript so please be easy on me.