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

228
Visualizações
How to check if a button exists?

I'm learning to create a chrome extension. I want to create an extension to find a button and show alerts that found it

The button is

<button class="bt bt-sm text-white btn-flashing"
style="background-color: #fd7e14; margin:3px" disabled="">ABC - 01</button>

So how i can write a script to find that?

I have a script for showing the alert

chrome.browserAction.onClicked.addListener(function() { 
        alert("found it");
})

Thank you.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

chrome.browserAction.onClicked.addListener(function() { 
//Checking if there are any results of the button with that class
        if(document.querySelectorAll('.bt bt-sm text-white btn-flashing').length >= 1){
//Found results of the button

}else{
//Found no results of the button

});

All this code says is if there are more than 0 occurances of ".bt bt-sm text white btn-flashing" then it found results.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use a content script to check for the presence of the button.

For example:

chrome.browserAction.onClicked.addListener(function(){
    chrome.tabs.executeScript({
        code: 'document.querySelector("button.bt.bt-sm.text-white.btn-flashing")'
    }, function(result) {
        if (result[0]) {
            alert('found it');
        } else {
            alert('not found');
        }
    });
});
about 4 years ago · Juan Pablo Isaza Relatório
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