> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Custom Code

> Execute custom JavaScript code in the browser context

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

| Parameter   | Type   | Description                    | Required |
| ----------- | ------ | ------------------------------ | -------- |
| **code**    | string | The JavaScript code to execute | Yes      |
| **timeout** | number | Timeout in milliseconds        | Yes      |

## Usage Examples

### Extract Data from Page

```json theme={null}
{
  "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

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

### Trigger Custom Logic

```json theme={null}
{
  "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

## Related Commands

* [Get Window Data](/stream/commands/browser/get-window-data) - Structured `window` property access
* [Click by Javascript](/stream/commands/browser/click-by-javascript) - JS click without custom code
