UNPKG

notmebotz-tools

Version:

Sebuah Tools yang berfungsi untuk mendownload Video atau Foto dari media sosial, serta sebagai tools yang berguna untuk aplikasi kamu seperti untuk BOT

68 lines (60 loc) 2.2 kB
/* * * [ *SCRAPE XBOX STALK* ] * Created By Hann * Modified By Herza - JSON Return Only * * Channel: https://whatsapp.com/channel/0029Vaf07jKCBtxAsekFFk3i * **/ const axios = require('axios'); const cheerio = require('cheerio'); async function xboxStalk(teks) { try { const { data } = await axios.get('https://xboxgamertag.com/search/' + teks); const $ = cheerio.load(data); let gamerscore = 0; let gamesPlayed = 0; $('.profile-detail-item').each((index, element) => { const title = $(element).find('span').text(); const value = $(element).text().replace(title, '').trim(); if (title.includes("Gamerscore")) { gamerscore = parseInt(value.replace(/,/g, ''), 10) || 0; } if (title.includes("Games Played")) { gamesPlayed = parseInt(value, 10) || 0; } }); const gamertag = { author: "Herza", status: 200, data: { name: $('h1 a').text(), avatar: $('.avatar img').attr('src'), gamerscore: gamerscore, gamesPlayed: gamesPlayed, gameHistory: [] } }; $('.recent-games .game-card').each((index, element) => { const game = { title: $(element).find('h3').text(), lastPlayed: $(element).find('.text-sm').text().replace('Last played ', ''), platforms: $(element).find('.text-xs').text(), gamerscore: $(element).find('.badge:contains("Gamerscore")').parent().next().text().trim(), achievements: $(element).find('.badge:contains("Achievements")').parent().next().text().trim(), progress: ($(element).find('.progress-bar').attr('style') || 'width: 0%;').match(/width: (.*?);/)[1] || '0%' }; gamertag.data.gameHistory.push(game); }); return gamertag; } catch (error) { return { status: 500, author: "Herza", error: error.message, data: null }; } } module.exports = { xboxStalk }