Skip to content

Commit

Permalink
3.2.2
Browse files Browse the repository at this point in the history
Cookie fetching clicks on cookies accept on YouTube modal.
  • Loading branch information
AlexInCube committed Jul 22, 2024
1 parent 48400be commit 4f05aac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aicbot",
"version": "3.2.1",
"version": "3.2.2",
"description": "Discord Bot for playing music",
"main": "build/main.js",
"scripts": {
Expand Down
12 changes: 9 additions & 3 deletions src/CookiesAutomation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ export async function getYoutubeCookie() {
const page = await browser.newPage();
await page.goto('https://www.youtube.com', { waitUntil: 'networkidle2' });

// Press "Sign In" button on YouTube
await page.click('#buttons > ytd-button-renderer > yt-button-shape > a');

try {
// Press "Sign In" button on YouTube in accept cookie usage
await page.click(
'#topbar > div.top-buttons.style-scope.ytd-consent-bump-v2-lightbox > div:nth-child(2) > ytd-button-renderer > yt-button-shape > a'
);
} catch (e) {
// Press "Sign In" on navbar
await page.click('#buttons > ytd-button-renderer > yt-button-shape > a');
}
// Type Email in form
await page.waitForSelector('#identifierId', { visible: true });
await page.type('#identifierId', ENV.BOT_GOOGLE_EMAIL);
Expand Down

0 comments on commit 4f05aac

Please sign in to comment.