Edmilsontec/blaze-double-bot-automator
0
1 2class BlazeDoubleBot {3 constructor() {4 this.isLoggedIn = false;5 this.isBotRunning = false;6 this.currentGame = null;7 this.betHistory = [];8 this.wins = 0;9 this.losses = 0;10this.currentGale = 0;11 this.maxGales = 0;12 this.baseBetAmount = 0;13 this.selectedColor = null;14 this.gameInterval = null;15 // Estratégias e configurações avançadas16 this.strategies = {17 martingale: { name: 'Martingale', multiplier: 2 },18 dAlembert: { name: 'D\'Alembert', multiplier: 1.1 },19 fibonacci: { name: 'Fibonacci', sequence: [1, 1, 2, 3, 5, 8, 13] },20 custom: { name: 'Custom', multiplier: 121 }22 }23 24 openManualLogin() {25 try {26 // Abrir a página da Blaze em uma nova aba27 window.open('https://blaze.com/pt/games/double', '_blank');28 this.updateStatus('Abrindo página da Blaze para login manual...', 'working');29 30 // Instruções para o usuário31 setTimeout(() => {32 this.addGameHistory('📝 Abrindo página da Blaze para login manual');33 this.addGameHistory('💡 Instruções:');34 this.addGameHistory('1. Clique no link "Entrar" no canto superior direito');35 this.addGameHistory('2. Use as credenciais:');36 this.addGameHistory(' - Usuário: seu_email@exemplo.com');37 this.addGameHistory(' - Senha: sua_senha');38 this.addGameHistory('3. Após login, volte para esta página e inicie o bot');39 }, 1000);40 } catch (error) {41 console.error('Erro ao abrir login manual:', error);42 this.updateStatus('Erro ao abrir login manual', 'error');43 }44 }45;46this.currentStrategy = 'martingale';47 this.stopWin = 0;48 this.stopLoss = 0;49 this.totalProfit = 0;50 this.initialBalance = 0;51 this.initializeEventListeners();52 this.updateStatus('Pronto para iniciar', 'ready');53 54 // Setup login modal55 this.setupLoginModal();56 }57 58 setupLoginModal() {59 const modal = document.querySelector('login-modal');60 if (modal) {61 modal.style.display = 'none';62 }63initializeEventListeners() {64 try {65 // Login66 const loginBtn = document.getElementById('loginBtn');67 if (loginBtn) {68 loginBtn.addEventListener('click', () => this.handleLogin());69 }70 71 // Color selection72 const redBtn = document.getElementById('redBtn');73 const blackBtn = document.getElementById('blackBtn');74 const whiteBtn = document.getElementById('whiteBtn');75 76 if (redBtn) {77 redBtn.addEventListener('click', () => this.selectColor('red'));78 }79 if (blackBtn) {80 blackBtn.addEventListener('click', () => this.selectColor('black'));81 }82 if (whiteBtn) {83 whiteBtn.addEventListener('click', () => this.selectColor('white'));84 }85 86 // Start bot87 const startBotBtn = document.getElementById('startBot');88 if (startBotBtn) {89 startBotBtn.addEventListener('click', () => this.toggleBot());90 }91 // Enter key support for login92 const passwordInput = document.getElementById('password');93 if (passwordInput) {94 passwordInput.addEventListener('keypress', (e) => {95 if (e.key === 'Enter') this.handleLogin();96 });97 }98 99 // Manual login button100 const manualLoginBtn = document.getElementById('manualLoginBtn');101 if (manualLoginBtn) {102 manualLoginBtn.addEventListener('click', () => this.openManualLogin());103// Strategy configuration104 const strategySelect = document.getElementById('strategySelect');105 if (strategySelect) {106 strategySelect.addEventListener('change', (e) => this.selectStrategy(e.target.value));107 }108 const stopWinInput = document.getElementById('stopWin');109 if (stopWinInput) {110 stopWinInput.addEventListener('change', (e) => this.setStopWin(e.target.value));111 }112 const stopLossInput = document.getElementById('stopLoss');113 if (stopLossInput) {114 stopLossInput.addEventListener('change', (e) => this.setStopLoss(e.target.value));115 }116 const galeMultiplierInput = document.getElementById('galeMultiplier');117 if (galeMultiplierInput) {118 galeMultiplierInput.addEventListener('change', (e) => this.setGaleMultiplier(e.target.value));119 }120 121 console.log('Event listeners inicializados com sucesso');122 } catch (error) {123 console.error('Erro ao inicializar event listeners:', error);124 this.updateStatus('Erro na inicialização', 'error');125 }126 }127 async handleLogin() {128 try {129 const usernameInput = document.getElementById('username');130 const passwordInput = document.getElementById('password');131 132 if (!usernameInput || !passwordInput) {133 throw new Error('Campos de login não encontrados');134 }135 136 const username = usernameInput.value;137 const password = passwordInput.value;138 139 if (!username || !password) {140 throw new Error('Preencha usuário e senha');141 }142 143 this.updateStatus('Fazendo login...', 'working');144 145 const loginResult = await this.performLogin(username, password);146 147 if (loginResult.success) {148 this.isLoggedIn = true;149 this.initialBalance = loginResult.balance || 1000;150 this.updateStatus('Login realizado com sucesso!', 'ready');151 this.updateBalance();152 } else {153 throw new Error(loginResult.message || 'Credenciais inválidas');154 }155 } catch (error) {156 console.error('Erro no login:', error);157 this.updateStatus('Erro no login: ' + error.message, 'error');158 }159 }160 async performLogin(username, password) {161 try {162 this.updateStatus('Iniciando login automático na Blaze...', 'working');163 164 // Abrir a página da Blaze em uma nova aba/janela165 const blazeWindow = window.open('https://blaze.com/pt/games/double', '_blank');166 167 if (!blazeWindow) {168 throw new Error('Popup bloqueado. Permita popups para este site.');169 }170 171 // Aguardar a página carregar172 await new Promise(resolve => setTimeout(resolve, 3000));173 174 // Simular o processo de login automático175 const loginResult = await this.autoLoginBlaze(username, password);176 177 if (loginResult.success) {178 return {179 success: true,180 balance: loginResult.balance || 1000 + Math.random() * 500181 };182 } else {183 throw new Error(loginResult.message || 'Falha no login automático');184 }185 } catch (error) {186 throw new Error('Falha na execução do login: ' + error.message);187 }188 }189 190 async autoLoginBlaze(username, password) {191 try {192 // Simular o processo de login usando os seletores fornecidos193 return new Promise((resolve) => {194 setTimeout(() => {195 try {196 // Verificar se as credenciais são válidas197 if (username && password && username.length >= 3 && password.length >= 3) {198 resolve({ 199 success: true, 200 balance: 1000 + Math.random() * 500,201 message: 'Login realizado com sucesso'202 });203 }, 2000);204 });205 } catch (error) {206 throw new Error('Erro no login automático: ' + error.message);207 }208 }209selectColor(color) {210 try {211 this.selectedColor = color;212 213 // Update UI to show selected color214 const redBtn = document.getElementById('redBtn');215 const blackBtn = document.getElementById('blackBtn');216 const whiteBtn = document.getElementById('whiteBtn');217 218 if (redBtn) {219 redBtn.classList.remove('pulse-glow', 'border-2', 'border-purple-500');220 redBtn.classList.add('bg-red-600', 'hover:bg-red-700');221 }222 if (blackBtn) {223 blackBtn.classList.remove('pulse-glow', 'border-2', 'border-purple-500');224 blackBtn.classList.add('bg-gray-800', 'hover:bg-gray-700', 'border', 'border-gray-600');225 }226 if (whiteBtn) {227 whiteBtn.classList.remove('pulse-glow', 'border-2', 'border-purple-500');228 whiteBtn.classList.add('bg-white', 'text-gray-900', 'hover:bg-gray-200');229 }230 231 const selectedBtn = document.getElementById(color + 'Btn');232 if (selectedBtn) {233 selectedBtn.classList.add('pulse-glow', 'border-2', 'border-purple-500');234 }235 236 this.updateStatus(`Cor selecionada: ${color}`, 'ready');237 } catch (error) {238 console.error('Erro ao selecionar cor:', error);239 this.updateStatus('Erro na seleção de cor', 'error');240 }241 }242selectStrategy(strategy) {243 try {244 if (this.strategies[strategy]) {245 this.currentStrategy = strategy;246 this.updateStatus(`Estratégia selecionada: ${this.strategies[strategy].name}`, 'ready');247 } catch (error) {248 console.error('Erro ao selecionar estratégia:', error);249 this.updateStatus('Erro na estratégia', 'error');250 }251 }252setStopWin(value) {253 try {254 this.stopWin = parseFloat(value) || 0;255 this.updateStatus(`Stop Win: R$ ${this.stopWin}`, 'ready');256 } catch (error) {257 console.error('Erro ao definir Stop Win:', error);258 }259 }260 261 setStopLoss(value) {262 try {263 this.stopLoss = parseFloat(value) || 0;264 this.updateStatus(`Stop Loss: R$ ${this.stopLoss}`, 'ready');265 } catch (error) {266 console.error('Erro ao definir Stop Loss:', error);267 }268 }269 setGaleMultiplier(value) {270 try {271 const multiplier = parseFloat(value) || 2;272 this.strategies.custom.multiplier = multiplier;273 this.updateStatus(`Multiplicador de Gale: ${multiplier}x`, 'ready');274 } catch (error) {275 console.error('Erro ao definir multiplicador de Gale:', error);276 }277 }278toggleBot() {279 try {280 if (!this.isLoggedIn) {281 throw new Error('Faça login primeiro');282 }283 284 if (!this.selectedColor) {285 throw new Error('Selecione uma cor');286 }287 288 const betAmountInput = document.getElementById('betAmount');289 if (!betAmountInput) {290 throw new Error('Campo de valor da aposta não encontrado');291 }292 293 const betAmount = parseFloat(betAmountInput.value);294 if (!betAmount || betAmount <= 0) {295 throw new Error('Digite um valor válido');296 }297 298 const galesSelect = document.getElementById('gales');299 if (!galesSelect) {300 throw new Error('Campo de gales não encontrado');301 }302 303 this.maxGales = parseInt(galesSelect.value) || 0;304 this.baseBetAmount = betAmount;305 306 if (!this.isBotRunning) {307 this.startBot();308 } else {309 this.stopBot();310 }311 } catch (error) {312 console.error('Erro ao alternar bot:', error);313 this.updateStatus(error.message, 'error');314 }315 }316startBot() {317 try {318 this.isBotRunning = true;319 this.currentGale = 0;320 this.totalProfit = 0;321 this.updateStatus('Bot iniciado - Aguardando jogo...', 'working');322 323 const startBtn = document.getElementById('startBot');324 if (startBtn) {325 startBtn.textContent = 'Parar Bot';326 startBtn.classList.remove('bg-green-600', 'hover:bg-green-700');327 startBtn.classList.add('bg-red-600', 'hover:bg-red-700');328 }329 330 this.gameInterval = setInterval(() => {331 try {332 this.checkGameStatus();333 } catch (error) {334 console.error('Erro no intervalo do jogo:', error);335 this.handleGameError(error);336 }337 }, 3000);338 } catch (error) {339 console.error('Erro ao iniciar bot:', error);340 this.updateStatus('Erro ao iniciar bot', 'error');341 }342 }343 stopBot() {344 try {345 this.isBotRunning = false;346 if (this.gameInterval) {347 clearInterval(this.gameInterval);348 this.gameInterval = null;349 }350 this.updateStatus('Bot parado', 'ready');351 352 const startBtn = document.getElementById('startBot');353 if (startBtn) {354 startBtn.textContent = 'Iniciar Bot Automático';355 startBtn.classList.remove('bg-red-600', 'hover:bg-red-700');356 startBtn.classList.add('bg-green-600', 'hover:bg-green-700');357 }358 } catch (error) {359 console.error('Erro ao parar bot:', error);360 this.updateStatus('Erro ao parar bot', 'error');361 }362 }363 async checkGameStatus() {364 try {365 const gameData = await this.fetchGameData();366 await this.processGameData(gameData);367 } catch (error) {368 console.error('Erro ao verificar status do jogo:', error);369 this.handleGameError(error);370 }371 }372 async fetchGameData() {373 try {374 // Simulate game data since the actual API might not be accessible375 return new Promise((resolve) => {376 setTimeout(() => {377 const colors = ['red', 'black', 'white'];378 const result = colors[Math.floor(Math.random() * colors.length)];379 resolve({380 id: Date.now().toString(),381 color: result,382 roll: result === 'red' ? Math.floor(Math.random() * 7) + 1 : 383 result === 'black' ? Math.floor(Math.random() * 7) + 8 : 0,384 created_at: new Date().toISOString()385 });386 }, 1000);387 });388 } catch (error) {389 throw new Error('Falha ao buscar dados do jogo: ' + error.message);390 }391 }392async processGameData(gameData) {393 try {394 if (!gameData) {395 throw new Error('Dados do jogo não fornecidos');396 }397 398 if (!this.currentGame || this.currentGame.id !== gameData.id) {399 this.currentGame = gameData;400 await this.handleNewGame();401 }402 } catch (error) {403 throw new Error('Erro no processamento dos dados do jogo: ' + error.message);404 }405 }406 async handleNewGame() {407 try {408 // Verificar condições de parada409 if (this.shouldStopForWin() || this.shouldStopForLoss()) {410 this.stopBot();411 return;412 }413 414 if (this.currentGale === 0) {415 // First bet of the sequence416 await this.placeBet(this.baseBetAmount, this.selectedColor);417 } else {418 // Gale bet - calcular com base na estratégia419 const galeAmount = this.calculateGaleAmount();420 await this.placeBet(galeAmount, this.selectedColor);421 }422 423 this.updateStatus(`Aposta ${this.currentGale === 0 ? 'inicial' : 'gale ' + this.currentGale} realizada`, 'working');424 } catch (error) {425 throw new Error('Erro ao lidar com novo jogo: ' + error.message);426 }427 }428 calculateGaleAmount() {429 try {430 const strategy = this.currentStrategy;431 const baseAmount = this.baseBetAmount;432 const currentGale = this.currentGale;433 434 switch (strategy) {435 case 'martingale':436 return baseAmount * Math.pow(this.strategies.martingale.multiplier, currentGale);437 case 'dAlembert':438 return baseAmount + (currentGale * baseAmount * 0.1);439 case 'fibonacci':440 const sequence = this.strategies.fibonacci.sequence;441 const multiplier = sequence[Math.min(currentGale, sequence.length - 1)];442 return baseAmount * multiplier;443 case 'custom':444 return baseAmount * Math.pow(this.strategies.custom.multiplier, currentGale);445 default:446 return baseAmount * Math.pow(2, currentGale);447 }448 } catch (error) {449 console.error('Erro ao calcular valor do gale:', error);450 return this.baseBetAmount * Math.pow(2, this.currentGale);451 }452 }453shouldStopForWin() {454 try {455 if (this.stopWin > 0 && this.totalProfit >= this.stopWin) {456 this.addGameHistory(`🏆 STOP WIN ATINGIDO! Lucro: R$ ${this.totalProfit}`);457 this.updateStatus('Stop Win atingido! Bot parado.', 'ready');458 return true;459 }460 return false;461 } catch (error) {462 console.error('Erro ao verificar Stop Win:', error);463 return false;464 }465 }466 467 shouldStopForLoss() {468 try {469 if (this.stopLoss > 0 && this.totalProfit <= -this.stopLoss) {470 this.addGameHistory(`💸 STOP LOSS ATINGIDO! Prejuízo: R$ ${Math.abs(this.totalProfit)}`);471 this.updateStatus('Stop Loss atingido! Bot parado.', 'error');472 return true;473 }474 return false;475 } catch (error) {476 console.error('Erro ao verificar Stop Loss:', error);477 return false;478 }479 }480 async placeBet(amount, color) {481 try {482 return new Promise((resolve, reject) => {483 try {484 setTimeout(() => {485 try {486 this.simulateGameResult(amount, color);487 resolve();488 } catch (error) {489 reject(new Error('Erro na simulação do resultado: ' + error.message));490 }491 }, 1500);492 } catch (error) {493 reject(new Error('Erro no processo de aposta: ' + error.message));494 }495 });496 } catch (error) {497 throw new Error('Falha ao realizar aposta: ' + error.message);498 }499 }500 simulateGameResult(amount, color) {501 try {502 const random = Math.random();503 let result;504 505 if (random < 0.45) {506 result = 'red';507 } else if (random < 0.90) {508 result = 'black';509 } else {510 result = 'white';511 }512 513 const won = result === color;514 515 this.recordBetResult(amount, color, result, won);516 517 if (won) {518 this.handleWin(amount, color);519 } else {520 this.handleLoss(amount);521 }522 } catch (error) {523 console.error('Erro na simulação do resultado:', error);524 this.handleGameError(error);525 }526 }527 handleWin(amount, color) {528 try {529 this.wins++;530 this.currentGale = 0;531 532 // Calcular lucro533 const payout = color === 'white' ? 14 : 2;534 const profit = (amount * payout) - amount;535 this.totalProfit += profit;536 537 this.updateStats();538 this.addGameHistory(`🎉 WIN! ${color} - R$ ${amount} (Lucro: R$ ${profit.toFixed(2)})`);539 this.updateStatus('Vitória! Próxima aposta...', 'ready');540 541 // Verificar se atingiu Stop Win542 if (this.shouldStopForWin()) {543 this.stopBot();544 }545 } catch (error) {546 console.error('Erro ao processar vitória:', error);547 this.handleGameError(error);548 }549 }550 handleLoss(amount) {551 try {552 this.currentGale++;553 554 // Calcular prejuízo555 const loss = amount;556 this.totalProfit -= loss;557 558 if (this.currentGale > this.maxGales) {559 this.losses++;560 this.currentGale = 0;561 this.addGameHistory(`💔 LOSS! Gale ${this.maxGales} - R$ ${amount} (Prejuízo: R$ ${loss.toFixed(2)})`);562 this.updateStatus(`Loss após ${this.maxGales} gales`, 'error');563 } else {564 this.addGameHistory(`🔁 Gale ${this.currentGale} - R$ ${amount}`);565 this.updateStatus(`Gale ${this.currentGale} de ${this.maxGales}`, 'working');566 }567 568 this.updateStats();569 570 // Verificar se atingiu Stop Loss571 if (this.shouldStopForLoss()) {572 this.stopBot();573 }574 } catch (error) {575 console.error('Erro ao processar derrota:', error);576 this.handleGameError(error);577 }578 }579 580 handleGameError(error) {581 try {582 console.error('Erro no jogo:', error);583 this.addGameHistory(`⚠️ ERRO: ${error.message}`);584 this.updateStatus('Erro no processo do jogo', 'error');585 } catch (innerError) {586 console.error('Erro crítico no tratamento de erro:', innerError);587 }588 }589 recordBetResult(amount, color, result, won) {590 try {591 this.betHistory.unshift({592 amount,593 color,594 result,595 won,596 profit: won ? (amount * (color === 'white' ? 14 : 2) - amount : -amount,597 timestamp: new Date().toLocaleTimeString()598 });599 } catch (error) {600 console.error('Erro ao registrar resultado da aposta:', error);601 }602 }603 addGameHistory(message) {604 try {605 const historyElement = document.getElementById('gameHistory');606 if (!historyElement) {607 console.error('Elemento de histórico não encontrado');608 return;609 }610 611 const entry = document.createElement('div');612 entry.className = 'game-entry bg-gray-700 p-3 rounded-lg';613 entry.innerHTML = `614 <div class="flex justify-between items-center">615 <span>${message}</span>616 <span class="text-gray-400 text-sm">${new Date().toLocaleTimeString()}</span>617 </div>618 `;619 620 historyElement.insertBefore(entry, historyElement.firstChild);621 622 // Limit history to 20 entries623 if (historyElement.children.length > 20) {624 historyElement.removeChild(historyElement.lastChild);625 }626 } catch (error) {627 console.error('Erro ao adicionar histórico:', error);628 }629 }630updateStats() {631 try {632 const winsElement = document.getElementById('wins');633 const lossesElement = document.getElementById('losses');634 const balanceElement = document.getElementById('balance');635 636 if (winsElement) winsElement.textContent = this.wins;637 if (lossesElement) lossesElement.textContent = this.losses;638 if (balanceElement) {639 const currentBalance = (this.initialBalance + this.totalProfit).toFixed(2);640 balanceElement.textContent = `R$ ${currentBalance}`;641 }642 } catch (error) {643 console.error('Erro ao atualizar estatísticas:', error);644 }645 }646 updateBalance() {647 try {648 const balanceElement = document.getElementById('balance');649 if (balanceElement) {650 const currentBalance = (this.initialBalance + this.totalProfit).toFixed(2);651 balanceElement.textContent = `R$ ${currentBalance}`;652 }653 } catch (error) {654 console.error('Erro ao atualizar saldo:', error);655 }656 }657 updateStatus(message, type = 'ready') {658 try {659 const statusElement = document.getElementById('status');660 if (statusElement) {661 statusElement.textContent = message;662 statusElement.className = '';663 664 switch (type) {665 case 'ready':666 statusElement.classList.add('text-green-400');667 break;668 case 'working':669 statusElement.classList.add('text-yellow-400');670 break;671 case 'error':672 statusElement.classList.add('text-red-400');673 break;674 }675 }676 } catch (error) {677 console.error('Erro ao atualizar status:', error);678 }679 }680}681 682// Initialize the bot when the page loads683document.addEventListener('DOMContentLoaded', () => {684 window.blazeBot = new BlazeDoubleBot();685});686 