Skip to content

Instantly share code, notes, and snippets.

@vrumger
Last active November 20, 2023 15:59
Show Gist options
  • Save vrumger/07874df45dbe998b376961f44dd831b2 to your computer and use it in GitHub Desktop.
Save vrumger/07874df45dbe998b376961f44dd831b2 to your computer and use it in GitHub Desktop.
Create a google account and go to youtube with puppeteer.
const puppeteer = require('puppeteer');
const uuid = require('uuid');
const sleep = ms => new Promise(r => setTimeout(r, ms));
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
const id = uuid.v4();
const [firstName, lastName] = id.split('-');
const username = id.slice(0, 30).replace(/-/g, '.');
const password = `${id}123!`;
await page.goto('https://accounts.google.com/signin/v2/identifier?hl=en&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fhl%3Den%26next%3D%252F%26app%3Ddesktop%26action_handle_signin%3Dtrue&passive=true&service=youtube&uilel=3&flowName=GlifWebSignIn&flowEntry=ServiceLogin');
// Click "Create an account"
await Promise.all([
page.waitForNavigation(),
page.click('.U26fgb.O0WRkf.oG5Srb.HQ8yf.C0oVfc.nDKKZc.NpwL8d.t29vte.G3hhxb'),
]);
// Wait for page to load
await sleep(1000);
// Click "Create a Gmail account instead"
await page.tap('.uBOgn');
await page.type('#firstName', firstName);
await page.type('#lastName', lastName);
await page.type('#username', username);
await page.type('input[type="password"][name="Passwd"]', password);
await page.type('input[type="password"][name="ConfirmPasswd"]', password);
// Click "Next"
await page.tap('#accountDetailsNext');
})();
@lulitha
Copy link

lulitha commented May 1, 2021

its working well but the next screen asking a verification code :(

@vrumger
Copy link
Author

vrumger commented May 2, 2021

@lulitha yeah, that's where I stopped writing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment