mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
content script messaging for safari app
This commit is contained in:
parent
98ac83dbc1
commit
53cc6f0a2b
@ -15,6 +15,8 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
page.getPropertiesWithCompletionHandler { properties in
|
||||
NSLog("The extension received a message (\(messageName)) from a script injected into (\(String(describing: properties?.url))) with userInfo (\(userInfo ?? [:]))")
|
||||
}
|
||||
|
||||
page.dispatchMessageToScript(withName: "getInfo", userInfo: ["hello": "world", "foo": "bar"])
|
||||
}
|
||||
|
||||
override func toolbarItemClicked(in window: SFSafariWindow) {
|
||||
|
@ -1,3 +1,8 @@
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
safari.extension.dispatchMessage("Hello World!");
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
safari.extension.dispatchMessage("Hello World!", { key: "value2" });
|
||||
|
||||
safari.self.addEventListener("message", (e) => {
|
||||
console.log(e);
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user