0

I have this in my background.html:

chrome.management.onEnabled.addListener(function(ExtensionInfo info) {
  alert('123');
});

which gives me an error: Uncaught SyntaxError: Unexpected identifier

If I remove info from function(ExtensionInfo info), I don't get any errors, but it's not firing the alert. Where did I go wrong?

Also, I added "management" inside permissions in manifest.json, so that's not the problem.

Norbert
  • 2,741
  • 8
  • 56
  • 111

1 Answers1

0

You won't be able to catch chrome.management.onEnabled event for your own extension.

If you are trying to execute some code on first extension installation then you would need to store some flag in a local storage.

background.html

if(!localStorage["first_run"]) {

    //do something at first run here

    localStorage["first_run"] = "done";

}

(for more advanced solution see this answer)

If you want to execute some code each time extension starts (browser startup) just put in into background.html.

Community
  • 1
  • 1
serg
  • 109,619
  • 77
  • 317
  • 330