Skip to content

Commit

Permalink
Update main.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rktst110 authored Mar 11, 2024
1 parent ce35ec3 commit cc79e1e
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,36 @@ if (letMeInLink) {
letMeInButton.scrollIntoView();
}
});

/*
// Click on the link
await Promise.all([
//page.waitForNavigation(), // Wait for navigation to complete
page.click('a[href*="/ghits/"]', { delay: 100 }), // Add a slight delay to allow the click
]);
*/

// Get the bounding box of the button
const buttonBoundingBox = await page.evaluate(() => {
const letMeInButton = document.querySelector('a[href*="/ghits/"]');
const rect = letMeInButton.getBoundingClientRect();
return {
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height
};
});

// Calculate click position relative to the button
const clickX = buttonBoundingBox.x + buttonBoundingBox.width / 2;
const clickY = buttonBoundingBox.y + buttonBoundingBox.height / 2;

// Perform a mouse click at the calculated position
await page.mouse.click(clickX, clickY);


// Take a screenshot
await page.screenshot({ path: 'let_me_in.png', fullPage: true });
//await page.screenshot({ path: 'let_me_in.png', fullPage: true });

console.log('Clicked on "Let me in!" button');
} else {
Expand Down

0 comments on commit cc79e1e

Please sign in to comment.