const fetch = require("node-fetch"); const SocksProxyAgent = require("socks-proxy-agent"); const fs = require("fs"); const functionLogin = (email, auth_token, port) => new Promise((resolve, reject) => { fetch("https://appapi.handypick.io/user/auto-login", { agent: new SocksProxyAgent(`socks5://127.0.0.1:${port}`), method: "POST", body: JSON.stringify({ email, auth_token, }), headers: { accept: "application/json, text/plain, */*", "Content-Type": "application/json;charset=utf-8", "Content-Length": 226, Host: "appapi.handypick.io", Connection: "Keep-Alive", "Accept-Encoding": "gzip", "User-Agent": "okhttp/3.14.3", }, }) .then((res) => res.json()) .then((result) => { resolve(result); }) .catch((err) => reject(err)); }); const checkTask = (token, user_id, email, port) => new Promise((resolve, reject) => { fetch("https://appapi.handypick.io/game/list-unfinished-limit", { agent: new SocksProxyAgent(`socks5://127.0.0.1:${port}`), method: "POST", body: JSON.stringify({ user_id, email, }), headers: { Authorization: `Bearer ${token}`, accept: "application/json, text/plain, */*", "Content-Type": "application/json;charset=utf-8", "Content-Length": 226, Host: "appapi.handypick.io", Connection: "Keep-Alive", "Accept-Encoding": "gzip", "User-Agent": "okhttp/3.14.3", }, }) .then((res) => res.json()) .then((result) => { resolve(result); }) .catch((err) => reject(err)); }); const checkPrediction = (token, id, port) => new Promise((resolve, reject) => { fetch("https://appapi.handypick.io/game/game-status", { agent: new SocksProxyAgent(`socks5://127.0.0.1:${port}`), method: "POST", body: JSON.stringify({ id }), headers: { Authorization: `Bearer ${token}`, accept: "application/json, text/plain, */*", "Content-Type": "application/json;charset=utf-8", "Content-Length": 226, Host: "appapi.handypick.io", Connection: "Keep-Alive", "Accept-Encoding": "gzip", "User-Agent": "okhttp/3.14.3", }, }) .then((res) => res.json()) .then((result) => { resolve(result); }) .catch((err) => reject(err)); }); const iklanGais = (token, email, port) => new Promise((resolve, reject) => { fetch("https://appapi.handypick.io/settings/get", { agent: new SocksProxyAgent(`socks5://127.0.0.1:${port}`), method: "POST", body: JSON.stringify({ email: email, setting_key: "AD_VIDEO_EXPO_RATIO", }), headers: { Authorization: `Bearer ${token}`, accept: "application/json, text/plain, */*", "Content-Type": "application/json;charset=utf-8", "Content-Length": 226, Host: "appapi.handypick.io", Connection: "Keep-Alive", "Accept-Encoding": "gzip", "User-Agent": "okhttp/3.14.3", }, }) .then((res) => res.json()) .then((result) => { resolve(result); }) .catch((err) => reject(err)); }); const submitGames = (token, user_id, email, game_id, valued, port) => new Promise((resolve, reject) => { fetch("https://appapi.handypick.io/game/join-game-msg", { agent: new SocksProxyAgent(`socks5://127.0.0.1:${port}`), method: "POST", body: JSON.stringify({ user_id, email, game_id, game_type: 0, value: JSON.stringify(valued), currency: "USD", }), headers: { Authorization: `Bearer ${token}`, accept: "application/json, text/plain, */*", "Content-Type": "application/json;charset=utf-8", "Content-Length": 226, Host: "appapi.handypick.io", Connection: "Keep-Alive", "Accept-Encoding": "gzip", "User-Agent": "okhttp/3.14.3", }, }) .then((res) => res.json()) .then((result) => { resolve(result); }) .catch((err) => reject(err)); }); (async () => { const fileport = fs.readFileSync("./port.txt", "utf-8"); const port = fileport.split("\n"); const fileakun = fs.readFileSync("./result.txt", "utf-8"); const akun = fileakun.split("\n"); for (let i = 0; i < akun.length; i++) { try { const email = akun[i].split("|")[0]; const token = akun[i].split("|")[1]; const login = await functionLogin(email, token, port[i]); const user_id = login.user_id; if (login.result != undefined) { const ip_address = login.result.ip_address; console.log(`${i + 1} | Sukses Login | ${email} - ${ip_address}`); const cekTask = await checkTask(token, user_id, email, port[i]); for (let ii = 0; ii < cekTask.results.length; ii++) { let predictionJson = []; const games_id = cekTask.results[ii].id; if ( cekTask.results[ii].before_game == 1 && cekTask.results[ii].handy_limit === -1 && cekTask.results[ii].join_date == null ) { console.log(`${i} | ${email} - Ada task Prediksi`); const prediction = await checkPrediction(token, games_id, port[i]); const predictionLength = prediction.results.length; for (let iii = 0; iii < predictionLength; iii++) { const key = prediction.results[iii].indexOf( Math.max(...prediction.results[iii]) ); predictionJson.push([key]); } const iklanduluGais = await iklanGais(token, email, port[i]); const submit = await submitGames( token, user_id, email, games_id, predictionJson, port[i] ); if (submit.results == 1) { console.log(`${i} | ${email} - Sukses Prediksi\n`); } else { console.log(`${i} | ${email} - ${submit.message}\n`); } } } } else { console.log("Gagal"); } } catch (e) { console.log(e); } } })();