Skip to main content
The Run Custom Code command (Command Type: 10) executes arbitrary JavaScript code directly in the browser’s page context. The return value of the script becomes the command result.

Command Type

Command Type ID: 10

Parameters

ParameterTypeDescriptionRequired
codestringThe JavaScript code to executeYes
timeoutnumberTimeout in millisecondsYes

Usage Examples

Extract Data from Page

{
  "command": "run-custom-code",
  "params": {
    "code": "return window.__INITIAL_STATE__.events.map(e => ({ id: e.id, name: e.name }));",
    "timeout": 10000
  }
}

Scroll to Bottom of Page

{
  "command": "run-custom-code",
  "params": {
    "code": "window.scrollTo(0, document.body.scrollHeight); return true;",
    "timeout": 5000
  }
}

Trigger Custom Logic

{
  "command": "run-custom-code",
  "params": {
    "code": "const el = document.querySelector('.load-more'); if (el) el.click(); return !!el;",
    "timeout": 8000
  }
}

Common Use Cases

  • Custom Extraction: Extract deeply nested or dynamically computed data from window
  • DOM Manipulation: Trigger interactions that require custom JS
  • Scraping Utilities: Run helper scripts for pagination, scrolling, or data normalization