Pergunta

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?

Foi útil?

Solução

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;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top