chrome-agent 0.3.0

Browser automation for AI agents. Single binary, zero deps, CDP direct to Chrome.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const { JSDOM } = require('jsdom');
const extract = require('../../vendor/extract.js');

function extractFromHTML(html, limit = 20) {
  const dom = new JSDOM(html);
  const result = extract(dom.window.document, limit);
  return JSON.parse(result);
}

function extractFromHTMLWithSelector(html, selector, limit = 20) {
  const dom = new JSDOM(html);
  const scope = dom.window.document.querySelector(selector);
  if (!scope) return { items: [], hint: `Selector ${selector} not found` };
  const result = extract(scope, limit);
  return JSON.parse(result);
}

module.exports = { extractFromHTML, extractFromHTMLWithSelector };