vps-panel.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. // content/vps-panel.js — Content script for CPA panel (steps 1, 9)
  2. // Injected on: CPA panel (user-configured URL)
  3. //
  4. // Actual DOM structure (after login click):
  5. // <div class="card">
  6. // <div class="card-header">
  7. // <span class="OAuthPage-module__cardTitle___yFaP0">Codex OAuth</span>
  8. // <button class="btn btn-primary"><span>登录</span></button>
  9. // </div>
  10. // <div class="OAuthPage-module__cardContent___1sXLA">
  11. // <div class="OAuthPage-module__authUrlBox___Iu1d4">
  12. // <div class="OAuthPage-module__authUrlLabel___mYFJB">授权链接:</div>
  13. // <div class="OAuthPage-module__authUrlValue___axvUJ">https://auth.openai.com/...</div>
  14. // <div class="OAuthPage-module__authUrlActions___venPj">
  15. // <button class="btn btn-secondary btn-sm"><span>复制链接</span></button>
  16. // <button class="btn btn-secondary btn-sm"><span>打开链接</span></button>
  17. // </div>
  18. // </div>
  19. // <div class="OAuthPage-module__callbackSection___8kA31">
  20. // <input class="input" placeholder="http://localhost:1455/auth/callback?code=...&state=...">
  21. // <button class="btn btn-secondary btn-sm"><span>提交回调 URL</span></button>
  22. // </div>
  23. // </div>
  24. // </div>
  25. console.log('[MultiPage:vps-panel] Content script loaded on', location.href);
  26. const VPS_PANEL_LISTENER_SENTINEL = 'data-multipage-vps-panel-listener';
  27. const {
  28. isRecoverableStep9AuthFailure,
  29. } = self.MultiPageActivationUtils || {};
  30. if (document.documentElement.getAttribute(VPS_PANEL_LISTENER_SENTINEL) !== '1') {
  31. document.documentElement.setAttribute(VPS_PANEL_LISTENER_SENTINEL, '1');
  32. // Listen for commands from Background
  33. chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  34. if (message.type === 'EXECUTE_STEP') {
  35. resetStopState();
  36. const startedAt = Date.now();
  37. console.log(LOG_PREFIX, `EXECUTE_STEP received for step ${message.step}`, {
  38. url: location.href,
  39. payloadKeys: Object.keys(message.payload || {}),
  40. snapshot: getVpsPanelSnapshot(),
  41. });
  42. handleStep(message.step, message.payload).then(() => {
  43. console.log(LOG_PREFIX, `EXECUTE_STEP resolved for step ${message.step} after ${Date.now() - startedAt}ms`, {
  44. url: location.href,
  45. snapshot: getVpsPanelSnapshot(),
  46. });
  47. sendResponse({ ok: true });
  48. }).catch(err => {
  49. console.error(LOG_PREFIX, `EXECUTE_STEP rejected for step ${message.step} after ${Date.now() - startedAt}ms: ${err?.message || err}`, {
  50. url: location.href,
  51. snapshot: getVpsPanelSnapshot(),
  52. });
  53. if (isStopError(err)) {
  54. log(`步骤 ${message.step}:已被用户停止。`, 'warn');
  55. sendResponse({ stopped: true, error: err.message });
  56. return;
  57. }
  58. reportError(message.step, err.message);
  59. sendResponse({ error: err.message });
  60. });
  61. return true;
  62. }
  63. });
  64. } else {
  65. console.log('[MultiPage:vps-panel] 消息监听已存在,跳过重复注册');
  66. }
  67. async function handleStep(step, payload) {
  68. switch (step) {
  69. case 1: return await step1_getOAuthLink(payload);
  70. case 9: return await step9_vpsVerify(payload);
  71. default:
  72. throw new Error(`vps-panel.js 不处理步骤 ${step}`);
  73. }
  74. }
  75. function isVisibleElement(el) {
  76. if (!el) return false;
  77. const style = window.getComputedStyle(el);
  78. const rect = el.getBoundingClientRect();
  79. return style.display !== 'none'
  80. && style.visibility !== 'hidden'
  81. && rect.width > 0
  82. && rect.height > 0;
  83. }
  84. function getActionText(el) {
  85. return [
  86. el?.textContent,
  87. el?.value,
  88. el?.getAttribute?.('aria-label'),
  89. el?.getAttribute?.('title'),
  90. ]
  91. .filter(Boolean)
  92. .join(' ')
  93. .replace(/\s+/g, ' ')
  94. .trim();
  95. }
  96. function getInlineTextSnippet(text, maxLength = 160) {
  97. const normalized = (text || '').replace(/\s+/g, ' ').trim();
  98. if (!normalized) return '';
  99. if (normalized.length <= maxLength) return normalized;
  100. return `${normalized.slice(0, maxLength)}...`;
  101. }
  102. function getPageTextSnippet(maxLength = 240) {
  103. const bodyText = document.body?.innerText || document.documentElement?.innerText || '';
  104. return getInlineTextSnippet(bodyText, maxLength);
  105. }
  106. function getVpsPanelSnapshot() {
  107. const authUrlEl = findAuthUrlElement();
  108. const oauthHeader = findCodexOAuthHeader();
  109. const managementKeyInput = findManagementKeyInput();
  110. const managementLoginButton = findManagementLoginButton();
  111. const rememberCheckbox = findRememberPasswordCheckbox();
  112. const oauthNavLink = findOAuthNavLink();
  113. return {
  114. url: location.href,
  115. readyState: document.readyState,
  116. title: getInlineTextSnippet(document.title || '', 80),
  117. authUrlVisible: Boolean(authUrlEl),
  118. authUrlText: getInlineTextSnippet(authUrlEl?.textContent || '', 120),
  119. oauthHeaderVisible: Boolean(oauthHeader),
  120. oauthHeaderText: getInlineTextSnippet(oauthHeader?.textContent || '', 120),
  121. managementKeyVisible: Boolean(managementKeyInput),
  122. managementLoginVisible: Boolean(managementLoginButton),
  123. managementLoginText: getInlineTextSnippet(getActionText(managementLoginButton), 60),
  124. rememberCheckboxVisible: Boolean(rememberCheckbox),
  125. rememberCheckboxChecked: Boolean(rememberCheckbox?.checked),
  126. oauthNavVisible: Boolean(oauthNavLink),
  127. oauthNavText: getInlineTextSnippet(getActionText(oauthNavLink), 80),
  128. bodySnippet: getPageTextSnippet(),
  129. };
  130. }
  131. function getVpsPanelSnapshotSignature(snapshot) {
  132. return JSON.stringify({
  133. readyState: snapshot.readyState,
  134. title: snapshot.title,
  135. authUrlVisible: snapshot.authUrlVisible,
  136. authUrlText: snapshot.authUrlText,
  137. oauthHeaderVisible: snapshot.oauthHeaderVisible,
  138. oauthHeaderText: snapshot.oauthHeaderText,
  139. managementKeyVisible: snapshot.managementKeyVisible,
  140. managementLoginVisible: snapshot.managementLoginVisible,
  141. rememberCheckboxVisible: snapshot.rememberCheckboxVisible,
  142. rememberCheckboxChecked: snapshot.rememberCheckboxChecked,
  143. oauthNavVisible: snapshot.oauthNavVisible,
  144. oauthNavText: snapshot.oauthNavText,
  145. bodySnippet: snapshot.bodySnippet,
  146. });
  147. }
  148. function parseUrlSafely(rawUrl) {
  149. if (!rawUrl) return null;
  150. try {
  151. return new URL(rawUrl);
  152. } catch {
  153. return null;
  154. }
  155. }
  156. function isLocalhostOAuthCallbackUrl(rawUrl) {
  157. const parsed = parseUrlSafely(rawUrl);
  158. if (!parsed) return false;
  159. if (!['http:', 'https:'].includes(parsed.protocol)) return false;
  160. if (!['localhost', '127.0.0.1'].includes(parsed.hostname)) return false;
  161. if (!['/auth/callback', '/codex/callback'].includes(parsed.pathname)) return false;
  162. const code = (parsed.searchParams.get('code') || '').trim();
  163. const state = (parsed.searchParams.get('state') || '').trim();
  164. return Boolean(code && state);
  165. }
  166. function getStatusBadgeElement() {
  167. const selectors = [
  168. '#root > div > div > div > main > div > div > div > div > div:nth-child(1) > div > div.OAuthPage-module__cardContent___1sXLA > div.status-badge',
  169. '#root .OAuthPage-module__cardContent___1sXLA > .status-badge',
  170. '.OAuthPage-module__cardContent___1sXLA > .status-badge',
  171. '.status-badge',
  172. ];
  173. for (const selector of selectors) {
  174. const candidates = document.querySelectorAll(selector);
  175. const visible = Array.from(candidates).find(isVisibleElement);
  176. if (visible) return visible;
  177. }
  178. return null;
  179. }
  180. function getStatusBadgeText() {
  181. const statusEl = getStatusBadgeElement();
  182. return statusEl ? (statusEl.textContent || '').replace(/\s+/g, ' ').trim() : '';
  183. }
  184. function isOAuthCallbackTimeoutFailure(statusText) {
  185. return /认证失败:\s*Timeout waiting for OAuth callback/i.test(statusText || '');
  186. }
  187. async function waitForExactSuccessBadge(timeout = 30000) {
  188. const start = Date.now();
  189. while (Date.now() - start < timeout) {
  190. throwIfStopped();
  191. const statusText = getStatusBadgeText();
  192. if (isOAuthCallbackTimeoutFailure(statusText)) {
  193. throw new Error(`STEP9_OAUTH_TIMEOUT::${statusText}`);
  194. }
  195. if (typeof isRecoverableStep9AuthFailure === 'function' && isRecoverableStep9AuthFailure(statusText)) {
  196. throw new Error(`STEP9_OAUTH_RETRY::${statusText}`);
  197. }
  198. if (statusText === '认证成功!') {
  199. return statusText;
  200. }
  201. await sleep(200);
  202. }
  203. const finalText = getStatusBadgeText();
  204. if (isOAuthCallbackTimeoutFailure(finalText)) {
  205. throw new Error(`STEP9_OAUTH_TIMEOUT::${finalText}`);
  206. }
  207. if (typeof isRecoverableStep9AuthFailure === 'function' && isRecoverableStep9AuthFailure(finalText)) {
  208. throw new Error(`STEP9_OAUTH_RETRY::${finalText}`);
  209. }
  210. throw new Error(finalText
  211. ? `CPA 面板状态不是“认证成功!”,当前为“${finalText}”。`
  212. : 'CPA 面板长时间未出现“认证成功!”状态徽标。');
  213. }
  214. function findManagementKeyInput() {
  215. const candidates = document.querySelectorAll(
  216. '.LoginPage-module__loginCard___OgP-R input[type="password"], input[placeholder*="管理密钥"], input[aria-label*="管理密钥"]'
  217. );
  218. return Array.from(candidates).find(isVisibleElement) || null;
  219. }
  220. function findManagementLoginButton() {
  221. const candidates = document.querySelectorAll('.LoginPage-module__loginCard___OgP-R button, .LoginPage-module__loginCard___OgP-R .btn');
  222. return Array.from(candidates).find((el) => {
  223. if (!isVisibleElement(el)) return false;
  224. return /登录|login/i.test(getActionText(el));
  225. }) || null;
  226. }
  227. function findRememberPasswordCheckbox() {
  228. const candidates = document.querySelectorAll('.LoginPage-module__loginCard___OgP-R input[type="checkbox"]');
  229. return Array.from(candidates).find((el) => {
  230. const label = el.closest('label');
  231. const text = getActionText(label || el);
  232. return /记住密码|remember/i.test(text);
  233. }) || null;
  234. }
  235. function findOAuthNavLink() {
  236. const candidates = document.querySelectorAll('a[href*="#/oauth"], a.nav-item, button, [role="link"], [role="button"]');
  237. return Array.from(candidates).find((el) => {
  238. if (!isVisibleElement(el)) return false;
  239. const text = getActionText(el);
  240. const href = el.getAttribute('href') || '';
  241. return href.includes('#/oauth') || /oauth/i.test(text);
  242. }) || null;
  243. }
  244. function findCodexOAuthHeader() {
  245. const candidates = document.querySelectorAll('.card-header, [class*="cardHeader"], .card, [class*="card"]');
  246. return Array.from(candidates).find((el) => {
  247. if (!isVisibleElement(el)) return false;
  248. const text = (el.textContent || '').toLowerCase();
  249. return text.includes('codex') && text.includes('oauth');
  250. }) || null;
  251. }
  252. function findOAuthCardLoginButton(header) {
  253. const card = header?.closest('.card, [class*="card"]') || header?.parentElement || document;
  254. const candidates = card.querySelectorAll('button.btn.btn-primary, button.btn-primary, button.btn');
  255. return Array.from(candidates).find((el) => isVisibleElement(el) && /登录|login/i.test(getActionText(el))) || null;
  256. }
  257. function findAuthUrlElement() {
  258. const candidates = document.querySelectorAll('[class*="authUrlValue"], .OAuthPage-module__authUrlValue___axvUJ');
  259. return Array.from(candidates).find((el) => isVisibleElement(el) && /^https?:\/\//i.test((el.textContent || '').trim())) || null;
  260. }
  261. async function ensureOAuthManagementPage(vpsPassword, step = 1, timeout = 45000) {
  262. const start = Date.now();
  263. let lastLoginAttemptAt = 0;
  264. let lastOauthNavAttemptAt = 0;
  265. let lastSnapshotSignature = '';
  266. let lastSnapshotLogAt = 0;
  267. console.log(LOG_PREFIX, `[Step ${step}] ensureOAuthManagementPage start`, {
  268. timeout,
  269. url: location.href,
  270. hasVpsPassword: Boolean(vpsPassword),
  271. snapshot: getVpsPanelSnapshot(),
  272. });
  273. while (Date.now() - start < timeout) {
  274. throwIfStopped();
  275. const elapsed = Date.now() - start;
  276. const snapshot = getVpsPanelSnapshot();
  277. const signature = getVpsPanelSnapshotSignature(snapshot);
  278. if (signature !== lastSnapshotSignature || elapsed - lastSnapshotLogAt >= 5000) {
  279. lastSnapshotSignature = signature;
  280. lastSnapshotLogAt = elapsed;
  281. console.log(LOG_PREFIX, `[Step ${step}] panel snapshot at ${elapsed}ms`, snapshot);
  282. }
  283. const authUrlEl = findAuthUrlElement();
  284. if (authUrlEl) {
  285. console.log(LOG_PREFIX, `[Step ${step}] found visible auth URL after ${elapsed}ms`, {
  286. url: location.href,
  287. authUrlText: getInlineTextSnippet(authUrlEl.textContent || '', 120),
  288. });
  289. return { header: findCodexOAuthHeader(), authUrlEl };
  290. }
  291. const oauthHeader = findCodexOAuthHeader();
  292. if (oauthHeader) {
  293. console.log(LOG_PREFIX, `[Step ${step}] found OAuth card header after ${elapsed}ms`, {
  294. url: location.href,
  295. headerText: getInlineTextSnippet(oauthHeader.textContent || '', 120),
  296. });
  297. return { header: oauthHeader, authUrlEl: null };
  298. }
  299. const managementKeyInput = findManagementKeyInput();
  300. const managementLoginButton = findManagementLoginButton();
  301. if (managementKeyInput && managementLoginButton) {
  302. if (!vpsPassword) {
  303. throw new Error('CPA 面板需要管理密钥,请先在侧边栏填写 CPA Key(管理密钥)。');
  304. }
  305. if ((managementKeyInput.value || '') !== vpsPassword) {
  306. await humanPause(350, 900);
  307. fillInput(managementKeyInput, vpsPassword);
  308. console.log(LOG_PREFIX, `[Step ${step}] filled management key after ${elapsed}ms`);
  309. log(`步骤 ${step}:已填写 CPA 管理密钥。`);
  310. }
  311. const rememberCheckbox = findRememberPasswordCheckbox();
  312. if (rememberCheckbox && !rememberCheckbox.checked) {
  313. simulateClick(rememberCheckbox);
  314. console.log(LOG_PREFIX, `[Step ${step}] toggled remember checkbox after ${elapsed}ms`);
  315. log(`步骤 ${step}:已勾选 CPA 面板“记住密码”。`);
  316. await sleep(300);
  317. }
  318. if (Date.now() - lastLoginAttemptAt > 3000) {
  319. lastLoginAttemptAt = Date.now();
  320. await humanPause(350, 900);
  321. simulateClick(managementLoginButton);
  322. console.log(LOG_PREFIX, `[Step ${step}] clicked management login after ${elapsed}ms`, {
  323. buttonText: getInlineTextSnippet(getActionText(managementLoginButton), 80),
  324. });
  325. log(`步骤 ${step}:已提交 CPA 管理登录。`);
  326. }
  327. await sleep(1500);
  328. continue;
  329. }
  330. const oauthNavLink = findOAuthNavLink();
  331. if (oauthNavLink && Date.now() - lastOauthNavAttemptAt > 2000) {
  332. lastOauthNavAttemptAt = Date.now();
  333. await humanPause(300, 800);
  334. simulateClick(oauthNavLink);
  335. console.log(LOG_PREFIX, `[Step ${step}] clicked OAuth nav after ${elapsed}ms`, {
  336. navText: getInlineTextSnippet(getActionText(oauthNavLink), 80),
  337. });
  338. log(`步骤 ${step}:已打开“OAuth 登录”导航。`);
  339. await sleep(1200);
  340. continue;
  341. }
  342. await sleep(250);
  343. }
  344. console.error(LOG_PREFIX, `[Step ${step}] ensureOAuthManagementPage timeout after ${Date.now() - start}ms`, {
  345. url: location.href,
  346. snapshot: getVpsPanelSnapshot(),
  347. });
  348. throw new Error('无法进入 CPA 的 OAuth 管理页面,请检查面板是否正常加载。URL: ' + location.href);
  349. }
  350. // ============================================================
  351. // Step 1: Get OAuth Link
  352. // ============================================================
  353. async function step1_getOAuthLink(payload) {
  354. const { vpsPassword } = payload || {};
  355. console.log(LOG_PREFIX, '[Step 1] step1_getOAuthLink start', {
  356. url: location.href,
  357. hasVpsPassword: Boolean(vpsPassword),
  358. snapshot: getVpsPanelSnapshot(),
  359. });
  360. log('步骤 1:正在等待 CPA 面板加载并进入 OAuth 页面...');
  361. const { header, authUrlEl: existingAuthUrlEl } = await ensureOAuthManagementPage(vpsPassword, 1);
  362. let authUrlEl = existingAuthUrlEl;
  363. console.log(LOG_PREFIX, '[Step 1] ensureOAuthManagementPage resolved', {
  364. url: location.href,
  365. hasHeader: Boolean(header),
  366. hasExistingAuthUrl: Boolean(existingAuthUrlEl),
  367. snapshot: getVpsPanelSnapshot(),
  368. });
  369. if (!authUrlEl) {
  370. const loginBtn = findOAuthCardLoginButton(header);
  371. if (!loginBtn) {
  372. throw new Error('已找到 Codex OAuth 卡片,但卡片内没有登录按钮。URL: ' + location.href);
  373. }
  374. if (loginBtn.disabled) {
  375. console.log(LOG_PREFIX, '[Step 1] OAuth login button is disabled, waiting for auth URL', {
  376. url: location.href,
  377. buttonText: getInlineTextSnippet(getActionText(loginBtn), 80),
  378. });
  379. log('步骤 1:OAuth 登录按钮当前不可用,正在等待授权链接出现...');
  380. } else {
  381. await humanPause(500, 1400);
  382. simulateClick(loginBtn);
  383. console.log(LOG_PREFIX, '[Step 1] clicked OAuth login button and waiting for auth URL', {
  384. url: location.href,
  385. buttonText: getInlineTextSnippet(getActionText(loginBtn), 80),
  386. });
  387. log('步骤 1:已点击 OAuth 登录按钮,正在等待授权链接...');
  388. }
  389. try {
  390. authUrlEl = await waitForElement('[class*="authUrlValue"]', 15000);
  391. } catch {
  392. throw new Error(
  393. '点击 OAuth 登录按钮后未出现授权链接。' +
  394. '请检查 CPA 面板服务是否正在运行。URL: ' + location.href
  395. );
  396. }
  397. } else {
  398. log('步骤 1:CPA 面板上已显示授权链接。');
  399. }
  400. const oauthUrl = (authUrlEl.textContent || '').trim();
  401. if (!oauthUrl || !oauthUrl.startsWith('http')) {
  402. throw new Error(`拿到的 OAuth 链接无效:\"${oauthUrl.slice(0, 50)}\"。应为 http 开头的 URL。`);
  403. }
  404. log(`步骤 1:已获取 OAuth 链接:${oauthUrl.slice(0, 80)}...`, 'ok');
  405. console.log(LOG_PREFIX, '[Step 1] reporting completion with oauthUrl', {
  406. url: location.href,
  407. oauthUrlPreview: oauthUrl.slice(0, 120),
  408. });
  409. reportComplete(1, { oauthUrl });
  410. }
  411. // ============================================================
  412. // 步骤 9:CPA 回调验证——填写 localhost 回调地址并提交
  413. // ============================================================
  414. async function step9_vpsVerify(payload) {
  415. await ensureOAuthManagementPage(payload?.vpsPassword, 9);
  416. // 优先从 payload 读取 localhostUrl;没有时再回退到全局状态
  417. let localhostUrl = payload?.localhostUrl;
  418. if (localhostUrl && !isLocalhostOAuthCallbackUrl(localhostUrl)) {
  419. throw new Error('步骤 9 只接受真实的 localhost OAuth 回调地址,请重新执行步骤 8。');
  420. }
  421. if (!localhostUrl) {
  422. log('步骤 9:payload 中没有 localhostUrl,正在从状态中读取...');
  423. const state = await chrome.runtime.sendMessage({ type: 'GET_STATE' });
  424. localhostUrl = state.localhostUrl;
  425. if (localhostUrl && !isLocalhostOAuthCallbackUrl(localhostUrl)) {
  426. throw new Error('步骤 9 只接受真实的 localhost OAuth 回调地址,请重新执行步骤 8。');
  427. }
  428. }
  429. if (!localhostUrl) {
  430. throw new Error('未找到 localhost 回调地址,请先完成步骤 8。');
  431. }
  432. log(`步骤 9:已获取 localhostUrl:${localhostUrl.slice(0, 60)}...`);
  433. log('步骤 9:正在查找回调地址输入框...');
  434. // Find the callback URL input
  435. // Actual DOM: <input class="input" placeholder="http://localhost:1455/auth/callback?code=...&state=...">
  436. let urlInput = null;
  437. try {
  438. urlInput = await waitForElement('[class*="callbackSection"] input.input', 10000);
  439. } catch {
  440. try {
  441. urlInput = await waitForElement('input[placeholder*="localhost"]', 5000);
  442. } catch {
  443. throw new Error('在 CPA 面板中未找到回调地址输入框。URL: ' + location.href);
  444. }
  445. }
  446. await humanPause(600, 1500);
  447. fillInput(urlInput, localhostUrl);
  448. log(`步骤 9:已填写回调地址:${localhostUrl.slice(0, 80)}...`);
  449. // Find and click "提交回调 URL" button
  450. let submitBtn = null;
  451. try {
  452. submitBtn = await waitForElementByText(
  453. '[class*="callbackActions"] button, [class*="callbackSection"] button',
  454. /提交/,
  455. 5000
  456. );
  457. } catch {
  458. try {
  459. submitBtn = await waitForElementByText('button.btn', /提交回调/, 5000);
  460. } catch {
  461. throw new Error('未找到“提交回调 URL”按钮。URL: ' + location.href);
  462. }
  463. }
  464. await humanPause(450, 1200);
  465. simulateClick(submitBtn);
  466. log('步骤 9:已点击“提交回调 URL”,正在等待认证结果...');
  467. const verifiedStatus = await waitForExactSuccessBadge();
  468. log(`步骤 9:${verifiedStatus}`, 'ok');
  469. reportComplete(9, { localhostUrl, verifiedStatus });
  470. }