1 year ago

#80122

test-img

Evgeniy

Can't migrate background script to v3 in Chrome extension

I try to migrate my manifest from v2 to v3 and fail with background scripts. I get an error unexpected token. I think my syntax is correct. What I'm doing wrong? How can I migrate this setup with multiple background scripts?

manifest v2

{
   "description": "Tooltip Dictionary",
   "manifest_version": 2,
   "name": "Tooltip Dictionary",
   "permissions": [ "https://www.example.com/*", "storage" ],   
   "version": "1.0.0",
   "icons":{
      "16":"icon16.png",
      "32":"icon32.png",
      "48":"icon48.png",
      "128":"icon128.png"
   },
   "browser_action":{
      "default_icon": "icon32.png"
   },
   "content_scripts":[{
      "matches":["<all_urls>"],
      "js":["jquery.min.js", "tooltip.css.js", "cs.js"]
   }],
   "background":{
      "scripts":[ "jquery.min.js","bg.js" ]
   },
       "commands":{
      "run-script": {
        "suggested_key": {
          "default": "Alt+1",
          "windows": "Alt+1",
          "mac": "Command+E"
        },
        "description": "Run"
      }
    }
}

manifest v3

{
   "description": "Tooltip Dictionary",
   "manifest_version": 3,
   "name": "Tooltip Dictionary",
   "host_permissions": ["https://www.example.com/*"],
   "permissions": ["storage"],
   "version": "1.0.0",
   "icons":{
      "16":"icon16.png",
      "32":"icon32.png",
      "48":"icon48.png",
      "128":"icon128.png"
   },
   "action":{
      "default_icon": "icon32.png"
   },
   "content_scripts":[{
      "matches":["<all_urls>"],
      "js":["jquery.min.js", "tooltip.css.js", "cs.js"]
   }],
  "background": {
        "service_worker": ["jquery.min.js", "bg.js"]
    },
       "commands":{
      "run-script": {
        "suggested_key": {
          "default": "Alt+1",
          "windows": "Alt+1",
          "mac": "Command+E"
        },
        "description": "Run"
      }
    }
}

If I try to use a single background file, it can't be registered too, like on screenshot: enter image description here

enter image description here

enter image description here

chrome-extension-manifest-v3

chrome-extension-manifest-v2

0 Answers

Your Answer

Accepted video resources