سؤال

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