Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/automation/keywordFollow.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
await sleep(1000);
};

const getBioFromUserCell = (cell) => {
// bio 通常是 dir="auto" 且带 overflow hidden(简介会截断)
const bioDiv = [...cell.querySelectorAll('div[dir="auto"]')]
.find(d => (d.getAttribute('style') || '').includes('overflow: hidden'));
return (bioDiv?.textContent || '').trim();
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a fallback mechanism to improve user bio extraction reliability.

This update introduces getBioFromUserCell, which attempts to locate the bio text by searching for a div[dir="auto"] element with overflow: hidden styling—commonly used for truncated profile descriptions.
If the standard extraction path fails, this method provides an alternative way to retrieve the user’s bio, increasing robustness across different DOM structures and UI variations.


// ============================================
// USER EXTRACTION
// ============================================
Expand All @@ -85,7 +92,7 @@
const displayName = nameEl?.textContent || username;

const bioEl = userCell.querySelector('[data-testid="UserDescription"]');
const bio = bioEl?.textContent || '';
const bio = bioEl?.textContent || getBioFromUserCell(userCell);

// Try to get follower count (might not always be visible)
const statsText = userCell.textContent || '';
Expand Down