This module provides support for injecting custom JavaScript user content into your webviews and for JavaScript to post messages back to Hammerspoon.
| Signature | hs.webview.usercontent.new(name) -> usercontentControllerObject |
|---|---|
| Type | Constructor |
| Description | Create a new user content controller for a webview and create the message port with the specified name for JavaScript message support. Parameters:
Returns:
Notes:
|
| Signature | hs.webview.usercontent:injectScript(scriptTable) -> usercontentControllerObject |
|---|---|
| Type | Method |
| Description | Add a script to be injected into webviews which use this user content controller. Parameters:
Returns:
|
| Signature | hs.webview.usercontent:removeAllScripts() -> usercontentControllerObject |
|---|---|
| Type | Method |
| Description | Removes all user scripts currently defined for this user content controller. Parameters:
Returns:
|
| Signature | hs.webview.usercontent:setCallback(fn) -> usercontentControllerObject |
|---|---|
| Type | Method |
| Description | Set or remove the callback function to handle message posted to this user content's message port. Parameters:
Returns:
Notes:
|
| Signature | hs.webview.usercontent:userScripts() -> array |
|---|---|
| Type | Method |
| Description | Get a table containing all of the currently defined injection scripts for this user content controller Parameters:
Returns:
Notes:
|