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

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