As this official document said, I put safari.extension.settings.test = "test"
in my injected script, and it didn't work with an error:
TypeError: undefined is not an object (evaluating 'safari.extension.settings.test = "test"')
And I noticed that this setting api might have been depreciated? apple forums
So what's the best way now to read/write global settings through the injected script or somewhere else?
The old Safari Extensions API is deprecated! Please check the Safari App Extensions API instead.
The easiest way would be to store your settings in UserDefaults
, like a classic iOS/Mac app.