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

302
Vistas
CHROME - EXTENSIONS: chrome.webRequest.onBeforeRequest does not finish the process?

I am working on a project which produces a google extension. In my extension, I tried to access resources of a website. Here is my code

 if (requestArray.length !== 0) {
    requestArray = []
  }
  if (resourcesCategories.length !== 0) {
    resourcesCategories = []
  }
  if (mywebsiteCategories.length !== 0) {
    mywebsiteCategories = []
  }

  getWebsiteCategories().then((webCat) => {
    if (webCat.length !== 0) {
      setWebsiteCategories([])
    }
  })

  getResourcesCategories().then((resCat) => {
    if (resCat.length !== 0) {
      setResourcesCategories([])
    }
  })
  getResources().then((res) => {
    if (res.length !== 0) {
      setResources([])
    }
  })
  chrome.webRequest.onBeforeRequest.addListener(
    (details) => {
      if (details && details.tabId !== -1 && details.tabId === tabId) {
        if (!requestArray.includes(details.url.split('/')[2])) {
          requestArray.push(details.url.split('/')[2])
          apiCheck(
            requestArray,
            tabId,
            mywebsiteCategories,
            resourcesCategories
          )
        }
      }
      getURL().then((host) => {
        if (host && !requestArray.includes(host)) {
          requestArray.push(host)
          apiCheck(
            requestArray,
            tabId,
            mywebsiteCategories,
            resourcesCategories
          )
        }
        setResources(requestArray)
      })
    },
    {
      urls: ['<all_urls>'],
    }
  )
 

I use webRequest API for access resources. For every tab, my function works again. However, when I change the tab I still see another tabs resources. I think before tab still working. Bu I want it finished there and work for my new tab again. How can I do that?

I am adding an image for more understandable.

image

I am telling my actions: First I open nytimes.com tab. Then I switch trklvs.com tab. It doesnt have any resource. However, after some time, I saw nytimes.com resources. (I think it still updating.) How can I fix that?

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