Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!