Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda