fix: update 163 mail - click inbox first, correct refresh selectors

- 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
This commit is contained in:
unknown
2026-04-05 10:02:15 +08:00
parent c6f1070ace
commit 7cc7c91bf3
2 changed files with 29 additions and 22 deletions
+1 -1
View File
@@ -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' };
}
+28 -21
View File
@@ -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: <div class="js-component-button nui-btn"><span class="nui-btn-text">刷 新</span></div>
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: <li class="ra0 nb0"><span class="oz0">收 信</span></li>
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');