17

This is my first attempt writing a Chrome extension. I added "web_accessible_resources": ["images/icon.png"] to manifest.json because I wanted to access the image from content script. After adding this line, I got the error "Invalid value for 'web_accessible_resources[0]'. Could not load manifest." I have checked to make sure the file path is correct, where else could I be wrong? Any help is appreciated.

{
    "name": "Bookmark Checker",
    "version": "1.0",
    "manifest_version": 3,
    "permissions": [
        "bookmarks",
        "activeTab"
    ],
    "background": {
        "service_worker": "background.js"
    },
    "content_scripts": [
        {
            "matches":["https://www.google.com/search?*"],
            "js": ["content/content.js"]
        }
    ],
    ...
    "web_accessible_resources": ["images/icon.png"]
}
wOxxOm
  • 65,848
  • 11
  • 132
  • 136
chau-phan
  • 801
  • 1
  • 6
  • 12

1 Answers1

50

The syntax for web_accessible_resources in Manifest V3 has changed:

"web_accessible_resources": [{ 
  "resources": ["/images/icon.png"],
  "matches": ["<all_urls>"]
}]

The matches key must specify where to expose these resources since Chrome 89.

wOxxOm
  • 65,848
  • 11
  • 132
  • 136
chau-phan
  • 801
  • 1
  • 6
  • 12
  • 6
    You probably need to specify some matches to get it to work, e.g. `"matches": ["http://*/*", "https://*/*"]` for the same behavior as in MV2, or a more specific set of URLs – gengkev Mar 15 '21 at 02:51
  • 2
    Absolutely TYPICAL Google. As of this date https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/ still mentions "The matches, extension_ids, and use_dynamic_url keys are not available yet. Support for these properties will be coming in a future release." – AntonOfTheWoods May 24 '21 at 06:05