Expand description
JavaScript payloads injected into the browser by MCP tools.
Constants§
- DOC_
SIZE_ JS - Expression yielding the document’s scroll size as JSON, for full-page screenshots on BiDi.
- DOC_
TOKEN_ JS - Expression (for
script.evaluate) yielding the per-document token as a decimal string; creates it when the walker has not run yet. - FETCH_
JS - Performs a fetch from the page context. Receives JSON-string args.
- GET_
CLIP_ RECT_ JS - Resolves a selector to a clip rectangle in document coordinates,
scrolling the element into view first. Returns
nullwhen the selector matches nothing or the element has zero area (hidden / detached). - GET_
DOM_ JS - Serializes the DOM with shadow roots included.
- GET_
PAGE_ TEXT_ JS - Readable-text extraction for
browser_get_page_text. Called as(fn)(maxChars, selectorOrNull); returns a JSON string{title, url, source, text, truncated, total_chars}or{error}. - REF_
CENTER_ JS (id)→ centre of the element in viewport CSS px after scrolling it into view, clipped to the viewport.- REF_
CLIP_ RECT_ JS (id)→ the element’s border box in document coordinates (same contract asGET_CLIP_RECT_JS).- REF_
TYPE_ JS (id, text, mode)withmode=fill|select|clear: focus the element, select its content (or clear it), and forfillinserttextthroughexecCommand('insertText')with a value-setter fallback that keeps framework value trackers in sync. Returns{kind, method}.- SELECT_
ALL_ JS - Called via
Runtime.callFunctionOnwiththisbound to the element about to receive typed text. Selects the element’s current content so the followingInput.insertTextreplaces it (like Playwrightfill). Withclear=truethe content is emptied outright andinput/changeare dispatched, for the “type an empty string” case. - SELECT_
ELEMENT_ JS - Interactive element picker. Resolves with the selector string for the picked element.
- SNAPSHOT_
TREE_ JS - The walker itself; see the header comment in the file.