0

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/"
  ]
}
sahmad
  • 144
  • 8
  • 2
    It would help if you would give the source. – Daniel Herr Jan 21 '16 at 01:41
  • Posting a picture doesn't really help. Did you post the same picture twice? – Teepeemm Jan 21 '16 at 01:44
  • Even without looking, the answer lies in https://developer.chrome.com/extensions/contentSecurityPolicy - but please either make this question proper or delete it. And in general, https://developer.chrome.com/extensions/tut_debugging – Xan Jan 21 '16 at 11:01
  • @danielHerr just updated it with code. – sahmad Jan 21 '16 at 21:03
  • 1
    Duplicate of http://stackoverflow.com/questions/13591983/onclick-within-chrome-extension-not-working but my close vote is spent. – Xan Jan 21 '16 at 21:40

0 Answers0