2026-11-09 09:18:58 +08:00
|
|
|
|
// 探针:连接已打开的 Edge,把每个 goofish 页面的候选"未读"元素打印/保存出来。
|
|
|
|
|
|
// 用法: node probe.js [输出文件]
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
const path = require('path');
|
|
|
|
|
|
const { CDP, listPages, EXPR } = require('./cdp');
|
|
|
|
|
|
|
2026-11-09 09:21:06 +08:00
|
|
|
|
const cfg = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'), 'utf8').replace(/^\uFEFF/, ''));
|
2026-11-09 09:18:58 +08:00
|
|
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
|
|
const outFile = process.argv[2] || path.join(__dirname, 'probe-result.json');
|
|
|
|
|
|
let pages;
|
|
|
|
|
|
try {
|
|
|
|
|
|
pages = await listPages(cfg.debugPort, cfg.urlMatch);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error(`无法连接调试端口 ${cfg.debugPort}:${e.message}`);
|
|
|
|
|
|
console.error('请先双击 launch-edge.bat 启动 Edge,并在那个窗口登录闲鱼、打开消息页。');
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!pages.length) {
|
|
|
|
|
|
console.error(`没有找到包含 "${cfg.urlMatch}" 的标签页。请在启动的 Edge 窗口里打开 seller.goofish.com 消息页。`);
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const results = [];
|
|
|
|
|
|
for (const p of pages) {
|
|
|
|
|
|
const cdp = new CDP(p.webSocketDebuggerUrl);
|
|
|
|
|
|
try {
|
|
|
|
|
|
await cdp.connect();
|
|
|
|
|
|
const st = await cdp.eval(EXPR);
|
|
|
|
|
|
results.push(st);
|
|
|
|
|
|
console.log('='.repeat(70));
|
|
|
|
|
|
console.log('URL :', st.url);
|
|
|
|
|
|
console.log('TITLE :', st.title);
|
|
|
|
|
|
console.log('DOM :', st.domSize, ' nodes, visibility:', st.visible);
|
|
|
|
|
|
console.log('红点候选 badges:', st.badges.length);
|
|
|
|
|
|
st.badges.slice(0, 40).forEach(b => {
|
|
|
|
|
|
console.log(` ${b.red ? '[RED]' : '[ ]'} "${b.t}" fs=${b.fs} bg=${b.bg} rect=${b.rect}`);
|
|
|
|
|
|
console.log(` ${b.p}`);
|
|
|
|
|
|
console.log(` parentText: ${JSON.stringify(b.parentText)}`);
|
|
|
|
|
|
});
|
|
|
|
|
|
console.log('class 命中:', st.classHits.length);
|
|
|
|
|
|
st.classHits.slice(0, 25).forEach(h => {
|
|
|
|
|
|
console.log(` "${h.t}" cls=${h.cls} rect=${h.rect}`);
|
|
|
|
|
|
console.log(` ${h.p}`);
|
|
|
|
|
|
});
|
|
|
|
|
|
console.log('title 内数字:', JSON.stringify(st.titleNumbers));
|
|
|
|
|
|
if (st.iframes.length) console.log('iframes:', JSON.stringify(st.iframes));
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error('探针失败:', p.url, e.message);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
cdp.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
fs.writeFileSync(outFile, JSON.stringify(results, null, 2), 'utf8');
|
|
|
|
|
|
console.log('\n完整结果已保存:', outFile);
|
|
|
|
|
|
})();
|