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

104
Visualizações
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
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