Why JS don’t show the last message in Telegram? [duplicate]

I am writing a chrome extension. I want to know the user’s last message in a telegram conversation. Here is my code:

js:

function getLastMessage() {
    const messages = document.querySelectorAll('.Message'); 

    if (messages.length > 0) {
        const lastMessage = messages[messages.length - 1];
        const messageText = lastMessage.querySelector('.text')?.innerText || "Нет текста";
        
        alert("Last message:", messageText);
 
    } else {
        alert("There are no messages");
    }
}
document.getElementById('myButton').addEventListener('click', function() {
    getLastMessage();
});

json:

{
    "manifest_version": 3,
    "name": "My Simple Button Extension",
    "version": "1.0",
    "description": "An extension with a single button.",
    "action": {
      "default_popup": "popup.html",
      "default_icon": "icon.webp"
    },
    "permissions": []
  }

This code alert “There are no messages” always but there are messages in chat.
Please, help me.

I can’t find anything in web