Page Analysis
Fast, structured alternatives to screenshots for understanding page content. These tools return JSON data and require no mutex, making them ideal for multi-agent workflows. ## firefox_get_page_state Get structured page state as JSON. Returns headings, links, buttons, inputs, images, and landmarks with counts. Much faster than screenshots for understanding page content. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `tabId` | number | active tab | Target tab ID | | `maxHeadings` | number | `30` | Max headings to return | | `maxLinks` | number | `50` | Max links to return | | `maxButtons` | number | `30` | Max buttons to return | | `maxInputs` | number | `30` | Max inputs to return | | `maxImages` | number | `20` | Max images to return | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Response shape and limits ```json { "headings": [{ "level": "h1", "text": "...", "truncated": true, "rawLength": 150 }], "links": [{ "text": "...", "href": "...", "truncated": true }], "buttons": [{ "text": "Submit", "disabled": false, "type": "submit" }], "inputs": [{ "type": "text", "name": "email", "label": "Email", "value": "...", "required": true, "disabled": false }], "images": [{ "alt": "...", "src": "...", "truncated": true }], "landmarks": [], "counts": {} } ``` The count parameters above are forwarded to the content script. String caps are: heading text 100 characters; link text 50 and href 100; button text 50; input values 50; image alt text and source 100 each. When a non-sensitive value exceeds its cap, its object includes `truncated: true`; heading objects also include `rawLength`. Password input values are always returned as `'***'`. Password objects never include `truncated` or raw-length metadata, so the password length is not leaked. Buttons return `{ text, disabled, type }`; they do not return a selector. Inputs return `{ type, name, label, value, required, disabled }`, and `label` falls back through `aria-label`, placeholder, and an associated `<label>`. ### Example with limits ```js const compact = await firefox_get_page_state({ tabId: 42, maxHeadings: 10, maxLinks: 10, maxButtons: 5, maxInputs: 5, maxImages: 3 }); ``` The `counts` object reports shown and total items for each collection. These collection limits are independent from the character caps. --- ## firefox_get_element Get detailed information about a specific element, including attributes, computed styles, visibility, and position. The returned `text` property is capped at 500 characters. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `selector` | string | **required** | CSS selector for the element | | `tabId` | number | active tab | Target tab ID | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js const info = await firefox_get_element({ selector: "#submit-btn", tabId: 42 }); ``` The element response includes attributes, computed styles, bounding rect, visibility state, and the capped text value. ### Tips - Prefer this over `firefox_screenshot` when you need to understand page structure without visual inspection. - Save the result to use with `firefox_diff_page_state` for change detection. --- ## firefox_get_accessibility_snapshot Get an accessibility tree snapshot. Returns the semantic structure of the page with roles, names, and states. Capped at 200 nodes by default. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `tabId` | number | active tab | Target tab ID | | `maxDepth` | number | `5` | Maximum tree depth to traverse | | `maxNodes` | number | `200` | Maximum nodes to include (lower = faster) | | `selector` | string | `body` | CSS selector for root element | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js // Full page accessibility tree const tree = await firefox_get_accessibility_snapshot({ tabId: 42 }); // Focused snapshot of a specific section const nav = await firefox_get_accessibility_snapshot({ tabId: 42, selector: "nav.main-menu", maxDepth: 3 }); ``` ### Tips - Use `selector` to scope the snapshot to a specific region for faster results. - Lower `maxNodes` when you only need a high-level overview of the page structure. --- ## firefox_get_element Get detailed information about a specific element, including attributes, computed styles, visibility, and position. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `selector` | string | **required** | CSS selector for the element | | `tabId` | number | active tab | Target tab ID | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js const info = await firefox_get_element({ selector: "#submit-btn", tabId: 42 }); // Returns: attributes, computed styles, bounding rect, visibility state ``` ### Tips - Useful for debugging why a click or type command isn't working (e.g., element is hidden or off-screen). - Check the bounding rect to verify the element is within the viewport. --- ## firefox_diff_page_state Compare two `getPageState` snapshots to see what changed. Reports added, removed, and changed headings, links, buttons, and inputs. Useful for verifying that actions had the expected effect. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `before` | object | **required** | First `getPageState` snapshot | | `after` | object | **required** | Second `getPageState` snapshot | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js // Capture state before an action const before = await firefox_get_page_state({ tabId: 42 }); // Perform an action await firefox_click({ selector: "button.load-more", tabId: 42 }); await firefox_wait_for({ selector: ".new-items", tabId: 42 }); // Capture state after const after = await firefox_get_page_state({ tabId: 42 }); // Diff the two snapshots const diff = await firefox_diff_page_state({ before, after }); // Returns: { added: {...}, removed: {...}, changed: {...} } ``` ### Tips - Combine with `firefox_wait_for` between snapshots to ensure the page has settled. - Useful for regression testing: capture a baseline, perform actions, and verify expected changes.Fast, structured alternatives to screenshots for understanding page content. These tools return JSON data and require no mutex, making them ideal for multi-agent workflows.
firefox_get_page_state
Section titled “firefox_get_page_state”Get structured page state as JSON. Returns headings, links, buttons, inputs, images, and landmarks with counts. Much faster than screenshots for understanding page content.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
tabId | number | active tab | Target tab ID |
maxHeadings | number | 30 | Max headings to return |
maxLinks | number | 50 | Max links to return |
maxButtons | number | 30 | Max buttons to return |
maxInputs | number | 30 | Max inputs to return |
maxImages | number | 20 | Max images to return |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Response shape and limits
Section titled “Response shape and limits”{ "headings": [{ "level": "h1", "text": "...", "truncated": true, "rawLength": 150 }], "links": [{ "text": "...", "href": "...", "truncated": true }], "buttons": [{ "text": "Submit", "disabled": false, "type": "submit" }], "inputs": [{ "type": "text", "name": "email", "label": "Email", "value": "...", "required": true, "disabled": false }], "images": [{ "alt": "...", "src": "...", "truncated": true }], "landmarks": [], "counts": {}}The count parameters above are forwarded to the content script. String caps are: heading text 100 characters; link text 50 and href 100; button text 50; input values 50; image alt text and source 100 each. When a non-sensitive value exceeds its cap, its object includes truncated: true; heading objects also include rawLength.
Password input values are always returned as '***'. Password objects never include truncated or raw-length metadata, so the password length is not leaked.
Buttons return { text, disabled, type }; they do not return a selector. Inputs return { type, name, label, value, required, disabled }, and label falls back through aria-label, placeholder, and an associated <label>.
Example with limits
Section titled “Example with limits”const compact = await firefox_get_page_state({ tabId: 42, maxHeadings: 10, maxLinks: 10, maxButtons: 5, maxInputs: 5, maxImages: 3});The counts object reports shown and total items for each collection. These collection limits are independent from the character caps.
firefox_get_element
Section titled “firefox_get_element”Get detailed information about a specific element, including attributes, computed styles, visibility, and position. The returned text property is capped at 500 characters.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | string | required | CSS selector for the element |
tabId | number | active tab | Target tab ID |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”const info = await firefox_get_element({ selector: "#submit-btn", tabId: 42});The element response includes attributes, computed styles, bounding rect, visibility state, and the capped text value.
- Prefer this over
firefox_screenshotwhen you need to understand page structure without visual inspection. - Save the result to use with
firefox_diff_page_statefor change detection.
firefox_get_accessibility_snapshot
Section titled “firefox_get_accessibility_snapshot”Get an accessibility tree snapshot. Returns the semantic structure of the page with roles, names, and states. Capped at 200 nodes by default.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
tabId | number | active tab | Target tab ID |
maxDepth | number | 5 | Maximum tree depth to traverse |
maxNodes | number | 200 | Maximum nodes to include (lower = faster) |
selector | string | body | CSS selector for root element |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”// Full page accessibility treeconst tree = await firefox_get_accessibility_snapshot({ tabId: 42 });
// Focused snapshot of a specific sectionconst nav = await firefox_get_accessibility_snapshot({ tabId: 42, selector: "nav.main-menu", maxDepth: 3});- Use
selectorto scope the snapshot to a specific region for faster results. - Lower
maxNodeswhen you only need a high-level overview of the page structure.
firefox_get_element
Section titled “firefox_get_element”Get detailed information about a specific element, including attributes, computed styles, visibility, and position.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | string | required | CSS selector for the element |
tabId | number | active tab | Target tab ID |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”const info = await firefox_get_element({ selector: "#submit-btn", tabId: 42});// Returns: attributes, computed styles, bounding rect, visibility state- Useful for debugging why a click or type command isn’t working (e.g., element is hidden or off-screen).
- Check the bounding rect to verify the element is within the viewport.
firefox_diff_page_state
Section titled “firefox_diff_page_state”Compare two getPageState snapshots to see what changed. Reports added, removed, and changed headings, links, buttons, and inputs. Useful for verifying that actions had the expected effect.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
before | object | required | First getPageState snapshot |
after | object | required | Second getPageState snapshot |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”// Capture state before an actionconst before = await firefox_get_page_state({ tabId: 42 });
// Perform an actionawait firefox_click({ selector: "button.load-more", tabId: 42 });await firefox_wait_for({ selector: ".new-items", tabId: 42 });
// Capture state afterconst after = await firefox_get_page_state({ tabId: 42 });
// Diff the two snapshotsconst diff = await firefox_diff_page_state({ before, after });// Returns: { added: {...}, removed: {...}, changed: {...} }- Combine with
firefox_wait_forbetween snapshots to ensure the page has settled. - Useful for regression testing: capture a baseline, perform actions, and verify expected changes.