-
-
Save vrumger/07874df45dbe998b376961f44dd831b2 to your computer and use it in GitHub Desktop.
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'); | |
})(); |
@itsdarrylnorris I know, I wrote it a while ago and Google has obviously changed their class names. Feel free to inspect the buttons and update it. 🙂
Hey @YouTwitFace , I was able to update the classes to make it work, however it looks like they change it quite often. I think, I am going to write something to search for the button string and try to find the class base on button string, instead of relaying dynamic class.
After submitting the form second this script, if you are not login, Google will ask for phone number to verify you are not a bot and is required. Have you experience this phone verification? And you figure out a way to bypass this verification?
No, I haven't been able to figure out a way around it.
Hey @YouTwitFace
I think there are three possible path to get around that:
- First path: Use a third-party phone system to get a unique phone number. I am currently evaluating if this makes sense / possible or is too expensive.
- Second path: Login to Chorme, and figure out a way to load your user profile into puppetter and this should skip the validation. It looks like is possible with to load the userData. However, I tried and I could not figure out.
- Third path: Similar to path number two but instead of loading the entire user profile via chrome, we will try to copy all the google session cookies and load it in the puppeteer instance.
About the second path, you could use puppeteer-core with the users' global Chrome installation that is already logged in.
its working well but the next screen asking a verification code :(
@lulitha yeah, that's where I stopped writing this.
It does not seems to be working at the moment: