Georg Jähnig
Georg Jähnig

Reputation: 799

Safari Extension: "on install" event?

I am developing an extension for Safari 6 and I want to set some default values for my settings. These default values depend on window.navigator.language, so setting them in Settings.plist does not the trick – I need to run some JS code to set them.

Obviously, this code should only run once right after install. And it shouldn't run after simply reenabling the extension.

Is there an "official" event that I can attach a function with addEventlistener to? Or do I really need the trick with setting a helper variable?

Upvotes: 1

Views: 977

Answers (1)

Matt Swain
Matt Swain

Reputation: 3887

There is no official event that I know of. But it's pretty easy to do something like this in your global page:

if (!safari.extension.settings.hasRun) {
    safari.extension.settings.hasRun = true;
    safari.extension.settings.lang = window.navigator.language;
}

Upvotes: 1

Related Questions