Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!