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?

有帮助吗?

解决方案

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;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top