// This config would be injected into the UserScript constinjectedConfig = { hasModernWebkitAPI:true, webkitMessageHandlerNames: ["foo", "bar", "baz"], secret:"dax", };
// Then use that config to construct platform-specific configuration constconfig = newWebkitMessagingConfig(injectedConfig);
// finally, get an instance of Messaging and start sending messages in a unified way 🚀 constmessaging = newMessaging(config); messaging.notify("hello world!", {foo:"bar"})
// Messaging on Windows is namespaced, so you can create multiple messaging instances constautofillConfig = newWindowsMessagingConfig({ featureName:"Autofill" }); constdebugConfig = newWindowsMessagingConfig({ featureName:"Debugging" });
// Now send messages to both features as needed 🚀 autofillMessaging.notify("storeFormData", { "username":"dax" }) debugMessaging.notify("pageLoad", { time:window.performance.now() })
Description
An abstraction for communications between JavaScript and host platforms.
Example
Webkit Messaging
Example
Windows Messaging