Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extensions: Use the "background.service_worker" key instead manifest_version 3

When trying to install a chrome extension using manifest_version 3, I am unable to install as I keep getting the error:

The "background.scripts" key cannot be used with manifest_version 3. Use the "background.service_worker" key instead

or

The "background.persistent" key cannot be used with manifest_version 3. Use the "background.service_worker" key instead.

like image 248
KJ Sudarshan Avatar asked Feb 05 '21 00:02

KJ Sudarshan


People also ask

Where can I buy how to build a Chrome extension Manifest V3?

If you need an easy to follow along video tutorial, you can purchase How To Build a Chrome Extension Manifest V3 over on our Teachable platform. Use discount code: ANOBJ for 20% off.

How do I Register my background service workers in the manifest?

Extensions register their background service workers in the manifest under the "background" field. This field uses the "service_worker" key, which specifies a single JavaScript file. In Manifest V2, this field was called "scripts" and allowed multiple scripts.

What is the new service worker in manifest?

Instead it now supports a new feature called service workers. The key background in your manifest.json can no longer contain the field persistent, and also update the value from scripts to service_worker. Service worker cannot contain an array but can only contain a single string value.

What is the difference between service_worker and key background?

The key background in your manifest.json can no longer contain the field persistent, and also update the value from scripts to service_worker. Service worker cannot contain an array but can only contain a single string value.


1 Answers

Manifest V3 no longer supports background pages. Instead it now supports a new feature called service workers.

The key background in your manifest.json can no longer contain the field persistent, and also update the value from scripts to service_worker. Service worker cannot contain an array but can only contain a single string value.

Eg:

{
  "name": "Test",
  "description" : "Test Chrome Extension",
  "version": "1.0",
  "manifest_version": 3,
  "background": {
    "service_worker": "background.js"
  }
}

Ref: Manifest V3 Migration Checklist

like image 100
KJ Sudarshan Avatar answered Oct 17 '22 08:10

KJ Sudarshan