feat: 增强注册入口诊断功能,添加对可见操作的识别和筛选

This commit is contained in:
QLHazyCoder
2026-04-17 10:36:58 +08:00
parent 32e3973340
commit 6bd00e9129
2 changed files with 34 additions and 1 deletions
+24
View File
@@ -369,6 +369,25 @@ function getSignupEntryDiagnostics() {
const actionCandidates = document.querySelectorAll(
'a, button, [role="button"], [role="link"], input[type="button"], input[type="submit"]'
);
const allActions = Array.from(actionCandidates).map((el) => {
const rect = typeof el?.getBoundingClientRect === 'function'
? el.getBoundingClientRect()
: null;
const text = getActionText(el);
return {
tag: (el.tagName || '').toLowerCase(),
type: el.getAttribute?.('type') || '',
text: text.slice(0, 80),
visible: isVisibleElement(el),
enabled: isActionEnabled(el),
rect: rect
? {
width: Math.round(rect.width || 0),
height: Math.round(rect.height || 0),
}
: null,
};
});
const visibleActions = Array.from(actionCandidates)
.filter(isVisibleElement)
.slice(0, 12)
@@ -379,6 +398,9 @@ function getSignupEntryDiagnostics() {
enabled: isActionEnabled(el),
}))
.filter((item) => item.text);
const signupLikeActions = allActions
.filter((item) => item.text && SIGNUP_ENTRY_TRIGGER_PATTERN.test(item.text))
.slice(0, 12);
return {
url: location.href,
@@ -386,6 +408,8 @@ function getSignupEntryDiagnostics() {
readyState: document.readyState || '',
hasEmailInput: Boolean(getSignupEmailInput()),
hasPasswordInput: Boolean(getSignupPasswordInput()),
bodyContainsSignupText: SIGNUP_ENTRY_TRIGGER_PATTERN.test(getPageTextSnapshot()),
signupLikeActions,
visibleActions,
bodyTextPreview: getPageTextSnapshot().slice(0, 240),
};