Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension Manifest V3 support is now available #38

Closed
samuelmaddock opened this issue Jun 14, 2021 · 24 comments
Closed

Extension Manifest V3 support is now available #38

samuelmaddock opened this issue Jun 14, 2021 · 24 comments
Labels
electron-contrib-required Requires contributing changes upstream to the Electron repository. enhancement New feature or request

Comments

@samuelmaddock
Copy link
Owner

samuelmaddock commented Jun 14, 2021

Features required for Manifest V3 support have been proposed in Electron upstream. Once other maintainers have reviewed and accepted the changes, it will be ready to use.
electron/electron#44411


Manifest V3 (MV3) is that latest versions of the Chrome extensions API which is now stable in Chrome.

It's partially supported in Electron at the moment since electron/electron#27562 was introduced.

Known affected extensions

I don't know of any widely used extensions shipping with MV3 yet, but there will be as MV2 begins to be phased out.

Possible solutions

electron-chrome-extensions provides new extension APIs by injecting them with JavaScript. This is done in Electron preload scripts. Instead of background hosts using a WebContents instance, MV3 uses service workers.

Electron doesn't have support for injecting JS into a service worker context yet. The API will need to be expanded to support new contexts. Work on specing out changes has started in electron/governance#366

@samuelmaddock samuelmaddock added enhancement New feature or request electron-contrib-required Requires contributing changes upstream to the Electron repository. labels Jun 14, 2021
@schetle
Copy link
Contributor

schetle commented May 6, 2022

Is there any news on electron's support for injecting JS into service worker contexts?

https://developer.chrome.com/docs/extensions/mv3/mv2-sunset/

Here's the V2 support timeline, and so we're looking to get upgraded to V3 before V2 is completely killed off.

@samuelmaddock
Copy link
Owner Author

Is there any news on electron's support for injecting JS into service worker contexts?

Currently no update. I've spent time researching what it would take and the amount of work is non-trivial.

Electron's preload scripts work in a secure environment thanks to the effort of extension content scripts which provide an isolated JS context. Node's globals and other variables within preload scripts are separate from the main JS context. This is how V8's binding system works: https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/core/v8/V8BindingDesign.md#world

The problem is when trying to do the same thing with Workers (Service, Web, Shared). Support for isolated worlds/contexts within a worker environment isn't something that exists yet. This has been attempted before without context isolation which isn't a secure approach (see electron/electron#28923 (comment)).

At a high-level, here's a list of what might be needed:

  • Create new v8::Context in the renderer's Worker Thread to run alongside global service worker contexts
  • Inject node into the new context
  • Use internals of the contextBridge API to provide a bridge between the worker preload context and the service worker context
  • Provide API for executing JS in the main worker context from the preload context; ie. worker.executeScript(js)

Then there's a few other requirements just for API design within Electron. A design proposal might be needed for that in the API governance repo.

I do realize the importance of this work prior to Chrome dropping support of MV2, however, I don't currently have a roadmap for these contributions.

@lengband
Copy link

lengband commented Dec 21, 2022

@samuelmaddock hello. May I know the current status of this matter? Is there any news on electron's support for injecting JS into service worker contexts?
i am using electron-chrome-extensions but it only supports V2.

@samuelmaddock
Copy link
Owner Author

Electron does not yet support preload scripts for service workers. I'm not aware of others currently working towards adding this.

I spent time on it a couple of months ago, but I have no estimate and I'm not close to a solution.

@PascalPixel
Copy link

In case anyone is interested, there is movement towards Manifest v3; electron/electron#39395

@ductridev
Copy link

any updates on this :(

@samuelmaddock
Copy link
Owner Author

I'm currently awaiting comments on my RFC which would unblock this
electron/rfcs#4

@lengband
Copy link

Hello, @samuelmaddock
Are there any updates on this?
And is it difficult for Electron to support preload scripts for service workers? If it did, it would be a cool thing.

@PascalPixel
Copy link

Hello, @samuelmaddock

Are there any updates on this?

And is it difficult for Electron to support preload scripts for service workers? If it did, it would be a cool thing.

Depends on this electron/rfcs#4

@lengband
Copy link

This RFC has been around for a long time...

@samuelmaddock
Copy link
Owner Author

Moved RFC to electron/rfcs#8 due to GitHub bug...

Not much activity yet, but Electron's API WG is starting to meet regularly to work through APIs and RFCs.

@samuelmaddock
Copy link
Owner Author

API working group meetings have been a success. The Preload Realms RFC was just merged after approval 🎉

Next step is to finish implementing preload realms and open a PR to Electron. I don't have any estimates for how long this will take me, but my hope is we have MV3 supported by end of year, if not sooner 🙏

For anyone interested in this, please consider sponsoring my work 🙇

@ductridev
Copy link

awesome 😎

@ductridev
Copy link

Any updates about this?

@samuelmaddock
Copy link
Owner Author

samuelmaddock commented Oct 11, 2024

Implementation work is still ongoing.

Next step is to propose a PR in the Electron repo with support of preload scripts in service workers. Still need to finalize API designs and write more tests & documentation.

I'm able to inject JS into the MV3 service workers so the action badges are partially working now. :)

Screenshot 2024-10-11 at 10 55 40 AM

@saenzramiro
Copy link

Great news @samuelmaddock ! I'm glad you are making progress on this.

@samuelmaddock
Copy link
Owner Author

Opened a PR in Electron to add preload scripts in service workers.
electron/electron#44411

This will allow Chrome extension APIs to be implemented in Manifest V3 background workers.

@samuelmaddock
Copy link
Owner Author

samuelmaddock commented Nov 10, 2024

Dark Reader is now working well in the mv3 branch.

Screenshot 2024-11-10 at 11 45 28 AM

@samuelmaddock
Copy link
Owner Author

While service worker preloads are still going through reviews upstream, I built electron-chrome-web-store to make it easier to install and test extensions.

Screen.Recording.2024-12-04.at.6.31.35.PM.mov

@saenzramiro
Copy link

OMG! That is epic. Good work!👏🏼👏🏼

Please consider the option that the Browser Action List can be at the top, bottom, left, or right, so the extensions popup should be displayed inside the viewport automatically.

@samuelmaddock
Copy link
Owner Author

1password extension mostly working. Note that other password managers are still not quite working.

output.mp4

@samuelmaddock samuelmaddock changed the title Extension Manifest V3 not supported Extension Manifest V3 support in development Dec 24, 2024
@samuelmaddock
Copy link
Owner Author

Some updates

Assuming the backport is approved, initial MV3 support should be available relatively soon.

In the mean time, I worked on adding native messaging capabilities to support password managers like iCloud Passwords.

icloudpasswords.mp4

@samuelmaddock
Copy link
Owner Author

Manifest V3 is now supported in Electron 🎉 To use it, update your dependencies as followed

  • electron@35.0.0-beta.3
  • electron-chrome-extensions@4.2.0
  • electron-chrome-web-store@0.7.0

Please give it a try and lmk how it goes! This library is still incomplete so feel free to file additional issues for missing functionality or any broken extensions.

@samuelmaddock samuelmaddock changed the title Extension Manifest V3 support in development Extension Manifest V3 support is now available Feb 7, 2025
@saenzramiro
Copy link

Thank you @samuelmaddock!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron-contrib-required Requires contributing changes upstream to the Electron repository. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants