-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
146 lines (116 loc) · 4.77 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
// Requires
var casper = require('casper').create({
verbose: false,
logLevel: "debug"
});
var nicknames = require('./nicknames.json');
var fs = require('fs');
// Settings
var start = 0; // Start from x (NAMEx, [email protected])
var end = 10; // Up to x, but not including (exclusive)
var useNicknamesFile = false; // Use nicknames file, or just append numbers to username?
var useRandomPassword = true; // Generate a random password?
var outputFile = 'accounts.txt'; // File which will contain the generated "username password" combinations.
var outputFormat = '%NICK% %PASS%\r\n'; // Format used to save the account data in outputFile. Supports %NICK%, %PASS%.
var country = 'US'; // Country code (BE, NL, FR, ...)
var dob = '1990-12-30'; // Date of birth, YYYY-mm-dd
var username = 'user'; // User- & display name. Make sure any "(username + number)@domain.com" is 100% unique.
var password = 'pass'; // Static password for all accounts. Ignored if useRandomPassword is true.
var email_user = 'email'; // If your email is [email protected], enter "email"
var email_domain = 'domain.com'; // Domain of e-mail host
// App data
var url_ptc = 'https://club.pokemon.com/us/pokemon-trainer-club/sign-up/';
// Settings check
if (!useNicknamesFile && (username + end).length > 16) {
console.log("Error: length of username + number can't be longer than 16 characters.");
console.log("Please use a shorter nickname.");
process.exit();
}
if ((email_user + '+' + username + end + '@' + email_domain).length > 75) {
console.log("Error: length of e-mail address including the + trick can't be longer than 75 characters.");
console.log("Please use a shorter e-mail address and/or nickname.");
process.exit();
}
if (!useRandomPassword && password.length > 15) {
console.log("Error: length of password can't be longer than 15 characters.");
console.log("Please use a shorter password.");
process.exit();
}
// LETSAHGO
casper.start();
casper.on('complete.error', function(err) {
this.echo("Complete callback has failed: " + err);
});
casper.on('error', function(msg, trace) {
this.echo("Err: " + msg, "ERROR");
});
casper.on("page.error", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
});
console.log('[o] Starting ' + start + ' to ' + (end - 1) + '.');
for(var i = start; i < end; i++) {
(function(ctr) {
casper.thenOpen(url_ptc, handleDobPage.bind(casper, ctr)).then(handleSignupPage.bind(casper, ctr)).then(handleFinished.bind(casper, ctr));
})(i);
}
casper.run();
function randomPassword() {
return Math.random().toString(36).substr(2, 8);
}
// Pages
function handleDobPage(ctr) {
this.echo('[' + ctr + '] First Page: ' + this.getTitle());
this.fill('form[name="verify-age"]', {
'dob': dob,
'country': country
}, true);
}
function handleSignupPage(ctr) {
// Server sometimes messes up and redirects us to the verify-age page again
if(this.exists('form[name="verify-age"]')) {
this.echo('[' + ctr + '] Server is acting up. Retrying...');
handleDobPage.call(this, ctr);
this.then(handleSignupPage.bind(casper, ctr));
return;
}
// OK we're on the right page
var _pass = password;
var _nick = username + ctr;
var formdata = {
'terms': true
};
this.echo('[' + ctr + '] Second Page: ' + this.getTitle());
// Random password?
if(useRandomPassword) {
_pass = randomPassword();
}
// Use nicknames list, or (username + number) combo?
if(useNicknamesFile) {
// Make sure we have a nickname left
if(nicknames.length < 1) {
throw Error("We're out of nicknames to use!");
}
// Get the first nickname off the list & use it
_nick = nicknames.shift();
formdata['username'] = _nick;
formdata['screen_name'] = _nick;
formdata['email'] = email_user + '+' + _nick + '@' + email_domain;
formdata['confirm_email'] = email_user + '+' + _nick + '@' + email_domain;
} else {
// Use username & counter
formdata['username'] = _nick;
formdata['screen_name'] = _nick;
formdata['email'] = email_user + '+' + ctr + '@' + email_domain;
formdata['confirm_email'] = email_user + '+' + ctr + '@' + email_domain;
}
// Log it in the file of used nicknames
var content = outputFormat.replace('%NICK%', _nick).replace('%PASS%', _pass);
fs.write(outputFile, content, 'a');
formdata['password'] = _pass;
formdata['confirm_password'] = _pass;
// Fill & submit
this.fill('form#user-signup-create-account-form', formdata, true);
}
function handleFinished(ctr) {
this.echo('Finished ' + ctr + '.');
}