browserJS
Runs JavaScript in the current tab of a browser and returns what it gives back.
Keyboard Maestro: ChromeJavaScript, SafariJavaScript, FrontBrowserJavaScript
Details #
browserJS(browser, script) takes exactly two arguments and returns text.
browser is "safari", "chrome" or "front". script is JavaScript run in the current tab of the front window; the value it evaluates to comes back as text.
Parameters #
Takes 2 arguments.
{{ browserJS(text, b) }}
Examples #
browserJS("front", "document.title")→
Gotchas #
Needs Automation permission for the browser, and the browser must allow JavaScript from Apple Events. A refusal, an error in the script or no answer within about 5 seconds returns empty text.
Reading the page is harmless, but a script that changes the page changes it every time the expression is evaluated.