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

371
Views
Chrome extension V3 Cannot read properties of undefined setBadgeBackgroundColor

I'm trying to make a V3 Chrome Extension work, but I'm not sure how to change this V2 code that works.

manifest.json

{
  "name": "Extension name",
  "version": "1.0",
  "manifest_version": 3,
  "description": "Display API Info.",
  "background": {
    "service_worker": "background.js"
  },
  "icons": {
    "16": "./icons/icon16.png",
    "48": "./icons/icon48.png",
    "128": "./icons/icon128.png"
  },
  "action": {}
}

background.js

chrome.browserAction.setBadgeBackgroundColor({ color: "green" });

const setStuff = () => {
    chrome.browserAction.setBadgeText({ text: `...` });
}

const callApi = () => {
    setStuff();

    setTimeout(() => fetch('https://api.com/api')
        .then(response => response.json())
        .then(data => {
            chrome.browserAction.setBadgeText({ text: `${data.info}` });
        }).catch(error => console.log(error)), 5000)

}

callApi()

setInterval(function () {
    callApi()
}, 300000);

Getting this error when testing it locally

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'setBadgeBackgroundColor')
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change your code that is manifest v2:

chrome.browserAction.setBadgeBackgroundColor({ color: "green" });

const setStuff = () => {
    chrome.browserAction.setBadgeText({ text: `...` });
}

To this code for Chrome extension manifest v3:

chrome.action.setBadgeBackgroundColor({ color: "green" });

const setStuff = () => {
    chrome.action.setBadgeText({ text: `...` });
}
about 4 years ago · Juan Pablo Isaza Report
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!