-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (48 loc) · 1.89 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const fs = require('fs');
const readLastLines = require('read-last-lines');
const puppeteer = require('puppeteer-core');
const { getPlatform } = require('chrome-launcher/dist/utils.js');
const chromeFinder = require('chrome-launcher/dist/chrome-finder.js');
require('lodash.product');
const _ = require('lodash');
(async () => {
const executablePath = process.env.PUPPETEER_EXECUTABLE_PATH || (await(chromeFinder)[getPlatform()]())[0];
if (!executablePath) {
throw new Error('Chrome / Chromium is not installed.');
}
const browser = await puppeteer.launch({executablePath, headless: false});
const page = await browser.newPage();
await page.setViewport({ width: 675, height: 600 });
const letters = "abcdefghijklmnopqrstuvwxyz";
const arr_letters = letters.split('');
const length = 4;
let product = _.product(...Array(length).fill(arr_letters));
let usernames = product.map(x => x.join(''));
await page.goto('https://github.com');
const USERNAME_SELECTOR = '#user\\[login\\]';
await page.click(USERNAME_SELECTOR);
await readLastLines.read('logs/successful.txt', 1)
.then( async (line) => {
if (line === '') line = usernames[0];
usernames = usernames.splice(usernames.indexOf(line) + 1);
for (let i of usernames) {
await page.keyboard.type(i);
await page.waitFor(3000);
let result = await page.$('.is-autocheck-successful');
if (result){
console.log('Successful: ' + i);
fs.appendFile('logs/successful.txt', `\n${i}`, function (err) {
if (err) throw err;
console.log('Saved!');
});
} else {
console.log('Error: ' + i);
}
await page.keyboard.down('Control');
await page.keyboard.press('KeyA');
await page.keyboard.up('Control');
await page.keyboard.press('Backspace');
}
});
// await browser.close();
})();