Skip to main content
Glama
wait-for.js1.42 kB
/** * Wait for conditions script - waits for selectors, text, or events * * @param {Object} params * @param {string} params.type - What to wait for: 'selector', 'text', 'ipc-event' * @param {string} params.value - Selector, text, or event name to wait for * @param {number} params.timeout - Timeout in milliseconds */ (async function(params) { const { type, value, timeout } = params; const startTime = Date.now(); return new Promise((resolve, reject) => { function check() { if (Date.now() - startTime > timeout) { reject(new Error(`Timeout waiting for ${type}: ${value}`)); return; } if (type === 'selector') { const element = document.querySelector(value); if (element) { resolve(`Element found: ${value}`); return; } } else if (type === 'text') { const found = document.body.innerText.includes(value); if (found) { resolve(`Text found: ${value}`); return; } } else if (type === 'ipc-event') { // For IPC events, we'd need to set up a listener // This is a simplified version reject(new Error('IPC event waiting not yet implemented in this context')); return; } setTimeout(check, 100); } check(); }); })

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hypothesi/mcp-server-tauri'

If you have feedback or need assistance with the MCP directory API, please join our Discord server