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

108
Vistas
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 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