Files
MCP-Browser/tools/smartWaitNavigation.js
T

11 lines
516 B
JavaScript

const browser = require('../browser');
module.exports = async ({ timeout = 15000 }) => {
await browser.start();
const oldUrl = await browser.currentUrl();
const p = await browser.ensurePage();
try { await Promise.race([p.waitForNavigation({ timeout, waitUntil: 'domcontentloaded' }), p.waitForLoadState('domcontentloaded', { timeout })]); } catch (e) {}
const newUrl = await browser.currentUrl();
return { success: true, action: 'smart_wait_navigation', oldUrl, newUrl, changed: oldUrl !== newUrl };
};