MCPcopy Create free account
hub / github.com/different-ai/opencode-browser / buildAgentNthPropertyScript

Function buildAgentNthPropertyScript

src/agent-backend.ts:347–361  ·  view source on GitHub ↗
(selector: string, indexValue: number, property: string)

Source from the content-addressed store, hash-verified

345}
346
347function buildAgentNthPropertyScript(selector: string, indexValue: number, property: string): string {
348 const payload = { selector, index: indexValue, property };
349 return buildEvalScript(`
350 const payload = ${JSON.stringify(payload)};
351 let nodes = [];
352 try {
353 nodes = Array.from(document.querySelectorAll(payload.selector));
354 } catch {
355 return { ok: false, error: "Invalid selector" };
356 }
357 const element = nodes[payload.index];
358 if (!element) return { ok: false, error: "Element not found" };
359 return { ok: true, value: element[payload.property] };
360 `);
361}
362
363function buildAgentOuterHtmlScript(selector: string, indexValue: number): string {
364 const payload = { selector, index: indexValue };

Callers 1

agentQueryFunction · 0.85

Calls 1

buildEvalScriptFunction · 0.85

Tested by

no test coverage detected