Merge PR #10: add Hotmail Graph account pool flow
This commit is contained in:
+30
-3
@@ -1,5 +1,7 @@
|
||||
// content/utils.js — Shared utilities for all content scripts
|
||||
|
||||
const getActivationStrategy = self.MultiPageActivationUtils?.getActivationStrategy;
|
||||
|
||||
const SCRIPT_SOURCE = (() => {
|
||||
if (window.__MULTIPAGE_SOURCE) return window.__MULTIPAGE_SOURCE;
|
||||
const url = location.href;
|
||||
@@ -305,9 +307,34 @@ function reportError(step, errorMessage) {
|
||||
*/
|
||||
function simulateClick(el) {
|
||||
throwIfStopped();
|
||||
el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
|
||||
console.log(LOG_PREFIX, `已点击: ${el.tagName} ${el.textContent?.slice(0, 30) || ''}`);
|
||||
log(`已点击 [${el.tagName}] "${el.textContent?.trim().slice(0, 30) || ''}"`);
|
||||
if (!el) {
|
||||
throw new Error('无法点击空元素。');
|
||||
}
|
||||
|
||||
const form = el.form || el.closest?.('form') || null;
|
||||
const strategy = typeof getActivationStrategy === 'function'
|
||||
? getActivationStrategy({
|
||||
tagName: el.tagName,
|
||||
type: el.getAttribute?.('type') || el.type || '',
|
||||
hasForm: Boolean(form),
|
||||
pathname: location.pathname || '',
|
||||
})
|
||||
: { method: 'click' };
|
||||
|
||||
let method = strategy.method || 'click';
|
||||
|
||||
if (method === 'requestSubmit' && form && typeof form.requestSubmit === 'function') {
|
||||
form.requestSubmit(el);
|
||||
} else if (typeof el.click === 'function') {
|
||||
method = 'click';
|
||||
el.click();
|
||||
} else {
|
||||
method = 'dispatchEvent';
|
||||
el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
|
||||
}
|
||||
|
||||
console.log(LOG_PREFIX, `已点击(${method}): ${el.tagName} ${el.textContent?.slice(0, 30) || ''}`);
|
||||
log(`已点击(${method}) [${el.tagName}] "${el.textContent?.trim().slice(0, 30) || ''}"`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user