Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions src/clis/twitter/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ cli({
],
columns: ['id', 'action', 'author', 'text', 'url'],
func: async (page, kwargs) => {
// Install the interceptor before loading the notifications page so we
// capture the initial timeline request triggered during page load.
await page.goto('https://x.com');
await page.wait(2);
await page.installInterceptor('NotificationsTimeline');

// 1. Navigate to notifications
// 1. Navigate directly to notifications
await page.goto('https://x.com/notifications');
await page.wait(5);
await page.wait(3);

// 2. Install interceptor after page load (must be after goto, not before,
// because goto triggers a full navigation that resets the JS context).
// Note: this misses the initial request fired during hydration;
// we rely on scroll-triggered pagination to capture data.
await page.installInterceptor('NotificationsTimeline');

// 3. Trigger API by scrolling (if we need to load more)
// 3. Scroll to trigger API calls (load more notifications)
await page.autoScroll({ times: 2, delayMs: 2000 });

// 4. Retrieve data
Expand Down
18 changes: 9 additions & 9 deletions src/clis/twitter/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ cli({
],
columns: ['id', 'author', 'text', 'likes', 'views', 'url'],
func: async (page, kwargs) => {
// Install the interceptor before opening the target page so we don't miss
// the initial SearchTimeline request fired during hydration.
await page.goto('https://x.com');
await page.wait(2);
await page.installInterceptor('SearchTimeline');

// 1. Navigate to the search page
// 1. Navigate directly to the search page
const q = encodeURIComponent(kwargs.query);
await page.goto(`https://x.com/search?q=${q}&f=top`);
await page.wait(5);
await page.wait(3);

// 2. Install interceptor after page load (must be after goto, not before,
// because goto triggers a full navigation that resets the JS context).
// Note: this misses the initial SearchTimeline request fired during
// hydration; we rely on scroll-triggered pagination to capture data.
await page.installInterceptor('SearchTimeline');

// 3. Trigger API by scrolling
// 3. Scroll to trigger SearchTimeline API calls (pagination)
await page.autoScroll({ times: 3, delayMs: 2000 });

// 4. Retrieve data
Expand Down
Loading