Run Javascript
Runs Javascript in the context of the web page in the active tab of the frontmost window of the selected browser.
You can use return
statements to return values.
Returns
Using a JS return
statement will make the action return a value. Some simple rules apply:
- The result will always be a list. Nested arrays will be flattened.
- String, number, booleans, and arrays containing those types will always be returned as strings.
- Any other types will be replaced by empty strings.
See the section Examples below.
Examples
return [true, "yes", 1, [false], {a: 1}]
will yield a list with the strings:
- "true"
- "yes"
- "1"
- "false"
- ""
For more complex data structures, you can use JSON.stringify()! Let's say you're passing an object to the function:
return JSON.stringify(myObject)
Let's further assume that myObject
's structure isn't too weird, then this action's result will be a native dictionary, and you'll be able to access its keys using a native "Get Dictionary Value" action, like so:
