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

159
Views
Chrome extension issue with popup.js

I am working on a chrome extension, I have the following code in my popup.js which works correctly if the background page finishes loading, however, if I try to open the extension before the page finishes loading there is a JS error and nothing get executed;

There error I get in the extension report is: Uncaught TypeError: Cannot read properties of undefined (reading 'query') I have tried a few typeOf == undefined and add a delay until it loads but with not success.

    function initHome()
    {

        try {



            chrome.tabs.query({ 
            //This method output active URL 
                "active": true,
                "currentWindow": true,
                "status": "complete",
                "windowType": "normal"
            }, function (tabs) {
                for (tab in tabs) {
              
                    if(tabs[tab].active == true)
                    {

                        var  newUrl = new URL(tabs[tab].url);
                        var currentTab = tabs[0];
                         currentDomain = newUrl.hostname.replace('www.','');
                       
                        $('#header_domain').html(currentDomain);
                        
                        if(currentDomain.indexOf('google.') == -1 && currentDomain.indexOf('chrome') == -1)
                            process_home(currentDomain);

                       
                    }
          
                }
            });     


            } catch (error) {
              console.error(error);

            }

    }

    initHome();
about 4 years ago · Juan Pablo Isaza
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!