This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
starwars.js
133 lines (104 loc) · 4.48 KB
/
starwars.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const {
Builder,
By,
Key,
until
} = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const MailosaurClient = require('mailosaur');
const cheerio = require('cheerio');
const fs = require('fs');
var twoFAcode = '';
var twofaid = '';
let driver;
var email;
var password;
var account;
var civ6account;
var oldacc;
var contents = fs.readFileSync("config/credentials.json").toString();
var credentials = JSON.parse(contents);
const client = new MailosaurClient(credentials.apikey);
const SERVER_ID = credentials.serverId;
register();
function register() {
civ6account = fs.readFileSync("output/starwars_accounts.txt").toString();
oldacc = fs.readFileSync("output/accounts.txt").toString();
oldacc = oldacc.split(/\s*[\n:]+\s*/);
for (i = credentials.accountctr; i < oldacc.length; i++) {
oldacc[i] = oldacc[i].replace("(incomplete)", "")
}
email = oldacc[credentials.accountctr];
password = oldacc[credentials.accountctr + 1];
(async () => {
var options = new chrome.Options();
options.addArguments('disable-gpu');
options.addArguments("--lang=en-US");
try {
driver = new Builder().forBrowser('chrome').setChromeOptions(options).build();
var date = new Date(Date.now())
await driver.get('https://www.epicgames.com/id/login?lang=en_US');
await driver.wait(until.titleIs('Sign in to Your Epic Games Account | Epic Games'), 5000);
if (driver.wait(until.elementLocated(By.id('login-with-epic')), 150000)) {
await driver.findElement(By.id('login-with-epic')).click();
}
await driver.findElement(By.name('usernameOrEmail')).sendKeys(email);
await driver.findElement(By.name('password')).sendKeys(password);
var butones = await driver.findElement(By.className('MuiButton-fullWidth'));
await driver.wait(until.elementIsEnabled(butones), 150000);
await butones.click();
twoFAcode = await verify2FA(date);
await console.log(twoFAcode);
await driver.findElement(By.name('code')).sendKeys(twoFAcode);
var continueBtn = await driver.findElement(By.id('continue'));
await driver.wait(until.elementIsEnabled(continueBtn), 150000);
await continueBtn.click();
await driver.wait(until.titleIs('Personal Details'), 150000);
await driver.sleep(1300);
await driver.get('https://www.epicgames.com/store/purchase?namespace=b156c3365a5b4cb9a01a5e1108b4e3f4&showNavigation=true&highlightColor=0078f2&offers=ea7721c6c2694e72813d3661bc68a2cb');
await driver.wait(until.elementLocated(By.xpath("//*[@id='purchase-app']/div/div[4]/div[1]/div[2]/div[5]/div/div/button/span")), 150000);
await driver.sleep(1000);
await driver.findElement(By.xpath("//*[@id='purchase-app']/div/div[4]/div[1]/div[2]/div[5]/div/div/button/span")).click();
await driver.sleep(1000);
try {
await driver.wait(until.elementLocated(By.xpath("//*[@id='purchase-app']/div/div[4]/div[1]/div[2]/div[6]/div[2]/div/div[2]/button[2]")), 2500);
await driver.findElement(By.xpath("//*[@id='purchase-app']/div/div[4]/div[1]/div[2]/div[6]/div[2]/div/div[2]/button[2]")).click();
} catch (e) {
var foo = 'bar';
}
await driver.wait(until.elementLocated(By.className('receipt-container')), 100000);
account = '\n' + email + ":" + password;
fs.writeFileSync("ark_accounts.txt", civ6account + account)
credentials.accountctr += 2;
fs.writeFileSync("credentials.json", JSON.stringify(credentials))
} //try block
catch (e) { // catch block
console.log(e);
account = email + ":" + password + "(incomplete)\n";
fs.writeFileSync("starwars_accounts.txt", civ6account + account)
} finally {
await driver.manage().deleteAllCookies()
await driver.close();
await register();
}
})();
}
async function verify2FA(date) {
try {
console.log("Getting 2FA Email Code .....");
var results = await client.messages.search(SERVER_ID, {
subject: "Your two-factor sign in code"
}, {
receivedAfter: date,
itemsPerPage: 200,
timeout: 60000
});
twofaid = await results.items[0].id;
let message = await client.messages.getById(twofaid);
const $ = cheerio.load(message.html.body);
var result = $('body > table > tbody > tr > td > center > table > tbody > tr > td > table:nth-child(4) > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-child(3) > td > div').text().trim();
return result;
} catch (e) {
console.log(e);
}
}