0

I am trying to access the getUserSettings method on the chrome API and always get an error that "property getUserSettings is not defined on typeof action" when trying to call it. Is this method deprecated?

I have listed my manifest.json below, all I am doing is trying to print out the user settings in the background.js file: chrome.action.getUserSettings((userSettings) => console.log(userSettings));

    "name": "test",
    "description": "test",
    "background": {
        "service_worker": "background.js"
    },
    "manifest_version": 3,
    "version": "0.0.1",
    "permissions": ["tabs"],
    "action": {
        "default_icon": {
            "16": "icon.png",
        },
        "default_popup": "popup.html"
    }
}

In the documentation the return type of this function is listed as pending, but I have seen many other examples of people using this function in V3 of the manifest without issue, even looking through some of the deprecated features in the chrome blog did not seem to mention this function.

enter image description here

Nexxus
  • 131
  • 1
  • 9
  • 1
    The error you see is shown by your IDE or compiler, apparently, so it's not related to the API or the browser. I guess you're using an outdated [chrome-types](https://www.npmjs.com/package/chrome-types) package. Just in case, see how to open the [correct devtools console](/a/10258029). – wOxxOm Feb 18 '22 at 04:54
  • I get a runtime error of ```Uncaught TypeError: Cannot read properties of undefined (reading 'getUserSettings')``` when trying to use this method, my chrome/types version is `^0.0.157`, i tried updating it to the latest version and still see the same issue, is there anything i'm missing in my actions entry or something? – Nexxus Feb 18 '22 at 17:57
  • The error message means that `chrome.action` is undefined, which can only happen if you run this code in a content script or web page context. Another explanation is that you're looking not in devtools but in chrome://extensions UI at an old outdated error which you can clear by clicking the button in that page. – wOxxOm Feb 18 '22 at 18:53
  • Thanks for your reply, the function will work in the service worker script but is still undefined as a type error in the IDE, I will try to use a different package for the chrome API types to see if that helps the error – Nexxus Feb 18 '22 at 22:21

0 Answers0