24 lines
941 B
JavaScript
24 lines
941 B
JavaScript
// 直接读评论管理页 DOM
|
|
import { evalViaBridge } from './client.mjs';
|
|
import fs from 'node:fs';
|
|
|
|
await evalViaBridge(`location.href='https://baijiahao.baidu.com/builder/rc/commentmanage/comment/all'`);
|
|
await new Promise(r => setTimeout(r, 12000));
|
|
|
|
const info = await evalViaBridge(`(() => ({
|
|
url: location.href,
|
|
text: (document.body ? document.body.innerText : '').slice(0, 12000),
|
|
// 找置顶标记
|
|
pinnedHints: Array.from(document.querySelectorAll('*'))
|
|
.filter(e => e.children.length === 0)
|
|
.map(e => (e.innerText || '').trim())
|
|
.filter(t => t && (t.includes('置顶') || t.includes('作者')))
|
|
.slice(0, 40)
|
|
}))()`);
|
|
|
|
fs.writeFileSync('out/comment-page.json', JSON.stringify(info, null, 2), 'utf8');
|
|
console.log('URL=' + String(info.url).replace(/[^\x20-\x7E]/g, '?'));
|
|
console.log('TEXTLEN=' + String(info.text).length);
|
|
console.log('PINNED_HINTS=' + (info.pinnedHints || []).length);
|
|
process.exit(0);
|