get-page-visible-text
Extract visible text from web pages using AdsPower LocalAPI MCP Server to enable content retrieval for analysis or integration into workflows.
Instructions
Get the visible text content of the page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/handlers/automation.ts:41-74 (handler)The core handler function for 'get-page-visible-text' that uses Puppeteer's evaluate to run JavaScript extracting visible text from the page using TreeWalker on text nodes, filtering hidden elements via computed styles.async getPageVisibleText() { browser.checkConnected(); try { const visibleText = await browser.pageInstance!.evaluate(() => { const walker = document.createTreeWalker( document.body, NodeFilter.SHOW_TEXT, { acceptNode: (node) => { const style = window.getComputedStyle( node.parentElement! ); return style.display !== 'none' && style.visibility !== 'hidden' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT; }, } ); let text = ''; let node; while ((node = walker.nextNode())) { const trimmedText = node.textContent?.trim(); if (trimmedText) { text += trimmedText + '\n'; } } return text.trim(); }); return `Visible text content:\n${visibleText}`; } catch (error) { return `Failed to get visible text content: ${(error as Error).message}`; } },
- src/utils/toolRegister.ts:62-63 (registration)Registers the 'get-page-visible-text' tool on the MCP server with description, empty input schema, and wrapped automation handler.server.tool('get-page-visible-text', 'Get the visible text content of the page', schemas.emptySchema.shape, wrapHandler(automationHandlers.getPageVisibleText));