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

103
Views
how do i launch index.html from backgrund.js?

im trying to make a chrome extension and i have this code in background.js that gets the url of the website that im on:

console.log("service worker: running")




let urls = []

let interval = setInterval(getUrl, 1000)

function getUrl(){
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
            urls.push(tabs[0].url) 
            //console.log(urls)

            let urlToBeParsed = urls[0]

            let finalUrl = urlToBeParsed.toString()

            urls = []
            console.log(finalUrl)
    });

}

how do i check if a statement is true or false, and if its true launch index.html

const keyWords =  ["red", "green", "blue"]


// FYI when the keyword is not in the string you are looking for it returns -1
if (finalUrl.indexOf(keyWords[0]) !== -1 || finalUrl.indexOf(keyWords[1]) !== -1  || finalUrl.indexOf(keyWords[2]) !== -1 ) {
// open index.html

} else {
console.log("keywords not in url")
}

thank you in advance!

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!