feat: MCP Browser v3.0 - 42 tools with stealth mode, multi-tab, PDF, cookies, storage, network logs, device emulation

This commit is contained in:
2026-03-27 11:58:52 -03:00
parent c1d716bb84
commit 13f7392555
48 changed files with 1269 additions and 714 deletions
+8 -29
View File
@@ -1,36 +1,15 @@
const browser = require('../browser');
module.exports = async ({ selector, attributes = [] }) => {
if (!selector) {
throw new Error('Selector é obrigatório');
}
if (!selector) throw new Error('Selector é obrigatório');
await browser.start();
const p = await browser.ensurePage();
const attrsStr = JSON.stringify(Array.isArray(attributes) ? attributes : []);
const elements = await p.evaluate((sel) => {
const attrs = JSON.parse(sel.__attrs);
const els = Array.from(document.querySelectorAll(sel.__sel));
return els.map(el => {
const data = {
text: (el.innerText || el.textContent || '').trim()
};
for (let i = 0; i < attrs.length; i++) {
data[attrs[i]] = el.getAttribute(attrs[i]);
}
const attrs = Array.isArray(attributes) ? attributes : [];
const elements = await browser.evaluateJS(({ sel, attrs: a }) => {
return Array.from(document.querySelectorAll(sel)).map(el => {
const data = { text: (el.innerText || el.textContent || '').trim() };
a.forEach(attr => data[attr] = el.getAttribute(attr));
return data;
});
}, { __sel: selector, __attrs: attrsStr });
return {
success: true,
action: "extract_elements",
count: elements.length,
elements
};
}, { sel: selector, attrs });
return { success: true, action: 'extract_elements', count: elements.length, elements };
};