Global.js Safari App Extension
This is a proof-of-concept Safari app extension for embedding a
WKWebView view from the WKWebkit framework inside a Safari app extension. Tested on macOS 10.14.2 Mojave and Safari Technology Preview 72. YMMV on other versions.
Instead of doing that, the idea here is:
- we embed a
WKWebViewinstance inside the app extension
- have it load
global.json first invocation.
Results / Caveats
- Compile the project and run the extension.
- Reload the main page after the extension runs. This ensures that the injected script loads (Safari sometimes doesn't inject app extension content scripts correctly).
- Click the toolbar item installed by the extension.
- See that the global.js function
test2is successfully invoked, and its results printed via an
alert()call in the injected script.
Success! Sort of.
The process of calling JS functions with simple values is fairly straightforward. However, I have yet to figure out how to call
- The app extension target (not the main containing app target) must have the "Outgoing Connections (client)" capability granted in the App Sandbox.