├── data.txt ├── user.txt ├── package.json ├── LICENSE ├── readme.md ├── spin.js ├── setup.js └── index.js /data.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /user.txt: -------------------------------------------------------------------------------- 1 | email1,password2,proxy1 2 | email2,password2,proxy2 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "axios": "^1.7.8", 4 | "https-proxy-agent": "^7.0.5" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 recitativonika 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Kaisar ZeroNode bot 2 | 3 | ## Description 4 | This script automates registration, network or node operations and daily claim for Kaisar ZeroNode. 5 | 6 | ## Features 7 | - **Automated node and daily claim interaction** 8 | - **Automatic account registration** 9 | - **Automatic claim mining rewards** 10 | - **Multi account** 11 | - **Proxy support** 12 | 13 | ## Prerequisites 14 | - [Node.js](https://nodejs.org/) (version 12 or higher) 15 | 16 | ## Installation 17 | 18 | 1. Clone the repository to your local machine: 19 | ```bash 20 | git clone https://github.com/recitativonika/kaisar-zero-node-bot.git 21 | ``` 22 | 2. Navigate to the project directory: 23 | ```bash 24 | cd kaisar-zero-node-bot 25 | ``` 26 | 4. Install the necessary dependencies: 27 | ```bash 28 | npm install 29 | ``` 30 | 31 | ## Usage 32 | 1. Register to Kaisar ZeroNode account first, if you don't have you can register [here](https://zero.kaisar.io/register?ref=SOXdEc181) or you can put email and password that you desire in to automatically register, check next part to do that. 33 | 2. Set and Modify `user.txt` with your account data. If you don't have account, you can just put email and password that you want to register and it will automatically register account for you. Put the data in `user.txt` with format like this: 34 | ```bash 35 | email1,password1,proxy1 36 | email2,password2,proxy2 37 | ``` 38 | if you dont want to use proxy, you don't need to put the proxy. 39 | 3. After put data in `user.txt`, run this script 40 | ```bash 41 | node setup.js 42 | ``` 43 | This script will automatically register account if you don't have account `(You need to check email and open the link to verify the account, after that you can rerun again the script)`. The setup script will automatically fill and save the needed data to the `data.txt`, it will look like this: 44 | ```bash 45 | email1,token1,extensionid1,proxy1 46 | email2,token2,extensionid2,proxy2 47 | ``` 48 | if you not use proxy when registering account and want to use proxy when run the bot, you can add it manually 49 | 4. Run the script: 50 | ```bash 51 | node index.js 52 | ``` 53 | 54 | ## License 55 | This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. 56 | 57 | ## Note 58 | This script only for testing purpose, using this script might violates ToS and may get your account permanently banned. 59 | 60 | My reff code if you want to use :) : 61 | https://zero.kaisar.io/register?ref=SOXdEc181 62 | -------------------------------------------------------------------------------- /spin.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios'); 2 | const fs = require('fs'); 3 | const path = require('path'); 4 | const { HttpsProxyAgent } = require('https-proxy-agent'); 5 | const readline = require('readline'); 6 | 7 | const yellow = '\x1b[33m'; 8 | const bold = '\x1b[1m'; 9 | const reset = '\x1b[0m'; 10 | 11 | function centerAlignText(text, width) { 12 | const pad = Math.floor((width - text.length) / 2); 13 | return ' '.repeat(pad) + text + ' '.repeat(pad); 14 | } 15 | 16 | const consoleWidth = process.stdout.columns; 17 | console.log(""); 18 | console.log(`${bold}${yellow}${centerAlignText("============================================", consoleWidth)}${reset}`); 19 | console.log(`${bold}${yellow}${centerAlignText("Kaisar zero node bot", consoleWidth)}${reset}`); 20 | console.log(`${bold}${yellow}${centerAlignText("github.com/recitativonika", consoleWidth)}${reset}`); 21 | console.log(`${bold}${yellow}${centerAlignText("============================================", consoleWidth)}${reset}`); 22 | console.log(""); 23 | 24 | const dataFilePath = path.join(__dirname, 'data.txt'); 25 | const accounts = fs.readFileSync(dataFilePath, 'utf-8').trim().split('\n').map(line => line.split(',')); 26 | 27 | const rl = readline.createInterface({ 28 | input: process.stdin, 29 | output: process.stdout 30 | }); 31 | 32 | function askQuestion(query) { 33 | return new Promise(resolve => rl.question(yellow + query + reset, resolve)); 34 | } 35 | 36 | async function getTicketBalance(email, token, proxyAgent) { 37 | try { 38 | const response = await axios.get('https://zero-api.kaisar.io/user/balances?symbol=ticket', { 39 | headers: { 40 | 'accept': '*/*', 41 | 'accept-encoding': 'gzip, deflate, br, zstd', 42 | 'accept-language': 'en-US,en;q=0.9,id;q=0.8', 43 | 'authorization': `Bearer ${token}` 44 | }, 45 | httpsAgent: proxyAgent 46 | }); 47 | 48 | const ticketData = response.data.data.find(item => item.currency === 'ticket'); 49 | return parseInt(ticketData.balance, 10); 50 | } catch (error) { 51 | if (error.response && error.response.status === 407) { 52 | console.error(`Error fetching ticket balance for ${email}: Request failed with status code 407. Not authenticated or invalid authentication credentials. Make sure to update your proxy address, proxy username, and port.`); 53 | } else { 54 | console.error(`Error fetching ticket balance for ${email}:`, error.message); 55 | } 56 | return 0; 57 | } 58 | } 59 | 60 | async function spinTicket(email, token, proxyAgent) { 61 | try { 62 | const response = await axios.post('https://zero-api.kaisar.io/lucky/spin', {}, { 63 | headers: { 64 | 'accept': '*/*', 65 | 'accept-encoding': 'gzip, deflate, br, zstd', 66 | 'accept-language': 'en-US,en;q=0.9,id;q=0.8', 67 | 'authorization': `Bearer ${token}` 68 | }, 69 | httpsAgent: proxyAgent 70 | }); 71 | 72 | const prize = response.data.data.prize; 73 | console.log(`Spin result for ${email} prize: { symbol: '${prize.symbol}', amount: ${prize.amount} }`); 74 | } catch (error) { 75 | if (error.response && error.response.status === 407) { 76 | console.error(`Error spinning ticket for ${email}: Request failed with status code 407. Not authenticated or invalid authentication credentials. Make sure to update your proxy address, proxy username, and port.`); 77 | } else { 78 | console.error(`Error spinning ticket for ${email}:`, error.message); 79 | } 80 | } 81 | } 82 | 83 | async function automateSpinning(email, token, proxyAgent) { 84 | let ticketBalance = await getTicketBalance(email, token, proxyAgent); 85 | 86 | while (ticketBalance > 0) { 87 | await spinTicket(email, token, proxyAgent); 88 | await new Promise(resolve => setTimeout(resolve, 5000)); 89 | ticketBalance = await getTicketBalance(email, token, proxyAgent); 90 | } 91 | 92 | console.log(`No more tickets left for ${email}.`); 93 | } 94 | 95 | async function main() { 96 | const useProxy = await askQuestion('Do you want to run with proxy? (y/n): '); 97 | const autoRestart = await askQuestion('Do you want to auto-restart the script? (y/n): '); 98 | let interval = null; 99 | 100 | if (autoRestart.toLowerCase() === 'y') { 101 | const hours = await askQuestion('Enter the number of hours for auto-restart: '); 102 | interval = parseFloat(hours) * 3600000; 103 | } 104 | 105 | for (const [email, token, extensionId, proxyString] of accounts) { 106 | let proxyAgent = null; 107 | if (useProxy.toLowerCase() === 'y') { 108 | let proxyUrl = proxyString; 109 | if (!proxyUrl.startsWith('http://') && !proxyUrl.startsWith('https://')) { 110 | proxyUrl = `http://${proxyUrl}`; 111 | } 112 | proxyAgent = new HttpsProxyAgent(proxyUrl); 113 | } 114 | 115 | await automateSpinning(email, token, proxyAgent); 116 | } 117 | 118 | if (interval) { 119 | console.log(`Restarting process in ${interval / 3600000} hour(s)...`); 120 | setInterval(() => { 121 | for (const [email, token, extensionId, proxyString] of accounts) { 122 | let proxyAgent = null; 123 | if (useProxy.toLowerCase() === 'y') { 124 | let proxyUrl = proxyString; 125 | if (!proxyUrl.startsWith('http://') && !proxyUrl.startsWith('https://')) { 126 | proxyUrl = `http://${proxyUrl}`; 127 | } 128 | console.log(`Using proxy: ${proxyUrl}`); 129 | proxyAgent = new HttpsProxyAgent(proxyUrl); 130 | } 131 | console.log(`Restarting script for ${email}...`); 132 | automateSpinning(email, token, proxyAgent); 133 | } 134 | }, interval); 135 | } 136 | 137 | rl.close(); 138 | } 139 | 140 | main(); 141 | 142 | main(); 143 | -------------------------------------------------------------------------------- /setup.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios'); 2 | const crypto = require('crypto'); 3 | const fs = require('fs'); 4 | const readline = require('readline'); 5 | const { HttpsProxyAgent } = require('https-proxy-agent'); 6 | 7 | const COLORS = { 8 | GREEN: "\x1b[32m", 9 | BOLD_CYAN: "\x1b[1m\x1b[36m", 10 | BOLD_YELLOW: "\x1b[1m\x1b[33m", 11 | RED: "\x1b[31m", 12 | RESET: "\x1b[0m" 13 | }; 14 | 15 | const rl = readline.createInterface({ 16 | input: process.stdin, 17 | output: process.stdout 18 | }); 19 | 20 | function generateUniqueIdentifier() { 21 | return crypto.randomUUID(); 22 | } 23 | 24 | function generateRandomBrowserId() { 25 | return `browser-${crypto.randomBytes(6).toString('hex')}`; 26 | } 27 | 28 | function generateRandomHardwareId() { 29 | return `hardware-${crypto.randomBytes(6).toString('hex')}`; 30 | } 31 | 32 | function readTextFile(filePath) { 33 | try { 34 | const data = fs.readFileSync(filePath, 'utf-8'); 35 | return data.split('\n').map(line => line.trim()).filter(line => line !== ''); 36 | } catch (error) { 37 | console.error(`Error reading file at ${filePath}:`, error.message); 38 | return []; 39 | } 40 | } 41 | 42 | function saveToFileContent(data) { 43 | try { 44 | fs.writeFileSync('data.txt', data.join('\n') + '\n'); 45 | } catch (error) { 46 | console.error("Error saving data to file:", error.message); 47 | } 48 | } 49 | 50 | function updateUserData(email, token, extensionId, proxy, skipExtensionUpdate = false) { 51 | const data = readTextFile('data.txt'); 52 | const updatedData = []; 53 | const emailNormalized = email.trim().toLowerCase(); 54 | let emailExists = false; 55 | 56 | data.forEach(line => { 57 | const parts = line.split(','); 58 | const existingEmailNormalized = parts[0].trim().toLowerCase(); 59 | if (existingEmailNormalized === emailNormalized) { 60 | updatedData.push(`${email},${token},${skipExtensionUpdate ? parts[2] : extensionId},${proxy}`); 61 | emailExists = true; 62 | } else { 63 | updatedData.push(line); 64 | } 65 | }); 66 | 67 | if (!emailExists) { 68 | updatedData.push(`${email},${token},${extensionId},${proxy}`); 69 | } 70 | 71 | saveToFileContent(updatedData); 72 | } 73 | 74 | function createApiClient(proxy, useProxy) { 75 | const agent = useProxy ? new HttpsProxyAgent(proxy) : undefined; 76 | return axios.create({ 77 | baseURL: 'https://zero-api.kaisar.io/', 78 | headers: { 79 | 'Content-Type': 'application/json' 80 | }, 81 | httpsAgent: agent, 82 | }); 83 | } 84 | 85 | async function verifyExtensionId(apiClient, extensionId, token, browserId, hardwareId) { 86 | try { 87 | console.log("Initializing ExtensionID verification..."); 88 | 89 | const response = await apiClient.post('/mining/start', { 90 | extension: extensionId, 91 | browserId, 92 | hardwareId 93 | }, { 94 | headers: { 95 | Authorization: `Bearer ${token}` 96 | } 97 | }); 98 | 99 | if (response.status === 200) { 100 | console.log(`${COLORS.GREEN}ExtensionID verification was successful!${COLORS.RESET}`); 101 | return true; 102 | } 103 | } catch (error) { 104 | if (error.response) { 105 | const { status } = error.response; 106 | if (status === 412) { 107 | console.log(`${COLORS.RED}Verification failed, another ExtensionID is already running. Please try again later.${COLORS.RESET}`); 108 | } else if (status === 401) { 109 | console.log(`${COLORS.RED}Unauthorized access. Please check your token and permissions.${COLORS.RESET}`); 110 | } 111 | } 112 | return false; 113 | } 114 | } 115 | 116 | async function loginUser(email, password, proxy, useProxy) { 117 | const apiClient = createApiClient(proxy, useProxy); 118 | 119 | try { 120 | const response = await apiClient.post('/auth/login', { email, password }); 121 | 122 | if (response.data) { 123 | const token = response.data.data.accessToken; 124 | console.log(`Logging into account ${COLORS.BOLD_CYAN}${email}${COLORS.RESET}...`); 125 | console.log(`${COLORS.GREEN}Successfully logged in for ${email}${COLORS.RESET}`); 126 | 127 | const extensionId = generateUniqueIdentifier(); 128 | const browserId = generateRandomBrowserId(); 129 | const hardwareId = generateRandomHardwareId(); 130 | const verificationSuccess = await verifyExtensionId(apiClient, extensionId, token, browserId, hardwareId); 131 | updateUserData(email, token, extensionId, proxy, !verificationSuccess && response.status === 412); 132 | } else { 133 | console.error(`Failed to log in for ${email}:`, response.data.message); 134 | } 135 | } catch (error) { 136 | console.error(`Encountered an error logging in for ${email}. Please ensure email confirmation:`, error.message); 137 | } 138 | } 139 | 140 | async function registerUser(email, password, proxy, useProxy) { 141 | const apiClient = createApiClient(proxy, useProxy); 142 | const referralCode = 'SOXdEc181'; 143 | 144 | try { 145 | const response = await apiClient.post('/auth/register', { email, password, referrer: referralCode }); 146 | if (response.data) { 147 | console.log(`${COLORS.GREEN}Account registration successful for ${email}. Verify your email and rerun the script to obtain the token.${COLORS.RESET}`); 148 | } else { 149 | console.error(`Registration failed for ${email}:`, response.data.message); 150 | } 151 | } catch (error) { 152 | if (error.response?.data?.error?.code === 410) { 153 | console.log(`Account ${COLORS.BOLD_CYAN}${email}${COLORS.RESET} already exists. Attempting login...`); 154 | await loginUser(email, password, proxy, useProxy); 155 | } else { 156 | console.error(`Error encountered during registration for ${email}. Please try again later.`); 157 | } 158 | } 159 | } 160 | 161 | async function processUsers(useProxy) { 162 | try { 163 | const users = readTextFile('user.txt').map(line => { 164 | const parts = line.split(','); 165 | return { 166 | email: parts[0], 167 | password: parts[1], 168 | proxy: parts[2] || 'noproxy' 169 | }; 170 | }); 171 | 172 | for (let i = 0; i < users.length; i++) { 173 | const { email, password, proxy } = users[i]; 174 | console.log(`Using proxy: ${COLORS.BOLD_YELLOW}${proxy}${COLORS.RESET} for account: ${COLORS.BOLD_CYAN}${email}${COLORS.RESET}`); 175 | await new Promise(resolve => setTimeout(resolve, 1000)); 176 | await registerUser(email, password, useProxy ? proxy : 'noproxy', useProxy); 177 | } 178 | rl.close(); 179 | 180 | } catch (error) { 181 | console.error("Problem reading user.txt file:", error.message); 182 | } 183 | } 184 | 185 | function alignCenter(text, width) { 186 | const pad = Math.floor((width - text.length) / 2); 187 | return ' '.repeat(pad) + text + ' '.repeat(pad); 188 | } 189 | 190 | const consoleWidth = process.stdout.columns; 191 | console.log(""); 192 | console.log(`${COLORS.BOLD_YELLOW}${alignCenter("============================================", consoleWidth)}${COLORS.RESET}`); 193 | console.log(`${COLORS.BOLD_YELLOW}${alignCenter("Kaisar ZeroNode bot", consoleWidth)}${COLORS.RESET}`); 194 | console.log(`${COLORS.BOLD_YELLOW}${alignCenter("github.com/recitativonika", consoleWidth)}${COLORS.RESET}`); 195 | console.log(`${COLORS.BOLD_YELLOW}${alignCenter("============================================", consoleWidth)}${COLORS.RESET}`); 196 | console.log(""); 197 | 198 | rl.question(`${COLORS.BOLD_YELLOW}Do you want to use a proxy? (y/n): ${COLORS.RESET}`, (useProxyInput) => { 199 | const useProxy = useProxyInput.trim().toLowerCase() === 'y'; 200 | processUsers(useProxy); 201 | }); 202 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const axios = require('axios'); 3 | const { HttpsProxyAgent } = require('https-proxy-agent'); 4 | const readline = require('readline'); 5 | 6 | const COLORS = { 7 | RESET: "\x1b[0m", 8 | BOLD_YELLOW: "\x1b[1;33m", 9 | BOLD_CYAN: "\x1b[1;36m", 10 | GREEN: "\x1b[32m", 11 | RED: "\x1b[31m", 12 | WHITE: "\x1b[37m" 13 | }; 14 | 15 | function centerAlignText(text, width) { 16 | const pad = Math.floor((width - text.length) / 2); 17 | return ' '.repeat(pad) + text + ' '.repeat(pad); 18 | } 19 | 20 | const consoleWidth = process.stdout.columns; 21 | console.log(""); 22 | console.log(`${COLORS.BOLD_YELLOW}${centerAlignText("============================================", consoleWidth)}${COLORS.RESET}`); 23 | console.log(`${COLORS.BOLD_YELLOW}${centerAlignText("Kaisar zero node bot", consoleWidth)}${COLORS.RESET}`); 24 | console.log(`${COLORS.BOLD_YELLOW}${centerAlignText("github.com/recitativonika", consoleWidth)}${COLORS.RESET}`); 25 | console.log(`${COLORS.BOLD_YELLOW}${centerAlignText("============================================", consoleWidth)}${COLORS.RESET}`); 26 | console.log(""); 27 | 28 | function fetchConfigurationData() { 29 | const data = fs.readFileSync('data.txt', 'utf8'); 30 | return data.split('\n').filter(line => line.trim() !== '').map(line => { 31 | const [email, token, extensionId, proxy] = line.split(','); 32 | return { email, token, extensionId, proxy }; 33 | }); 34 | } 35 | 36 | function createUniqueApiClient(proxy, token, useProxy) { 37 | if (useProxy && proxy && !/^https?:\/\//i.test(proxy)) { 38 | proxy = `http://${proxy}`; 39 | } 40 | 41 | const agent = useProxy ? new HttpsProxyAgent(proxy) : undefined; 42 | return axios.create({ 43 | baseURL: 'https://zero-api.kaisar.io/', 44 | headers: { 45 | 'Content-Type': 'application/json', 46 | Authorization: `Bearer ${token}` 47 | }, 48 | httpsAgent: agent, 49 | }); 50 | } 51 | 52 | async function retrieveMissionTasks(email, proxy, token, useProxy, accountNumber) { 53 | const apiClient = createUniqueApiClient(proxy, token, useProxy); 54 | 55 | try { 56 | const response = await apiClient.get('mission/tasks'); 57 | const tasks = response.data.data; 58 | const activeTaskIds = tasks 59 | .filter(task => task.status === 1) 60 | .map(task => task._id); 61 | 62 | if (activeTaskIds.length > 0) { 63 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Active tasks detected with IDs: ${activeTaskIds}`); 64 | } 65 | 66 | return activeTaskIds; 67 | } catch (error) { 68 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] ${COLORS.RED}Failed to retrieve mission tasks for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET}${COLORS.RESET}`); 69 | return null; 70 | } 71 | } 72 | async function claimMissionRewards(email, proxy, token, taskIds, useProxy, accountNumber) { 73 | const apiClient = createUniqueApiClient(proxy, token, useProxy); 74 | 75 | for (let taskId of taskIds) { 76 | try { 77 | const response = await apiClient.post(`mission/tasks/${taskId}/claim`, {}); 78 | const task = response.data.data; 79 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Rewards successfully claimed from task ID: ${taskId}`); 80 | } catch (error) { 81 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Failed to claim task with ID: ${taskId} for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET}`); 82 | } 83 | } 84 | } 85 | 86 | async function executeDailyLogin(email, proxy, token, useProxy, accountNumber) { 87 | const apiClient = createUniqueApiClient(proxy, token, useProxy); 88 | 89 | try { 90 | const response = await apiClient.post('checkin/check', {}); 91 | const checkin = response.data.data; 92 | if (checkin) { 93 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Successfully logged in for the day at: ${checkin.time} for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET}`); 94 | } 95 | } catch (error) { 96 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] ${COLORS.RED}Daily login for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET} failed: Error or already logged in today.${COLORS.RESET}`); 97 | } 98 | } 99 | 100 | async function verifyAndClaimTasks(email, proxy, token, useProxy, accountNumber) { 101 | const taskIds = await retrieveMissionTasks(email, proxy, token, useProxy, accountNumber); 102 | if (taskIds && taskIds.length > 0) { 103 | await claimMissionRewards(email, proxy, token, taskIds, useProxy, accountNumber); 104 | } else { 105 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] No tasks available to claim for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET}`); 106 | } 107 | } 108 | 109 | async function fetchMiningData(apiClient, extensionId, accountNumber) { 110 | try { 111 | const response = await apiClient.get('/mining/current', { 112 | params: { extension: extensionId } 113 | }); 114 | 115 | if (response.data && response.data.data) { 116 | const miningData = response.data.data; 117 | 118 | updateMiningProgress(accountNumber, miningData); 119 | await updateMiningPoints(extensionId, miningData, apiClient, accountNumber); 120 | 121 | if (miningData.ended === 1) { 122 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Mining has concluded. Proceeding to claim mining points.`); 123 | await claimMiningRewards(apiClient, extensionId, accountNumber); 124 | } 125 | } 126 | } catch (error) { 127 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Error fetching mining data: ${COLORS.RED}`, error.message || error, `${COLORS.RESET}`); 128 | } 129 | } 130 | 131 | async function updateMiningPoints(extensionId, miningData, apiClient, accountNumber) { 132 | const elapsedTimeInHours = (Date.now() - new Date(miningData.start).getTime() - miningData.miss) / 36e5; 133 | const points = elapsedTimeInHours * miningData.hourly; 134 | const miningPoint = Math.max(0, points); 135 | const totalPoints = await checkAccountBalance(apiClient, extensionId, accountNumber); 136 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Total Points: ${COLORS.GREEN}${totalPoints}${COLORS.RESET}, MiningPoints: ${COLORS.BOLD_CYAN}${miningPoint}${COLORS.RESET}, ElapsedTimeInHours: ${COLORS.BOLD_YELLOW}${elapsedTimeInHours}${COLORS.RESET}`); 137 | } 138 | 139 | function updateMiningProgress(accountNumber, miningData) { 140 | const currentTime = Date.now(); 141 | const endTime = miningData.end; 142 | const remainingTime = Math.max(0, endTime - currentTime); 143 | 144 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Mining progress: EndTime: ${COLORS.BOLD_YELLOW}${endTime}${COLORS.RESET}, CurrentTime: ${COLORS.BOLD_YELLOW}${currentTime}${COLORS.RESET}, RemainingTime: ${COLORS.BOLD_YELLOW}${remainingTime}${COLORS.RESET}`); 145 | } 146 | async function claimMiningRewards(apiClient, extensionId, accountNumber) { 147 | try { 148 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Claiming mining points...`); 149 | const { data } = await apiClient.post('/mining/claim', { extension: extensionId }); 150 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Claimed successfully: ${COLORS.GREEN}`, data, `${COLORS.RESET}`); 151 | await initiateFarming(apiClient, extensionId, accountNumber); 152 | } catch (error) { 153 | 154 | } 155 | } 156 | async function initiateFarming(apiClient, extensionId, accountNumber) { 157 | try { 158 | const response = await apiClient.post('/mining/start', { 159 | extension: extensionId 160 | }); 161 | if (response.status === 200) { 162 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Mining initiated successfully`); 163 | } 164 | } catch (error) { 165 | if (error.response) { 166 | const { status, data } = error.response; 167 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Error initiating mining (HTTP Error): ${COLORS.RED}`, { 168 | status, 169 | data 170 | }, `${COLORS.RESET}`); 171 | 172 | if (status === 412 && data.error.message === 'Mining is already in progress.') { 173 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Mining already in progress. Skipping start process.`); 174 | return; 175 | } 176 | } else { 177 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Error initiating mining: ${COLORS.RED}`, error.message || error, `${COLORS.RESET}`); 178 | } 179 | } 180 | } 181 | 182 | async function checkAccountBalance(apiClient, extensionId, accountNumber) { 183 | try { 184 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Checking account balances...`); 185 | const response = await apiClient.get('/user/balances'); 186 | const balances = response.data.data[0].balance; 187 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Balances: ${COLORS.GREEN}`, balances, `${COLORS.RESET}`); 188 | return balances; 189 | } catch (error) { 190 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Error checking account balances: ${COLORS.RED}`, error.message || error, `${COLORS.RESET}`); 191 | return null; 192 | } 193 | } 194 | 195 | async function executePingAndUpdate(accountNumber, email, token, proxy, useProxy) { 196 | const apiClient = createUniqueApiClient(proxy, token, useProxy); 197 | 198 | try { 199 | if (useProxy) { 200 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Attempting to ping ${COLORS.BOLD_CYAN}${email}${COLORS.WHITE} using proxy ${COLORS.BOLD_YELLOW}${proxy}${COLORS.RESET}`); 201 | } else { 202 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Attempting to ping ${COLORS.BOLD_CYAN}${email}${COLORS.WHITE} without proxy`); 203 | } 204 | const response = await apiClient.post('/extension/ping', { 205 | extension: token 206 | }); 207 | 208 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] ${COLORS.GREEN}Ping for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET} was successful${COLORS.RESET}`); 209 | await fetchMiningData(apiClient, token, accountNumber); 210 | } catch (error) { 211 | const errorMessage = useProxy ? 212 | `Ping failed for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET} using proxy ${COLORS.BOLD_YELLOW}${proxy}${COLORS.RESET}` : 213 | `Ping failed for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET} without proxy`; 214 | console.error(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] ${COLORS.RED}${errorMessage}${COLORS.RESET}`); 215 | } 216 | } 217 | 218 | (async () => { 219 | const rl = readline.createInterface({ 220 | input: process.stdin, 221 | output: process.stdout 222 | }); 223 | 224 | rl.question(`${COLORS.BOLD_YELLOW}Would you like to use a proxy? (y/n):${COLORS.RESET} `, async (useProxyInput) => { 225 | const useProxy = useProxyInput.trim().toLowerCase() === 'y'; 226 | rl.close(); 227 | 228 | const config = fetchConfigurationData(); 229 | if (config.length === 0) { 230 | console.error("No configuration found in data.txt. Exiting..."); 231 | return; 232 | } 233 | 234 | const lastExecution = {}; 235 | const lastClaimTime = {}; 236 | 237 | for (let i = 0; i < config.length; i++) { 238 | const { email, token, extensionId, proxy } = config[i]; 239 | processAccountSequentially(i + 1, email, token, extensionId, proxy, useProxy, lastExecution, lastClaimTime); 240 | } 241 | 242 | async function processAccountSequentially(accountNumber, email, token, extensionId, proxy, useProxy, lastExecution, lastClaimTime) { 243 | while (true) { 244 | const now = Date.now(); 245 | 246 | if (!lastExecution[token] || now - lastExecution[token] >= 12 * 60 * 60 * 1000) { 247 | await executeDailyLogin(email, proxy, token, useProxy, accountNumber); 248 | await verifyAndClaimTasks(email, proxy, token, useProxy, accountNumber); 249 | lastExecution[token] = now; 250 | } 251 | 252 | if (!lastClaimTime[token] || now - lastClaimTime[token] >= 4 * 60 * 60 * 1000) { 253 | await verifyAndClaimTasks(email, proxy, token, useProxy, accountNumber); 254 | lastClaimTime[token] = now; 255 | } 256 | 257 | await executePingAndUpdate(accountNumber, email, token, proxy, useProxy); 258 | 259 | console.log(`[${COLORS.BOLD_CYAN}${accountNumber}${COLORS.RESET}] Pinging again in 1 minute for ${COLORS.BOLD_CYAN}${email}${COLORS.RESET}...`); 260 | await new Promise(resolve => setTimeout(resolve, 60000)); 261 | } 262 | } 263 | }); 264 | })(); 265 | --------------------------------------------------------------------------------