// Retrieve the previous value from local storage var previousValue = null; function sendTelegramMessage() { // Telegram API settings and sending messages var telegramAPIURL = 'https://api.telegram.org/bot{BOT_TOKEN}/sendMessage'; // Replace with your Bot Token var chatID = '{CHAT_ID}'; // Replace with your target chat ID // Getting the text and link from the HTML elements var titleElement = document.querySelector('.structItem-cell.structItem-cell--main .structItem-title a'); var message = titleElement.textContent; var link = titleElement.href; if (previousValue !== message) { var data = { chat_id: chatID, text: message, reply_markup: JSON.stringify({ inline_keyboard: [ [ { text: 'Go to Link', url: link } ] ] }) }; // Send message to Telegram using AJAX request fetch(telegramAPIURL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(function (response) { console.log('Message sent to Telegram successfully:', response); // Store the current value in local storage localStorage.setItem('previousValue', message); }) .catch(function (error) { console.error('Error sending message to Telegram:', error); }); } else { console.log('No change in value. Message not sent to Telegram.'); } } // Check for changes every 5 seconds setInterval(sendTelegramMessage, 5000);