MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / shouldSkipTwitterElement

Function shouldSkipTwitterElement

entrypoints/main/compat.ts:574–692  ·  view source on GitHub ↗

* 判断是否应该跳过Twitter网站上的特定元素

(node: any)

Source from the content-addressed store, hash-verified

572 * 判断是否应该跳过Twitter网站上的特定元素
573 */
574function shouldSkipTwitterElement(node: any): boolean {
575 // 检查是否为特殊内容(URL、邮箱、用户名等)
576 if (node.textContent && isSpecialContent(node.textContent)) {
577 debugLog('Twitter', '特殊内容', node.textContent);
578 return true;
579 }
580
581 // 如果当前节点或其祖先节点匹配这些选择器,则跳过
582 const skipSelectors = [
583 // 侧边栏导航
584 // 'nav[aria-label="Primary"]',
585 'div[data-testid="sidebarColumn"]',
586 // 趋势栏
587 'div[aria-label="Timeline: Trending now"]',
588 'aside[aria-label="Who to follow"]',
589 // 搜索栏
590 'div[data-testid="SearchBox_Search_Input"]',
591 // 各种按钮和UI元素
592 'div[role="button"]',
593 'div[data-testid="BottomBar"]',
594 // 未展开的帖子操作区域
595 'div[role="group"][aria-label]',
596 // 推荐关注
597 'div[data-testid="suggestedUserHover"]',
598 // 各种图标和操作按钮
599 'div[aria-label*="icon"]',
600 'div[data-testid*="icon"]',
601 // 顶部应用栏
602 'header[role="banner"]',
603 // 字数限制计数器
604 'div[data-testid="characterCount"]',
605 // 用户名称相关
606 'div[data-testid="User-Name"]',
607 'div[data-testid="UserName"]',
608 'span[data-testid="tweetText"] span.r-bcqeeo',
609 // 用户ID和用户名相关
610 'div[data-testid="HoverCard"]',
611 'div[data-testid="UserCell"]',
612 'a[role="link"][href*="/status/"]',
613 // 关注按钮
614 'div[role="button"][data-testid="follow"]',
615 'div[role="button"][data-testid="unfollow"]',
616 // 包含"关注"文本的元素
617 'div[dir="auto"][id^="id__"]'
618 ];
619
620 // 检查当前节点是否匹配跳过选择器
621 for (const selector of skipSelectors) {
622 if (node.matches?.(selector)) {
623 debugLog('Twitter', '选择器匹配跳过', selector, node.textContent);
624 return true;
625 }
626 }
627
628 // 检查节点的类名、属性等特征
629 const nodeTag = node.tagName?.toLowerCase();
630 if (nodeTag === 'svg' || nodeTag === 'path' || nodeTag === 'g') {
631 debugLog('Twitter', 'SVG元素跳过', node.textContent);

Callers 1

compat.tsFile · 0.85

Calls 2

isSpecialContentFunction · 0.85
debugLogFunction · 0.85

Tested by

no test coverage detected