Skip to content
Merged
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
16 changes: 10 additions & 6 deletions scripts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ async function getImageLinksPlaywright(url: string): Promise<string[]> {
timeout: 60000,
});

console.log("Waiting for network idle...");
await page.waitForLoadState("networkidle");
console.log("Page loaded.");
console.log("Waiting for image grid to be visible...");
await page.waitForSelector(
'img[src^="https://images.pexels.com/photos/"]',
{
state: "visible",
timeout: 60000,
},
);
Comment on lines +80 to +86
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

The hardcoded URL prefix 'https://images.pexels.com/photos/' creates tight coupling to a specific domain. Consider extracting this as a configuration constant or parameter to improve maintainability and reusability.

Copilot uses AI. Check for mistakes.
console.log("Page content is ready.");

const maxClicks = 5;
let clickCount = 0;
Expand All @@ -94,9 +100,7 @@ async function getImageLinksPlaywright(url: string): Promise<string[]> {
);
clickCount++;
await loadMoreButton.click();

// Wait for new content to load
await page.waitForLoadState("networkidle");
await page.waitForTimeout(5000);
Comment on lines 102 to +103
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

Fixed timeout delays can be inefficient and unreliable. Consider using a more robust waiting strategy like page.waitForSelector() with a specific selector for newly loaded images, or page.waitForFunction() to wait for a condition that indicates new content has loaded.

Copilot uses AI. Check for mistakes.
console.log("New content loaded after clicking Load More.");
} catch (error) {
console.error(`Error clicking button: ${error}`);
Expand Down