- 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
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
const browser = require('../browser');
|
|
|
|
module.exports = async ({ fullPage = true, path: customPath = null, highlight = null }) => {
|
|
await browser.start();
|
|
const p = await browser.ensurePage();
|
|
|
|
if (highlight) {
|
|
const selectors = Array.isArray(highlight) ? highlight : [highlight];
|
|
await p.evaluate((sels) => {
|
|
sels.forEach((sel, i) => {
|
|
const el = document.querySelector(sel);
|
|
if (!el) return;
|
|
const rect = el.getBoundingClientRect();
|
|
const marker = document.createElement('div');
|
|
marker.id = 'mcp-marker-' + i;
|
|
marker.style.cssText = `
|
|
position: fixed;
|
|
left: ${rect.left}px;
|
|
top: ${rect.top}px;
|
|
width: ${rect.width}px;
|
|
height: ${rect.height}px;
|
|
border: 2px dashed #ff6b6b;
|
|
background: rgba(255, 107, 107, 0.1);
|
|
pointer-events: none;
|
|
z-index: 999998;
|
|
`;
|
|
marker.setAttribute('data-selector', sel);
|
|
document.body.appendChild(marker);
|
|
});
|
|
}, selectors);
|
|
}
|
|
|
|
const file = await browser.screenshot({ fullPage, path: customPath });
|
|
|
|
if (highlight) {
|
|
await p.evaluate((sels) => {
|
|
sels.forEach((sel, i) => {
|
|
const marker = document.getElementById('mcp-marker-' + i);
|
|
if (marker) marker.remove();
|
|
});
|
|
}, Array.isArray(highlight) ? highlight : [highlight]);
|
|
}
|
|
|
|
return { success: true, action: 'annotated_screenshot', file, highlighted: highlight };
|
|
};
|