Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function to make a GET request to the Telegram API
- function sendMessageToXC(msg) {
- const apiUrl = `https://api.telegram.org/bot1498894757:AAEosFO7-zkw2wk3in_3z0tviW_lVeG34sM/sendMessage?chat_id=283993474&text=${encodeURIComponent(msg)}`;
- fetch(apiUrl)
- .then(response => {
- if (!response.ok) {
- throw new Error('Network response was not ok');
- }
- return response.json();
- })
- .then(data => {
- console.log('Telegram API response:', data);
- })
- .catch(error => {
- console.error('Error sending message to Telegram:', error);
- });
- }
- // Function to check for changes in coin amounts and send a message if there's a change
- function checkCoinAmountsAndSendNotification() {
- const pixelElement = document.querySelector('.Hud_pixelcoin__EUbKE .commons_coinBalance__d9sah');
- const coinElement = document.querySelector('.Hud_berry__6A2FS .commons_coinBalance__d9sah');
- const energyElement = document.querySelector('.Hud_energytext__3PQZQ');
- if (!pixelElement || !coinElement || !energyElement) {
- console.error('One or more elements not found');
- return;
- }
- const pixelAmount = parseInt(pixelElement.textContent.replace(/,/g, ''));
- const coinAmount = parseInt(coinElement.textContent.replace(/,/g, ''));
- const energyAmount = parseFloat(energyElement.textContent);
- if (previousPixelAmount === null || previousCoinAmount === null || previousEnergyAmount === null) {
- previousPixelAmount = pixelAmount;
- previousCoinAmount = coinAmount;
- previousEnergyAmount = energyAmount;
- return;
- }
- if (energyAmount !== previousEnergyAmount) {
- const pixelChange = pixelAmount - previousPixelAmount;
- const coinChange = coinAmount - previousCoinAmount;
- const energyChange = energyAmount - previousEnergyAmount;
- const coinEmoji = coinChange > 0 ? "🟩" : coinChange < 0 ? "🟥" : "⬛️";
- const pixelEmoji = pixelChange > 0 ? "🟩" : pixelChange < 0 ? "🟥" : "⬛️";
- const energyEmoji = energyChange > 0 ? "🟩" : energyChange < 0 ? "🟥" : "⬛️";
- const msg = `
- 👩🏻🌾 | Acc : XC
- ${coinEmoji} | Coin : ${coinAmount} | ${coinChange}
- ${pixelEmoji} | Pixel : ${pixelAmount} | ${pixelChange}
- ${energyEmoji} | E : ${energyAmount} | ${energyChange}`;
- sendMessageToXC(msg);
- previousPixelAmount = pixelAmount;
- previousCoinAmount = coinAmount;
- previousEnergyAmount = energyAmount;
- }
- }
- // Variables to store previous amounts
- let previousPixelAmount = null;
- let previousCoinAmount = null;
- let previousEnergyAmount = null;
- // Function to periodically check for changes in coin amounts
- function checkForChangesPeriodically() {
- checkCoinAmountsAndSendNotification();
- setInterval(checkCoinAmountsAndSendNotification, 120000); // Check every 2 minutes
- }
- // Start checking for changes periodically
- checkForChangesPeriodically();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement