The Run JavaScript Block
Add a Run JavaScript action block (internallyjavascript) to your task.
Execution Context
The code runs directly in the browser page context (via Playwright’spage.evaluate()).
- Scope: Full access to the global
windowobject. - DOM: Full access to
document,querySelector,querySelectorAll, etc. - Variables: Access runtime variables using
{$varName}syntax — they are injected as string literals before evaluation. - Async: Your code is wrapped in an async function, so top-level
awaitand top-levelreturnboth work directly. Figranium awaits the returned promise automatically.
Return Values
The return value of your script is captured and stored inblock.output, which can be used by subsequent blocks.
Access the result in later blocks with
{$block.output} or in conditions with block.output.
Examples
Chaining JavaScript Blocks
Useblock.output to pass data between JavaScript blocks:
Extraction Scripts vs. JavaScript Action Blocks
Figranium has two places where you can run JavaScript:
For final data collection, prefer the Extraction Script field in task settings. Use JavaScript action blocks for mid-flow decisions and interactions.
Security Considerations
- The JavaScript action block runs in the browser context, not in Node.js. You cannot access the file system or Node.js APIs from within these blocks.
- For complex data processing that needs Node.js features, use the Extraction Script which runs through Figranium’s sandboxed JSDOM environment. The sandbox is hardened against prototype-chain escape techniques, so extraction scripts cannot break out to access the host Node.js runtime.
- Data objects passed into the sandbox are read-only. You cannot set, define, or delete properties on them. If you need to transform data, copy values into new objects you create within your script. See Sandbox isolation for details.