-
Notifications
You must be signed in to change notification settings - Fork 4
/
old.js
331 lines (282 loc) · 10.5 KB
/
old.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
import https from "https";
import chalk from "chalk";
import querystring from "querystring";
import authConfig from "./auth/credentials.js";
import tapsConfig from "./config/config.js";
import fs from "fs";
import axios from 'axios';
import { JSDOM } from 'jsdom';
function Errors(text) {
return chalk.red(text);
}
function Success(text) {
return chalk.green(text);
}
const LoginEndpoint = "https://api.tapswap.ai/api/account/login";
const SendTapsEndpoint = "https://api.tapswap.ai/api/player/submit_taps";
const ApplyBoostEndpoint = "https://api.tapswap.ai/api/player/apply_boost";
function getFormattedTime() {
return new Date().toLocaleString('en-US', {
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
hour12: true,
});
}
function delay(time) {
return new Promise(function (resolve) {
setTimeout(resolve, time);
});
}
function extractChqResult(chq) {
let len = chq.length;
let bytesArray = new Uint8Array(len / 2);
let x = 157;
for (let i = 0; i < len; i += 2) {
bytesArray[i / 2] = parseInt(chq.substring(i, i + 2), 16);
}
let xored = new Uint8Array(bytesArray.length);
for (let i = 0; i < bytesArray.length; i++) {
xored[i] = bytesArray[i] ^ x;
}
let decoded = new TextDecoder().decode(xored);
let jsCode = decoded.split('try {eval("document.getElementById");} catch {return 0xC0FEBABE;}')[1].split('})')[0].trim();
return runCodeAndCalculateResult(jsCode);
}
function extractCodesFromHtml(html) {
const dom = new JSDOM(html);
const document = dom.window.document;
const divElements = document.querySelectorAll('div');
let codes = {};
divElements.forEach(div => {
if (div.id && div.getAttribute('_d_')) {
codes[div.id] = div.getAttribute('_d_');
}
});
return codes;
}
function runCodeAndCalculateResult(code) {
let rtElementContent = code.split('rt["inner" + "HTM" + "L"] = ')[1].split('\n')[0];
let codes = extractCodesFromHtml(rtElementContent);
let va, vb;
for (let [k, v] of Object.entries(codes)) {
if (code.split('\n')[5].includes(k)) {
va = v;
}
if (code.split('\n')[6].includes(k)) {
vb = v;
}
}
let codeToExecute = code.split('return ')[1].split(';')[0];
codeToExecute = codeToExecute.replace('va', va).replace('vb', vb);
// Note: Using eval can be risky. Consider refactoring this if possible.
return eval(codeToExecute);
}
async function authenticate() {
const user = {
id: authConfig.user_id,
first_name: authConfig.first_name,
last_name: authConfig.last_name,
username: authConfig.username,
language_code: authConfig.language_code,
allows_write_to_pm: authConfig.allows_write_to_pm,
};
const init_data = querystring.stringify({
query_id: authConfig.query_id,
user: JSON.stringify(user),
auth_date: authConfig.auth_date,
hash: authConfig.hash,
});
const data = JSON.stringify({
init_data: init_data,
referrer: "",
bot_key: "app_bot_0",
});
const headers = {
'Host': 'api.tapswap.ai',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Referer': 'https://app.tapswap.club/',
'Content-Type': 'application/json',
'x-app': 'tapswap_server',
'x-bot': 'no',
'x-cv': '622',
'Origin': 'https://app.tapswap.club',
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'Priority': 'u=4'
}
try {
const response = await axios.post(LoginEndpoint, data, { headers });
const formattedTime = getFormattedTime();
if (response.status >= 200 && response.status < 400) {
if (response.data && response.data.chq) {
const chq = response.data.chq;
const decodedResult = extractChqResult(chq);
console.log(Success('Decoded CHQ Result:'), decodedResult);
const secondData = JSON.stringify({
init_data: init_data,
referrer: "",
bot_key: "app_bot_0",
chr: decodedResult
});
const secondResponse = await axios.post(LoginEndpoint, secondData, { headers });
//console.log(Success('Second Login Response:'), secondResponse.data);
if (secondResponse.statusCode >= 200 && secondResponse.statusCode < 400) {
console.log(`${formattedTime} ==> | ${Success("Success")} | Authenticated Successfully ✔️`);
} else {
console.error(`${formattedTime} ==> | ${Errors("Error ⚠️")} | Unauthorized ❌`);
}
const accessToken = secondResponse.data.access_token;
if (accessToken) {
const coinsPerCycle = parseInt(tapsConfig.coinsPerCycle);
const cycleDuration = parseInt(tapsConfig.cycleDuration);
const cyclesPerDay = Math.floor(86400 / cycleDuration);
const totalCoinsPerDay = coinsPerCycle * cyclesPerDay;
console.log(`Total Coins To Earn Per Day: ${totalCoinsPerDay}`);
const responseData2 = secondResponse.data;
if (responseData2.player && responseData2.player.boost) {
const boosts = responseData2.player.boost;
responseData2.player.boost1 = boosts[0];
responseData2.player.boost2 = boosts[1];
console.log('Boost 1:', responseData2.player.boost1);
console.log('Boost 2:', responseData2.player.boost2);
// Check and apply boosts
if (responseData2.player.boost1.cnt > 0) {
activateBoostsPeriodically(accessToken, responseData2.player.boost1);
}
if (responseData2.player.boost2.cnt > 0) {
activateBoostsPeriodically(accessToken, responseData2.player.boost2);
}
}
sendTapsPeriodically(accessToken);
}
} else {
console.log(Errors('CHQ field not found in the response:'), response.data);
}
} else {
console.error(`${formattedTime} ==> | ${Errors("Error ⚠️")} | Unauthorized ❌`);
}
} catch (error) {
console.error(Errors('Error:'), error);
}
}
const date = new Date();
const timex = Math.floor(date.getTime());
let result = timex * authConfig.user_id;
result = result * authConfig.user_id;
result = result / authConfig.user_id;
result = result % authConfig.user_id;
result = result % authConfig.user_id;
const contentId = parseInt(result);
console.log("==> | Successfully Generated | Content-Id: |", contentId);
async function sendTaps(accessToken, boostActive) {
const requestBody = {
taps: boostActive ? 100 : 2,
time: timex,
};
const headers = {
Host: "api.tapswap.ai",
"User-Agent":
"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1",
Accept: "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br, zstd",
Referer: "https://app.tapswap.club/",
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
"x-app": "tapswap_server",
"x-bot": "no",
"x-cv": "622",
"Content-Id": `${contentId}`,
Origin: "https://app.tapswap.club",
Connection: "keep-alive",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
Priority: "u=4",
};
try {
const response = await axios.post(SendTapsEndpoint, requestBody, { headers });
const formattedTime = getFormattedTime();
if (response.status >= 200 && response.status < 400) {
console.log(`${formattedTime} ==> | ${Success("Success")} | Taps Sent Successfully ✔️`);
} else {
console.error(`${formattedTime} ==> | ${Errors("Error ⚠️")} | Failed to Send Taps ❌`);
}
} catch (error) {
console.error('Error:', error.response ? error.response.data : error.message);
}
}
async function applyBoost(accessToken, boostType) {
const boostBody = { type: boostType };
const headers = {
Host: "api.tapswap.ai",
"User-Agent":
"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1",
Accept: "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br, zstd",
Referer: "https://app.tapswap.club/",
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
"x-app": "tapswap_server",
"x-bot": "no",
"x-cv": "610",
Origin: "https://app.tapswap.club",
Connection: "keep-alive",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
Priority: "u=1",
};
try {
const formattedTime = getFormattedTime();
const response = await axios.post(ApplyBoostEndpoint, boostBody, { headers });
if (response.status >= 200 && response.status < 400) {
console.log(`${formattedTime} ==> | ${Success("Success")} | ${boostType.charAt(0).toUpperCase() + boostType.slice(1)} Boost Activated Successfully ✔️`);
// Start sending boosted taps 🗲
let boostActive = true;
const endTime = Date.now() + 22000; // 🗲 Boost duration of 22 seconds
while (Date.now() < endTime) {
await sendTaps(accessToken, boostActive);
await delay(1000); // Send 🗲 boosted taps every second
}
boostActive = false;
} else {
console.error(`${formattedTime} ==> | ${Errors("Error ⚠️")} | Failed To Activate ${boostType.charAt(0).toUpperCase() + boostType.slice(1)} Boost ❌`);
}
console.log(`${boostType.charAt(0).toUpperCase() + boostType.slice(1)} Boost Response:`, response.data);
} catch (error) {
console.error('Error:', error.response ? error.response.data : error.message);
}
}
async function activateBoostsPeriodically(accessToken, boost) {
const boostInterval = tapsConfig.boostInterval;
while (boost.cnt > 0) {
await applyBoost(accessToken, boost.type);
boost.cnt -= 1;
if (boost.cnt > 0) {
await delay(boostInterval);
}
}
}
async function sendTapsPeriodically(accessToken) {
const cycleDuration = parseInt(tapsConfig.cycleDuration) * 1000;
const numberOfTaps = parseInt(tapsConfig.numberOfTaps);
try {
while (true) {
await sendTaps(accessToken, false);
await delay(cycleDuration);
}
} catch (error) {
console.error('Error:', error.response ? error.response.data : error.message);
}
}
authenticate();