Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
How to filter chat on whatsapp web using content script?

I am actually creating a chrome extension which creates some tabs in whatsapp web like all, unread, groups etc. And when we select any of these tabs it will filter out the list of contacts on the left bases on the tab.

The issue is that the html structure of the whatsapp chat is very unusual. It is using position:absolute for all the elements of list and use translateY and change it to create a list vertically.

One more thing. The actual number of html elements in list at max goes to 18 and at min can be 0. I cannot understand how they are handling this.

Here is my filter chat function. For now I have only two tabs all and unread. But its not working. When I go to 'unread' and come back to 'all' its showing less results...

const filterChatList = () => {
   //Selects the active tab
   const activeTab = document.querySelector(".ext-tab.active");
   if (activeTab) {
      const chatListWrapper = document.querySelector("._3uIPm"); //The element in which all list items are.
      const name = activeTab.name; //Get the name of tab like "all" | "unread"
      let chatsToShow = [...document.querySelectorAll("._3m_Xw")]; //List of all the items of list

      //Hide all the items first.
      chatsToShow.forEach((x) => {
         x.style.display = "none";
      });
      //Checking if selected tab is "unread"
      if (name === "unread") {
         //Filter out the only chats which have that green unread circle with them
         chatsToShow = chatsToShow.filter((x) => x.querySelector(".aumms1qt"));
      }
      //Change the total height of wrapper
      chatListWrapper.style.height = 72 * chatsToShow.length + "px";
      //Then only display the required items and change their translateY sequentially.
      //Note height of each item is 72.
      chatsToShow.forEach((x, i) => {
         x.style.display = "block";
         x.style.transform = `translateY(${72 * i})`;
      });
   }
};

I am unable to know how we can filter out the chats of the elements. I know the above approach is not correct because if we select all elements we only get 18 elements and chatlist can be longer.

Isn't there any library or any api kind of thing so we can filter the results we want. Many extensions have this tabs feature but there code is bundled so I can't get anything out of it.

If you know any good way of achieving this please let me know. I will be thankful. If any questions feel free to ask.

Here is the link to whatsappweb

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda