Tampermonkey Manifest V3 Changes and How to Adapt

Author

Reads 1.1K

A woman browsing the web on a tablet, sitting in an office environment
Credit: pexels.com, A woman browsing the web on a tablet, sitting in an office environment

With the release of Manifest V3, Tampermonkey users are facing significant changes that affect how scripts are loaded and executed. One of the main changes is the removal of the webRequest API.

This means that scripts that relied on the webRequest API will no longer work as intended. To adapt, you'll need to update your scripts to use the new webRequest API alternatives.

The new webRequest API alternatives are webNavigation and webRequestBlocking, which provide more limited functionality compared to the original webRequest API. However, they can still be used to achieve similar results with some modifications to your scripts.

To get started with updating your scripts, you'll need to understand the differences between the old and new APIs, as well as the limitations of the new alternatives.

What's Changing in Chrome Extensions

Chrome is changing the way extensions work, and it's not all good news. The new Manifest V3 is being rolled out in Chrome 88 Beta, and it brings changes to ad blocking, performance, and privacy.

For more insights, see: Manifest V3 Release Date

Credit: youtube.com, Fix Unsupported Manifest Version in Chrome | Extensions Not Working | Fixed All Extensions

Extensions like Tampermonkey will need to adapt to the new rules. The developer of Tampermonkey is speaking out about how Manifest V3 would stop the extension from working altogether on Chrome.

One of the key differences between Manifest V2 and V3 is the way service workers replace background pages. This change is designed to improve performance, but it could also break some extensions.

Here are the main differences between Manifest V2 and V3:

  • Service workers replace background pages in Manifest V3.
  • Network request modification is handled with the new declarativeNetRequest API in Manifest V3.
  • Extensions can only execute JavaScript that is included within their package and cannot use remotely-hosted code in Manifest V3.
  • Manifest V3 introduces promise support to many methods, though callbacks are still supported as an alternative.
  • Host permissions in Manifest V3 are a separate element and must be specified in the "host_permissions" field.
  • The content security policy in Manifest V3 is an object with members representing alternative content security policy (CSP) contexts, rather than a string as it was in Manifest V2.

These changes will require extension developers to update their code to work with Manifest V3. Some extensions, like ad blockers, may not be able to work at all with the new rules.

Updating to Manifest V3

Updating to Manifest V3 is a crucial step in transitioning your Tampermonkey extension. You'll need to update your manifest's basic structure by changing the "manifest_version" element to 3, which determines that you're using the Manifest V3 feature set.

To do this, you'll need to register a single extension service worker in the "background" field, using the "service_worker" key and specifying a single JavaScript file. This replaces the multiple background scripts supported in Manifest V2.

A fresh viewpoint: Chrome Extension Manifest V3

Credit: youtube.com, How to Continue Using Legacy Manifest V2 Extensions in Google Chrome in 2025

You'll also need to update your content security policy to comply with Manifest V3. In Manifest V3, the CSP is now an object with different members representing alternative CSP contexts. You'll need to specify separate fields for "content_security_policy.extension_pages" and "content_security_policy.sandbox" depending on the type of extension pages you're using.

Here's a summary of the key differences between Manifest V2 and V3:

By updating your manifest to Manifest V3, you'll be able to take advantage of the new features and changes introduced in this version of the API. This is a crucial step in ensuring the security and stability of your extension.

Updating Manifest Structure

Updating your manifest's basic structure is the first step in transitioning to Manifest V3, and it's crucial to get it right. The most important change you'll need to make is changing the value of the "manifest_version" element to 3, which determines that you're using the Manifest V3 feature set.

Credit: youtube.com, Manifest V3 example for Chrome extension. #chrome-extension

You'll also need to replace background pages with a single extension service worker in Manifest V3. This means registering the service worker under the "background" field, using the "service_worker" key and specifying a single JavaScript file.

Even though Manifest V3 doesn't support multiple background scripts, you can optionally declare the service worker as an ES Module by specifying "type": "module", which allows you to import further code.

The "browser_action" and "page_action" properties are unified into a single "action" property in Manifest V3, so you'll need to replace these properties with "action" in your manifest. Similarly, the "chrome.browserAction" and "chrome.pageAction" APIs are unified into a single “Action” API in Manifest V3.

Here's a quick rundown of the changes to keep in mind:

By making these changes, you'll be well on your way to updating your manifest structure and taking advantage of the new features and changes introduced in Manifest V3.

Permissions and Security

In Manifest V3, permissions are more granular and explicit, allowing users to make informed decisions about what data they share with Tampermonkey scripts.

Credit: youtube.com, Manifest V3 Explained - Technical

This means script authors must declare specific permissions in the manifest file, such as access to browser tabs or browsing history.

Script authors must also ensure that their scripts only request permissions that are necessary for their functionality.

For example, a script that only needs to read the current URL should not request permission to read browsing history.

Tampermonkey scripts can also be limited to only running in specific contexts, such as when a user is on a specific website or when a specific tab is active.

Modify Host Permissions

Modifying host permissions is a crucial step in the transition to Manifest V3. In Manifest V2, host permissions were specified in the "permissions" field in the manifest file.

In Manifest V3, host permissions are a separate element, and you should specify them in the "host_permissions" field in the manifest file. This is a change from the previous version.

To modify your host permissions, you'll need to update your manifest file accordingly. This will ensure that your extension functions as intended in the new version.

Update CSP

Credit: youtube.com, Content Security Policy explained | how to protect against Cross Site Scripting (XSS)

Updating your content security policy (CSP) is a crucial step in transitioning to Manifest V3. You'll need to make some changes to your manifest file.

In Manifest V2, the CSP was specified as a string in the "content_security_policy" field of the manifest. But in Manifest V3, the CSP is now an object with different members representing alternative CSP contexts.

You'll need to specify separate fields for "content_security_policy.extension_pages" and "content_security_policy.sandbox", depending on the type of extension pages you're using. This means you'll have to update your CSP to be compliant with Manifest V3.

Remove any references to external domains in the "script-src", "worker-src", "object-src", and "style-src" directives if they're present. This will ensure the security and stability of your extension in Manifest V3.

Manifest V3 vs Manifest V2

Manifest V3 vs Manifest V2 is a crucial distinction for anyone working with Tampermonkey. Service workers replace background pages in Manifest V3.

One of the biggest changes is how network request modifications are handled. In Manifest V3, this is done with the declarativeNetRequest API. This means a different approach to modifying network requests compared to Manifest V2.

Recommended read: Manifest V2 vs V3

Credit: youtube.com, When should I convert my Manifest V2 extension into Manifest Version 3?

Extensions can only execute JavaScript included within their package in Manifest V3. This is a significant change from Manifest V2, where remotely-hosted code was allowed. This change affects how you structure your code and dependencies.

Manifest V3 introduces promise support to many methods. While callbacks are still supported as an alternative, promises are the recommended approach. This change can simplify your code and make it more readable.

Host permissions in Manifest V3 are a separate element and must be specified in the "host_permissions" field. This is a change from Manifest V2, where host permissions were part of the main manifest file.

The content security policy in Manifest V3 is an object with members representing alternative content security policy (CSP) contexts. This is different from Manifest V2, where the content security policy was a string.

Chrome Extensions Can Create Side Panel UI

Google Chrome extensions can now create a side panel UI, giving users more flexibility and customization options.

The desktop Chrome side panel will soon support Manifest V3 extensions that want to display an interface. This means developers can create extensions that integrate seamlessly with the browser's existing features.

The Chrome Web Store is where you can find these Manifest V3 extensions.

Claire Beier

Senior Writer

Claire Beier is a seasoned writer with a passion for creating informative and engaging content. With a keen eye for detail and a talent for simplifying complex concepts, Claire has established herself as a go-to expert in the field of web development. Her articles on HTML elements have been widely praised for their clarity and accessibility.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.