INNER CODE UNIT · TypeScript
collectContent
RyanYipeng/SyncCaster · apps/extension/src/content-scripts/index.ts:487
async function collectContent() {
try {
logInfo('collect', '开始采集页面内容', { url: window.location.href });
const url = window.location.href;
const hostname = window.location.hostname;
// 从原始 DOM 提取公式
const formulaMap = extractFormulasFromOriginalDom();
logInfo('collect', '从原始 DOM 提取公式', { count: formulaMap.size });
// 平台专用内容选择器
const getPlatformContent = (): HTMLElement | null => {
// CSDN 专用选择器 - 只选择正文内容区域
if (hostname.includes('csdn.net')) {
const csdnContent = document.querySelector('#content_views') as HTMLElement;
if (csdnContent) return csdnContent;
const articleContent = document.querySelector('.article_content') as HTMLElement;
if (articleContent) return articleContent;