I\'m in the process of building my first Safari extension--a very simple one--but I\'ve run into a couple of problems. The extension boils down to a single, injected script that
It took me several days, but I think I found a workable solution using the canLoad()
messaging method. My injection script retrieves settings by calling the global HTML page like this:
settings = safari.self.tab.canLoad( event );
My global HTML file, in turn, returns those settings as:
settings = {
'setting1': safari.extension.settings.getItem( 'setting1' )
}
msgEvent.message = settings;
It's still a bit more "hacky" than I'd like. I can't seem to simply return the settings object itself, so I have to compile a new object by retrieving each setting manually. Not ideal, but it does seem to be effective.