Skip to content

Instantly share code, notes, and snippets.

@Sapistudio
Forked from jamesandariese/google.js
Created March 18, 2021 23:48
Show Gist options
  • Save Sapistudio/9e4da054a6a47049c7eeba070771ffb6 to your computer and use it in GitHub Desktop.
Save Sapistudio/9e4da054a6a47049c7eeba070771ffb6 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.$x("//div[contains(., \"Create account\") and @role=\"button\"]").click()
]);
// 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');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment