Advertisement
xpppppppaicyber

Untitled

Jun 21st, 2024
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Function to make a GET request to the Telegram API
  2. function sendMessageToXC(msg) {
  3.     const apiUrl = `https://api.telegram.org/bot1498894757:AAEosFO7-zkw2wk3in_3z0tviW_lVeG34sM/sendMessage?chat_id=283993474&text=${encodeURIComponent(msg)}`;
  4.  
  5.     fetch(apiUrl)
  6.         .then(response => {
  7.             if (!response.ok) {
  8.                 throw new Error('Network response was not ok');
  9.             }
  10.             return response.json();
  11.         })
  12.         .then(data => {
  13.             console.log('Telegram API response:', data);
  14.         })
  15.         .catch(error => {
  16.             console.error('Error sending message to Telegram:', error);
  17.         });
  18. }
  19.  
  20. // Function to check for changes in coin amounts and send a message if there's a change
  21. function checkCoinAmountsAndSendNotification() {
  22.     const pixelElement = document.querySelector('.Hud_pixelcoin__EUbKE .commons_coinBalance__d9sah');
  23.     const coinElement = document.querySelector('.Hud_berry__6A2FS .commons_coinBalance__d9sah');
  24.     const energyElement = document.querySelector('.Hud_energytext__3PQZQ');
  25.  
  26.     if (!pixelElement || !coinElement || !energyElement) {
  27.         console.error('One or more elements not found');
  28.         return;
  29.     }
  30.  
  31.     const pixelAmount = parseInt(pixelElement.textContent.replace(/,/g, ''));
  32.     const coinAmount = parseInt(coinElement.textContent.replace(/,/g, ''));
  33.     const energyAmount = parseFloat(energyElement.textContent);
  34.  
  35.     if (previousPixelAmount === null || previousCoinAmount === null || previousEnergyAmount === null) {
  36.         previousPixelAmount = pixelAmount;
  37.         previousCoinAmount = coinAmount;
  38.         previousEnergyAmount = energyAmount;
  39.         return;
  40.     }
  41.  
  42.     if (energyAmount !== previousEnergyAmount) {
  43.         const pixelChange = pixelAmount - previousPixelAmount;
  44.         const coinChange = coinAmount - previousCoinAmount;
  45.         const energyChange = energyAmount - previousEnergyAmount;
  46.  
  47.         const coinEmoji = coinChange > 0 ? "🟩" : coinChange < 0 ? "🟥" : "⬛️";
  48.         const pixelEmoji = pixelChange > 0 ? "🟩" : pixelChange < 0 ? "🟥" : "⬛️";
  49.         const energyEmoji = energyChange > 0 ? "🟩" : energyChange < 0 ? "🟥" : "⬛️";
  50.  
  51.         const msg = `
  52. 👩🏻‍🌾 | Acc : XC
  53. ${coinEmoji} | Coin : ${coinAmount} | ${coinChange}
  54. ${pixelEmoji} | Pixel : ${pixelAmount} | ${pixelChange}
  55. ${energyEmoji} | E : ${energyAmount} | ${energyChange}`;
  56.         sendMessageToXC(msg);
  57.  
  58.         previousPixelAmount = pixelAmount;
  59.         previousCoinAmount = coinAmount;
  60.         previousEnergyAmount = energyAmount;
  61.     }
  62. }
  63.  
  64. // Variables to store previous amounts
  65. let previousPixelAmount = null;
  66. let previousCoinAmount = null;
  67. let previousEnergyAmount = null;
  68.  
  69. // Function to periodically check for changes in coin amounts
  70. function checkForChangesPeriodically() {
  71.     checkCoinAmountsAndSendNotification();
  72.     setInterval(checkCoinAmountsAndSendNotification, 120000); // Check every 2 minutes
  73. }
  74.  
  75. // Start checking for changes periodically
  76. checkForChangesPeriodically();
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement