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
+9 -36
View File
@@ -1,54 +1,27 @@
const browser = require('../browser');
module.exports = async ({ text }) => {
if (!text) {
throw new Error('Texto é obrigatório');
}
if (!text) throw new Error('Texto é obrigatório');
await browser.start();
const p = await browser.ensurePage();
const clicked = await p.evaluate((targetText) => {
const elements = Array.from(document.querySelectorAll(
'a, button, input[type="submit"], input[type="button"], [role="button"], [onclick]'
));
const elements = Array.from(document.querySelectorAll('a, button, input[type="submit"], input[type="button"], [role="button"], [onclick]'));
const el = elements.find(e => {
const txt = (e.innerText || e.textContent || e.value || e.getAttribute('aria-label') || '').trim().toLowerCase();
return txt.includes(targetText.toLowerCase());
});
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
el.click();
if (el.tagName === 'A' && el.href) {
return { clicked: true, href: el.href };
}
return { clicked: true, href: null };
return { clicked: true, href: el.tagName === 'A' ? el.href : null };
}
return { clicked: false, href: null };
}, text);
if (!clicked.clicked) {
throw new Error(`Elemento não encontrado pelo texto: "${text}"`);
}
if (clicked.href) {
try {
await p.waitForNavigation({ timeout: 5000, waitUntil: 'domcontentloaded' });
} catch (e) {
}
} else {
await p.waitForTimeout(1000);
}
return {
success: true,
action: "smart_click",
text,
navigatedTo: clicked.href || null
};
if (!clicked.clicked) throw new Error(`Elemento não encontrado: "${text}"`);
if (clicked.href) { try { await p.waitForNavigation({ timeout: 5000, waitUntil: 'domcontentloaded' }); } catch (e) {} }
else await p.waitForTimeout(1000);
return { success: true, action: 'smart_click', text, navigatedTo: clicked.href };
};