From 7cc7c91bf3ff912aefa2a67553c56b6eed081ba3 Mon Sep 17 00:00:00 2001 From: unknown <1249156074@qq.com> Date: Sun, 5 Apr 2026 10:02:15 +0800 Subject: [PATCH] fix: update 163 mail - click inbox first, correct refresh selectors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Click "收件箱" in left sidebar on load to ensure inbox view - Refresh uses toolbar "刷新" button (nui-btn-text) or sidebar "收信" button - Selectors match actual 163 mail DOM structure --- background.js | 2 +- content/mail-163.js | 49 ++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/background.js b/background.js index c0086a3..1f5d04d 100644 --- a/background.js +++ b/background.js @@ -537,7 +537,7 @@ async function executeStep3(state) { function getMailConfig(state) { const provider = state.mailProvider || 'qq'; if (provider === '163') { - return { source: 'mail-163', url: 'https://mail.163.com/', label: '163 Mail' }; + return { source: 'mail-163', url: 'https://mail.163.com/js6/main.jsp?df=mail163_letter#module=mbox.ListModule%7C%7B%22fid%22%3A1%2C%22order%22%3A%22date%22%2C%22desc%22%3Atrue%7D', label: '163 Mail' }; } return { source: 'qq-mail', url: 'https://wx.mail.qq.com/', label: 'QQ Mail' }; } diff --git a/content/mail-163.js b/content/mail-163.js index cfdc12b..778caea 100644 --- a/content/mail-163.js +++ b/content/mail-163.js @@ -75,9 +75,16 @@ async function handlePollEmail(step, payload) { log(`Step ${step}: Starting email poll on 163 Mail (max ${maxAttempts} attempts)`); - // Wait for mail list to load - await sleep(3000); + // First, click on "收件箱" in left sidebar to ensure we're in inbox view + await sleep(2000); + const inboxLink = document.querySelector('.nui-tree-item-text[title="收件箱"]'); + if (inboxLink) { + inboxLink.click(); + log(`Step ${step}: Clicked inbox in sidebar`); + await sleep(2000); + } + // Wait for mail list to load let items = findMailItems(); if (items.length === 0) { log(`Step ${step}: Waiting for mail list to appear...`); @@ -156,28 +163,28 @@ async function handlePollEmail(step, payload) { // ============================================================ async function refreshInbox() { - // 163 mail: click the "收信" button in toolbar - function tryRefresh(doc) { - const btn = doc.querySelector( - 'a[title="收信"], [id*="refresh"], .nui-toolbar-item[title*="收"]' - ); - if (btn) { - btn.click(); - console.log(MAIL163_PREFIX, 'Clicked 收信 button'); - return true; + // 163 mail: try the toolbar "刷 新" button first + // Actual DOM:
刷 新
+ const toolbarBtns = document.querySelectorAll('.nui-btn .nui-btn-text'); + for (const btn of toolbarBtns) { + if (btn.textContent.replace(/\s/g, '') === '刷新') { + btn.closest('.nui-btn').click(); + console.log(MAIL163_PREFIX, 'Clicked toolbar "刷新" button'); + await sleep(800); + return; } - return false; } - if (tryRefresh(document)) { await sleep(500); return; } - - // Try in iframes - const iframes = document.querySelectorAll('iframe'); - for (const iframe of iframes) { - try { - const doc = iframe.contentDocument || iframe.contentWindow?.document; - if (doc && tryRefresh(doc)) { await sleep(500); return; } - } catch { } + // Fallback: click the left sidebar "收 信" button + // Actual DOM:
  • 收 信
  • + const shouXinBtns = document.querySelectorAll('.ra0'); + for (const btn of shouXinBtns) { + if (btn.textContent.replace(/\s/g, '').includes('收信')) { + btn.click(); + console.log(MAIL163_PREFIX, 'Clicked sidebar "收信" button'); + await sleep(800); + return; + } } console.log(MAIL163_PREFIX, 'Could not find refresh button');