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

182
Vistas
Chrome Extension connection with the app is not working

Working on a project where an app needs to connect with a chrome extension that needs to migrate from manifest v2 to v3.

Detail: In manifest v2 inside the background.js we inject the script (which contains some dataset) that gets the file from another server which contains logic and some UI components (Vue JS).

We don't inject the script directly into the service worker in v3 because there is no access to DOM. So we move all of the code from another server to our project to run directly. But we need a way to pass a dataset that was previously passed from the script in v2

This is the code snippet that I need to be changed from v2 to v3. Kindly have a look into it.

function injectScript(name, { cachebuster, tabId } = {}) {
  const scriptSrc = new URL(process.env.ASSETS_URL)

  scriptSrc.pathname = `${scriptSrc.pathname}${name}.js`
  scriptSrc.search = `cachebuster=${cachebuster}`

  script = document.createElement("script")

  script.type = "text/javascript"
  script.id = `app_io_robot_${name}`
  script.setAttribute("defer", "")

  script.src = scriptSrc.toString()
  script.dataset.extension_id = chrome.runtime.id
  script.dataset.extension_name = process.env.EXTENSION_NAME
  script.dataset.extension_version = runtimeManifest.version
  script.dataset.app_url = process.env.APP_URL
  script.dataset.api_url = process.env.API_URL
  script.dataset.installed_manually = !runtimeManifest.update_url

  if (tabId) {
    script.dataset.tab_id = tabId
  }

  const ONE_MINUTE = 60

  script.onerror = function () {
    console.error(`Unable to load extension, retry in ${ONE_MINUTE} seconds`)

    script.remove()
    setTimeout(() => {
      console.info("Trying to reload extension")

      injectScript(name, { cachebuster, tabId })
    }, ONE_MINUTE * 1000)
  }

  document.getElementsByTagName("head")[0].appendChild(script)
}
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