Update miner.js
Browse files13 unmodified lines141516171819204 unmodified lines25262728293031323334358 unmodified lines4445464748495051525354555657585960616263646566676869707172737413 unmodified lines};// Kita coba ambil berdasarkan ID yang biasa dipakai (hashrate, shares, rejects)// Jika webminer memiliki struktur berbeda, ini akan mencoba fallback ke teks umumconst hr = getValue('hashrate') || getValue('hr') || document.querySelector('.hashrate')?.innerText || '0 H/s';const shares = getValue('shares') || getValue('accepted') || document.querySelector('.shares')?.innerText || '0';const rejects = getValue('rejects') || getValue('rejected') || document.querySelector('.rejects')?.innerText || '0';4 unmodified lines(async () => {console.log('========================================');console.log('MEMULAI DOCKER WEB MINER...');console.log('========================================');const browser = await puppeteer.launch({headless: 'new',args: ['--no-sandbox','--disable-setuid-sandbox',8 unmodified linesconst page = await browser.newPage();// Set User-Agent agar terlihat seperti Chrome biasaawait page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36');try {console.log(`[INFO] Membuka URL: ${TARGET_URL}`);await page.goto(TARGET_URL, { waitUntil: 'networkidle2', timeout: 60000 });console.log('[INFO] Halaman terbuka. Menunggu inisialisasi miner (10 detik)...');// Tunggu sebentar agar script JS di halaman bisa load dan mulai miningawait new Promise(resolve => setTimeout(resolve, 10000));// Loop untuk menampilkan stats setiap 5 detiksetInterval(async () => {try {const stats = await scrapeStats(page);// Tampilkan output yang rapiconst time = new Date().toLocaleTimeString();console.log(`[${time}] HASH: ${stats.hr} | SHARE: ${stats.shares} | REJECT: ${stats.rejects}`);} catch (e) {console.log('[ERROR] Gagal mengambil data stats:', e.message);}}, 5000); // Update setiap 5 detik// Biarkan process tetap hidupprocess.on('SIGINT', async () => {await browser.close();process.exit();13 unmodified lines1415161718194 unmodified lines24252627282930313233348 unmodified lines4344454647484950515253545556575859606162636465666768697013 unmodified lines};// Kita coba ambil berdasarkan ID yang biasa dipakai (hashrate, shares, rejects)const hr = getValue('hashrate') || getValue('hr') || document.querySelector('.hashrate')?.innerText || '0 H/s';const shares = getValue('shares') || getValue('accepted') || document.querySelector('.shares')?.innerText || '0';const rejects = getValue('rejects') || getValue('rejected') || document.querySelector('.rejects')?.innerText || '0';4 unmodified lines(async () => {console.log('========================================');console.log('MEMULAI DOCKER WEB MINER (UPDATED)...');console.log('========================================');const browser = await puppeteer.launch({headless: 'new', // Gunakan mode headless baruargs: ['--no-sandbox','--disable-setuid-sandbox',8 unmodified linesconst page = await browser.newPage();// Set User-Agentawait page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36');try {console.log(`[INFO] Membuka URL: ${TARGET_URL}`);await page.goto(TARGET_URL, { waitUntil: 'networkidle2', timeout: 60000 });console.log('[INFO] Halaman terbuka. Menunggu inisialisasi miner (10 detik)...');await new Promise(resolve => setTimeout(resolve, 10000));// Loop untuk menampilkan stats setiap 5 detiksetInterval(async () => {try {const stats = await scrapeStats(page);const time = new Date().toLocaleTimeString();console.log(`[${time}] HASH: ${stats.hr} | SHARE: ${stats.shares} | REJECT: ${stats.rejects}`);} catch (e) {console.log('[ERROR] Gagal mengambil data stats:', e.message);}}, 5000);// Handle shutdownprocess.on('SIGINT', async () => {await browser.close();process.exit();
miner.js+6-10