d8796531ee
- Added 9 new tools: visual overlay, highlight, toast, drag-drop, etc. - Fixed evaluateJS to support function arguments - Fixed hover for non-visible elements - Fixed storage operations with try/catch - Added 10 new wait tools: clickable, element visible, text - Fixed tool name mapping in server.js for MCP protocol - Updated README with 60+ tools documentation - Version bump to 3.1.1
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
const browser = require('../browser');
|
|
|
|
module.exports = async ({ selector, color = '#ff6b6b', duration = 500 }) => {
|
|
if (!selector) throw new Error('Selector é obrigatório');
|
|
await browser.start();
|
|
|
|
const p = await browser.ensurePage();
|
|
|
|
const result = await p.evaluate(({ sel, clr, dur }) => {
|
|
const el = document.querySelector(sel);
|
|
if (!el) return { success: false, error: 'Element not found' };
|
|
|
|
const rect = el.getBoundingClientRect();
|
|
const highlight = document.createElement('div');
|
|
highlight.id = 'mcp-highlight-' + Date.now();
|
|
highlight.style.cssText = `
|
|
position: fixed;
|
|
left: ${rect.left}px;
|
|
top: ${rect.top}px;
|
|
width: ${rect.width}px;
|
|
height: ${rect.height}px;
|
|
border: 3px solid ${clr};
|
|
border-radius: 4px;
|
|
pointer-events: none;
|
|
z-index: 999999;
|
|
box-shadow: 0 0 10px ${clr};
|
|
animation: mcp-pulse ${dur}ms ease-out;
|
|
`;
|
|
|
|
const style = document.createElement('style');
|
|
style.textContent = '@keyframes mcp-pulse { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1); } }';
|
|
document.head.appendChild(style);
|
|
document.body.appendChild(highlight);
|
|
|
|
setTimeout(() => highlight.remove(), dur);
|
|
return { success: true };
|
|
}, { sel: selector, clr: color, dur: duration });
|
|
|
|
if (!result.success) throw new Error(result.error);
|
|
return { success: true, action: 'highlight_element', selector, color };
|
|
};
|