MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / simulateClick

Function simulateClick

content/utils.js:346–376  ·  view source on GitHub ↗

* Simulate a click with proper event dispatching. * @param {Element} el

(el)

Source from the content-addressed store, hash-verified

344 * @param {Element} el
345 */
346function simulateClick(el) {
347 throwIfStopped();
348 if (!el) {
349 throw new Error('无法点击空元素。');
350 }
351
352 const form = el.form || el.closest?.('form') || null;
353 const strategy = typeof getActivationStrategy === 'function'
354 ? getActivationStrategy({
355 tagName: el.tagName,
356 type: el.getAttribute?.('type') || el.type || '',
357 hasForm: Boolean(form),
358 pathname: location.pathname || '',
359 })
360 : { method: 'click' };
361
362 let method = strategy.method || 'click';
363
364 if (method === 'requestSubmit' && form && typeof form.requestSubmit === 'function') {
365 form.requestSubmit(el);
366 } else if (typeof el.click === 'function') {
367 method = 'click';
368 el.click();
369 } else {
370 method = 'dispatchEvent';
371 el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
372 }
373
374 console.log(LOG_PREFIX, `已点击(${method}): ${el.tagName} ${el.textContent?.slice(0, 30) || ''}`);
375 log(`已点击(${method}) [${el.tagName}] "${el.textContent?.trim().slice(0, 30) || ''}"`);
376}
377
378/**
379 * Wait a specified number of milliseconds.

Callers 15

resendVerificationCodeFunction · 0.85
handle405ResendErrorFunction · 0.85
waitForSignupEntryStateFunction · 0.85
step3_fillEmailPasswordFunction · 0.85
triggerLoginSubmitActionFunction · 0.85
fillVerificationCodeFunction · 0.85
step8_triggerContinueFunction · 0.85
step5_fillNameBirthdayFunction · 0.85
refreshInboxFunction · 0.85

Calls 3

getActivationStrategyFunction · 0.85
logFunction · 0.85
throwIfStoppedFunction · 0.70

Tested by

no test coverage detected