I am creating a Google Chrome extension for generating passwords. It is working in an HTML page but on extension it won't output the password in text field. working HTML Page, non working Extension
Does Google chrome extensions work differently then HTML? Do I need something special in manifest.JSON?
popup.html is below
<html>
<head>
<title>Random Password Generator</title>
<style>
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
}
#status {
/* avoid an excessively wide status text */
white-space: pre;
text-overflow: ellipsis;
overflow: hidden;
max-width: 1000px;
}
</style>
<!--
- JavaScript and HTML must be in separate files: see our Content Security
- Policy documentation[1] for details and explanation.
-
- [1]: https://developer.chrome.com/extensions/contentSecurityPolicy
-->
<script src="popup.js"></script>
</head>
<body>
<div id="status"></div>
<img id="image-result" hidden>
<form name="pgenerate">
<input type="text" size=18 name="output">
<input type="button" value="Generate Password" onClick="populateform(this.form.thelength.value)"><br />
<b> <font size="1"> Password Length: </font> </b> <input type="text" name="thelength" size=3 value="12">
</form>
</body>
</html>
popup.js is below
var keylist="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*().?/`~"
var temp=''
function generatepass(plength){
temp=''
for (i=0;i<plength;i++)
temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
return temp
}
function populateform(enterlength){
document.pgenerate.output.value=generatepass(enterlength)
}
And finally my manifest.
{
"manifest_version": 2,
"name": "Random Password Generator",
"description": "This extension generates random 20 character strong passwords for you. These passwords includes both lower and upper case letters and special characters. You can copy the password, paste it in password generating window and Google Chrome will save your password if you chose remember my password. This will help in easier log in solutions.",
"author": "Sheheryar Ahmad",
"version": "1.0",
"browser_action": {
"default_icon": {
"19": "images/icon19.png",
"38": "images/icon38.png"
},
"default_popup": "popup.html",
"default_title": "Random Password Generator"
},
"permissions": [
"activeTab",
"https://ajax.googleapis.com/"
]
}