0

I'm writing my first Chrome packaged app and as per the documentation adding

"content_scripts": [
    {      
      "js": ["app.js"]
    }
  ],

this produces a chrome error that says: "There were warnings when trying to install this extension: 'content_scripts' is only allowed for extensions and legacy packaged apps, but this is a packaged app."

I have no idea what this means, but more importantly, I don't understand how I am to define the scripts in the js/ folder so that the app actually sees them and loads them.

rsanchez
  • 14,467
  • 1
  • 35
  • 46
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
  • 1
    http://stackoverflow.com/questions/16171474/filesystem-is-only-allowed-for-packaged-apps-and-this-is-a-legacy-packaged-ap – Madhur Ahuja Aug 10 '14 at 04:22
  • @MadhurAhuja, that only says that this methodology is not allowed. It doesn't actually explain what one ought to do instead. – Yevgeny Simkin Aug 10 '14 at 07:05
  • 2
    You are looking at the extension documentation, you need to look at the [app documentation](https://developer.chrome.com/apps/app_lifecycle#eventpage). – abraham Aug 10 '14 at 08:01
  • 1
    apps don't have content scripts. They use background same as extension (manifest) and other referenced through HTML page when fired (chrome.app.window.create("page.html",...) –  Aug 10 '14 at 08:41

1 Answers1

2

JavaScript files are in the same directory tree as the rest of the app (the root of that tree contains manifest.json) and they are referenced from SCRIPT tags in the HTML file. In addition, the manifest must have a background.scripts property that references the JavaScript file(s) for the event page. (This property is what makes it an app, as opposed to something else, such as an extension.) The event page is required; HTML associated with windows is optional, only present if you want one or more windows.

Marc Rochkind
  • 3,678
  • 3
  • 30
  • 38