-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathgolden_key_redeem.js
180 lines (148 loc) · 5.7 KB
/
golden_key_redeem.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
WIP not ready for use! Lots of old/recycled variables, code not finished
*/
var badcodes = [];
var pointsredeemed = [];
var points = 0;
var temppoints;
var totalpointsredeemed = 0;
var emailpointsredeemed = 0;
var creatorpointsredeemed = 0;
var vaultpointsredeemed = 0;
var emailpoints;
var creatorpoints;
var vaultpoints;
var USERNAME = 'SOMEUSER';
var PASSWORD = 'SOMEPASSWORD';
var apibase = 'https://api.2k.com/borderlands/code';
async function httppost(codeinfo) {
var response = await fetch(apibase + codeinfo.cid, {
method: 'POST',
mode: 'cors',
body: JSON.stringify({
code: codeinfo.code
}),
headers: {
'Content-type' : 'application/json'
}
})
let result = await response.json();
if (result.points) {
pointsredeemed.push(result.points);
temppoints = result.points;
return temppoints;
} else {
badcodes.push(codeinfo.code);
return null;
}
return null;
}
var vaultcid = 5261;
var emailcid = 5264;
var creatorcid = 5263;
var boostcid = 5721;
var BL2XBOX = [
"CT533-XZZ65-Z9FX9-CRT3J-S9X65",
"5TWBT-Z9HRK-9HRXZ-W6BTB-CZH39",
"KTCJJ-CJBSK-SS6XH-C6TJB-F6BFB",
"C3CT3-TB39C-9S6FS-WRT3B-SS9R3"
]
async function emailmap() {
emailpoints = await Promise.all(EMAILS.map(async function(email) {
var type = {
code : email,
cid : emailcid
};
temppoints = await httppost(type);
emailpointsredeemed = emailpointsredeemed + temppoints;
return emailpointsredeemed;
}))};
async function creatorsmap() {
creatorspoints = await Promise.all(CREATORS.map(async function(creator) {
var type = {
code : creator,
cid : creatorcid
};
temppoints = await httppost(type);
creatorpointsredeemed = creatorpointsredeemed + temppoints;
return creatorpointsredeemed;
}))};
async function vaultmap() {
vaultpoints = await Promise.all(VAULTS.map(async function(vault) {
var type = {
code : vault,
cid : vaultcid
};
temppoints = await httppost(type);
vaultpointsredeemed = vaultpointsredeemed + temppoints;
return vaultpointsredeemed;
}))}
async function gatherpoints() {
var [totalemailpoints, totalcreatorpoints, totalvaultpoints] = await Promise.all([emailmap(), creatorsmap(), vaultmap()]);
var totalpoints = emailpointsredeemed + creatorpointsredeemed + vaultpointsredeemed;
console.log("Total Points: ", totalpoints);
alert("Total Points Redeemed: " + totalpoints)
}
async function main() {
await tryGetLatestCodes();
gatherpoints();
}
async function login() {
var response = await fetch('https://api.2k.com/borderlands/users/authenticate', {
method: 'POST',
mode: 'cors',
headers: {
'Content-type' : 'application/json',
'Origin' : 'https://borderlands.com'
},
body: JSON.stringify({
username : USERNAME,
password : PASSWORD
})
})
console.log(response.headers.get('x-session-set')); // This is key, this is required in order to move to the next step; without this, you're unable to authenticate your account to submit/redeem codes
}
async function test() {
await login();
var response = await fetch(apibase + '/CT533-XZZ65-Z9FX9-CRT3J-S9X65/info', {
method: 'GET',
mode: 'cors',
headers: {
'Content-type' : 'application/json',
'Origin' : 'https://borderlands.com',
'Referer' : 'https://borderlands.com/en-US/vip'
}
});
console.log(await response.json());
console.log(response)
}
//main();
test();
/*
await fetch('https://2kgames.crowdtwist.com/code-redemption-campaign/redeem?cid=5263', {
method: 'POST',
body: JSON.stringify({
code: "GREGORONKH"
}),
headers: {
'Content-type' : 'application/json'
}
})
*/
/* MISC Golden Keys Notes:
Order of events:
Checks the key if it's valid
https://api.2k.com/borderlands/code/5T5B3-CWJSK-KRTJT-TTJJT-9HW63/info
'fetch("https://api.2k.com/borderlands/code/5T5B3-CWJSK-KRTJT-TTJJT-9HW63/info", {"credentials":"omit","headers":{"accept":"application/json, text/plain, ...","sec-fetch-mode":"cors","x-session":"supersecret.supersecret.supersecret-supersecret"},"referrer":"https://borderlands.com/en-US/vip-codes/","referrerPolicy":"no-referrer-when-downgrade","body":null,"method":"GET","mode":"cors"});'
{"entitlement_offer_codes":[{"code":"5T5B3-CWJSK-KRTJT-TTJJT-9HW63","max_redeemable":2000000,"amount_redeemed":1152284,"start_date":null,"end_date":null,"offer_title_text":"Borderlands 2 Golden Key","offer_description_text":"You have unlocked a Borderlands 2 Golden Key! You can use your Golden Key on the mysterious loot chest located in Sanctuary to receive a rare powerful item!","offer_service":"steam","offer_title":"willow2","offer_id":2,"is_active":true}]}
Golden Key Redeem Steam:
Request URL: https://api.2k.com/borderlands/code/5T5B3-CWJSK-KRTJT-TTJJT-9HW63/redeem/steam
fetch("https://api.2k.com/borderlands/code/5T5B3-CWJSK-KRTJT-TTJJT-9HW63/redeem/xboxlive", {"credentials":"omit","headers":{"accept":"application/json, text/plain, ...","sec-fetch-mode":"cors","x-session":"supersecret.supersecret.supersecret-supersecret"},"referrer":"https://borderlands.com/en-US/vip-codes/","referrerPolicy":"no-referrer-when-downgrade","body":null,"method":"POST","mode":"cors"});
Response:
{"message":"REDEMPTION_QUEUED","job_id":"UNIQUE-JOB-ID","min_wait_milliseconds":750,"max_wait_milliseconds":1000,"max_retry_attempts":5}
Checks status of the job:
https://api.2k.com/borderlands/code/5T5B3-CWJSK-KRTJT-TTJJT-9HW63/job/UNIQUE-JOB-ID
{"success":true}
fetch("https://api.2k.com/borderlands/code/5T5B3-CWJSK-KRTJT-TTJJT-9HW63/job/UNIQUE-JOB-ID", {"credentials":"omit","headers":{"accept":"application/json, text/plain, ...","sec-fetch-mode":"cors","x-session":"supersecret.supersecret.supersecret-supersecret"},"referrer":"https://borderlands.com/en-US/vip-codes/","referrerPolicy":"no-referrer-when-downgrade","body":null,"method":"GET","mode":"cors"});
d
*/