From 6bd00e91292d2f07488b1e994dbafd8eeac0f94f Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Fri, 17 Apr 2026 10:36:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E8=AF=8A=E6=96=AD=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=8F=AF=E8=A7=81=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=9A=84=E8=AF=86=E5=88=AB=E5=92=8C=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/signup-page.js | 24 ++++++++++++++++++++++++ tests/signup-entry-diagnostics.test.js | 11 ++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/content/signup-page.js b/content/signup-page.js index 9b6975e..6fdf820 100644 --- a/content/signup-page.js +++ b/content/signup-page.js @@ -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), }; diff --git a/tests/signup-entry-diagnostics.test.js b/tests/signup-entry-diagnostics.test.js index d1795bd..2e99d06 100644 --- a/tests/signup-entry-diagnostics.test.js +++ b/tests/signup-entry-diagnostics.test.js @@ -52,7 +52,8 @@ function extractFunction(name) { } test('signup entry diagnostics summarizes current page inputs and visible actions', () => { - const api = new Function(` +const api = new Function(` +const SIGNUP_ENTRY_TRIGGER_PATTERN = /免费注册|立即注册|注册|sign\\s*up|register|create\\s*account|create\\s+account/i; const location = { href: 'https://chatgpt.com/' }; const document = { title: 'ChatGPT', @@ -67,6 +68,9 @@ const document = { tagName: 'BUTTON', textContent: 'Get started', disabled: false, + getBoundingClientRect() { + return { width: 120, height: 40 }; + }, getAttribute(name) { return name === 'type' ? 'button' : ''; }, @@ -75,6 +79,9 @@ const document = { tagName: 'A', textContent: 'Log in', disabled: false, + getBoundingClientRect() { + return { width: 96, height: 40 }; + }, getAttribute() { return ''; }, @@ -129,6 +136,8 @@ return { assert.equal(result.readyState, 'complete'); assert.equal(result.hasEmailInput, false); assert.equal(result.hasPasswordInput, false); + assert.equal(result.bodyContainsSignupText, false); + assert.deepStrictEqual(result.signupLikeActions, []); assert.deepStrictEqual(result.visibleActions, [ { tag: 'button', type: 'button', text: 'Get started', enabled: true }, { tag: 'a', type: '', text: 'Log in', enabled: true },