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

Switch to manifest v3 #1430

Open
Mottie opened this issue May 30, 2022 · 33 comments
Open

Switch to manifest v3 #1430

Mottie opened this issue May 30, 2022 · 33 comments

Comments

@Mottie
Copy link
Member

Mottie commented May 30, 2022

https://developer.chrome.com/blog/mv2-transition/

January 2023: The Chrome browser will no longer run Manifest V2 extensions. Developers may no longer push updates to existing Manifest V2 extensions.

@Freeplayg
Copy link

Freeplayg commented Jun 2, 2022

Firefox doesn't yet support v3, although I think they are planning on adding it soon. So I would wait

we expect to launch MV3 support for all users by the end of 2022
(https://blog.mozilla.org/addons/2022/05/18/manifest-v3-in-firefox-recap-next-steps/)

@tophf
Copy link
Member

tophf commented Jun 3, 2022

Chrome doesn't support all the things we need too, like passing a config to content scripts synchronously or creating nested workers in the background context. These things may appear only next year, but we'll have to start the migration sooner because it takes time. We'll keep the MV3 version separate somehow, so that the ongoing work doesn't break the main extension in older browsers.

@narcolepticinsomniac
Copy link
Member

Makes you wonder if they're kickin' the can because there's already been a more significant, preemptive backlash than they originally predicted. The memes about Google killing adblockers, and how everyone should switch to Firefox, have certainly been making the rounds in recent weeks.

I'm sure it's all a numbers game to Google. How much of their market share monopoly are they willing to sacrifice for increased ad revenue? No doubt they have projections which legitimize the shady moves they've been planning for years now, but obviously something's changed. Predictions are all well and good 'till the pitchforks come out.

@Poopooracoocoo
Copy link

An update on this: Mozilla is planning general availability of MV3 extensions on Firefox for Android. NOT MV2 extensions.

@ZatsuneNoMokou
Copy link

https://developer.chrome.com/blog/resuming-the-transition-to-mv3?hl=en

We will begin disabling Manifest V2 extensions in pre-stable versions of Chrome (Dev, Canary, and Beta) as early as June 2024, in Chrome 127 and later.

@tophf tophf pinned this issue May 25, 2024
@tophf
Copy link
Member

tophf commented May 25, 2024

MV3 still doesn't implement a way to ensure the styles are applied in time to avoid FOUC (flash of unstyled content):

  • background script cannot be persistent and if you pause browsing for 30 seconds it'll terminate, then you open another page and the background script starts again (50-100ms), reads all styles to find the matching ones (20-200ms depending on the amount of styles), which almost always guarantees a FOUC on a fast site that open in less than 50ms (simple pages, sites with service workers, going back/forward when not in bfcache);
  • prolonging the lifetime of the background script artificially is forbidden by the web store policy;
  • the instant inject mode doesn't work with declarativeNetRequest because it can't use dynamically-calculated values on a response for a request that was already sent before we can add a dynamic rule.

The only way to avoid FOUC is to use the userScripts permission, but it's also problematic:

  • it's reserved for extensions that allow running external JS code, so the web store is likely to reject our CSS extension due to their single-purpose policy;
  • such ability is perceived as dangerous by many people, so even though we can guarantee no external code will be executed, it may still make people cautious;
  • it requires enabling developer mode switch in chrome://extensions, which is often disabled in managed browsers;
  • it doesn't support regexp matching, which is used in many popular styles, so we'll have to inject all these possibly huge styles into all pages/frames in inactive state and check each regexp against the current URL i.e. instead of super fast check using pre-compiled regexps in our ManifestV2 extension, the browser will recompile all these regexps in each time tab/frame. Just one GitHub Dark is 800kB with ~10 regexps in one style. Checking several such styles on every page would cause a noticeable delay.

In other words ManifestV3 is inherently inferior for userstyles as observed with the original Stylish extension if you open a page, read it for more than 30 seconds, open another page on a fast site. It seems unreasonable to break Stylus as well, so I think we should just keep using ManifestV2 until a native API is implemented.

ManifestV2 can be enabled for a year via policies or registry (if you're not an administrator, replace HKEY_LOCAL_MACHINE with HKEY_CURRENT_USER).

@jacekkopecky
Copy link

@tophf I don't know the complexities here, but if I understand instant-inject correctly, it could enable a workaround I could live with as a user - instant-inject a style that hides everything while the background script is starting and finding the right styles to apply.

Your calculations make it sound like very fast sites would have up to 300ms delay in showing up. I could live with that.

What do you think?

@tophf
Copy link
Member

tophf commented Jun 14, 2024

That's completely unusable i.e. I don't see the point of maintaining Stylus if that's how it has to work. Also, many sites open within 100ms, especially those that have a service worker installed e.g. telegram may start opening (onCommitted) in 30ms since the earliest moment the URL becomes known (onBeforeRequest).

It'd be especially bad when navigating the same site with a style that applies differently depending on the page URL because pages could be loaded very fast and they look similar, so hiding the old contents would be very disruptive and ugly.

I guess I'll try userScripts permission, which is the only reliable solution in ManifestV3, but a) its implementation in Chrome is irrationally dependent on the devmode switch and b) it may be disallowed in the web store since our extension's purpose is not userscripts, c) it's wasteful in regards to the regexp as I explained in my previous comment.

@jacekkopecky
Copy link

OK, fair enough...

@Vendrel
Copy link

Vendrel commented Aug 5, 2024

@tophf Please do what you can. 🙏 Stylus has a special importance in my browser usage and work.

@Tech-How
Copy link

Tech-How commented Aug 6, 2024

Chiming in here as well. I love creating customizable styles and sharing them with my friends the community. If this extension doesn't work on the web browser that 75% of the world uses it's kind of a let down. Even a "lite" variant of this extension would be better than nothing, even if it is a little slow and impractical. This addon knocks Stylish out of the park with auto-updates, the editor, cloud syncing, and numerous usability improvements. So much so that I now host my styles exclusively on userstyles.world. But yeah, Google's pretty evil in this regard.

@tgrushka
Copy link

I am legally blind with albinism and have light sensitivity. This extension has been a godsend for me. I'm already mostly using Firefox except for development / testing with Chrome. But please, if there's any way to defeat Goliath Google's constantly trampling down on users with disabilities by trying to take control out of our hands by crippling extensions such as Stylus... if there's any way to get around their constant nonsense, please do it. If you ask me, Google is asking for a major, major accessibility lawsuit worth millions if they cripple this and other such extensions.

@Tech-How
Copy link

Thinking more about this and following other affected projects, I imagine it must be incredibly painful to now have to be responsible for maintaining two versions of the same extension. If the developers fully migrate to Manifest V3 to comply with Google's demands, it will cripple and restrict the Firefox/Mozilla/Gecko version. If they do nothing, it won't work on any Chromium browser. Who is going to be responsible for maintaining both versions at the same time? Google is potentially killing off thousands of open source projects and scrapping years of development. It's outrageously sad to realize just how much control Google has over the entire "open" web.

@ristomatti

This comment was marked as off-topic.

@reaseno
Copy link

reaseno commented Aug 30, 2024

This assessment helped me to understand the situation better:
https://adguard.com/en/blog/chrome-manifest-v3-where-we-stand.html

@afknst
Copy link

afknst commented Oct 20, 2024

With the MV3 thing I don't want to trust google any more and I want something under my control.
Is there a proxy for userstyles like userscript-proxy?
Well technically I can inject userstyles using userscripts...

@tophf
Copy link
Member

tophf commented Nov 1, 2024

Test MV3 build is available in #1828 or in my comments below.

@Konata123
Copy link

Konata123 commented Nov 2, 2024

@tophf
On the Vivaldi browser (latest .deb version 7.0.3495.10, on Ubuntu 20.04), this MV3 test version is not working properly. The styles load and work, but the pop-up under the button does not work and nothing changes in it. On Chrome I do not have this problem

mv3

@pabli24
Copy link
Contributor

pabli24 commented Nov 2, 2024

"Write new style as UserCSS" opens the classic editor instead.

Edit: After installing usercss style and saving it as template (or reset template) and then restarting the browser fixes it :D

@Konata123
Copy link

Konata123 commented Nov 2, 2024

I do not have a problem with writing new styles, but with the window not working, the one in the screenshot above.
Nothing works in it and it always looks the same. No button does anything when pressed, no list of styles is displayed, even in the sceenshot you can see that 3 are enabled and working, I imported them from the MV2 version.

Edit: @pabli24 Saving as a template, resetting the template and resetting the browser, I tried various combinations but nothing helped.

@tophf
Copy link
Member

tophf commented Nov 2, 2024

Fixed the bugs reported above, hopefully without adding new ones:
Nov 02: stylus-mv3-test-51096464.zip
Nov 03: stylus-mv3-test-6c3ccc82.zip
Nov 04: stylus-mv3-test-ec135d6a.zip
Nov 05: stylus-mv3-test-ce03a9e0.zip fixed PatchCSP option.

@Konata123
Copy link

@tophf Thank you for the fix, this version works well, for these moments I see no more problems.

@pabli24
Copy link
Contributor

pabli24 commented Nov 2, 2024

"Patch CSP to allow style assets" --allowliste­d-extension-id workaround seems to be working.

I guess the ExtensionI­nstallForc­elist policy method would only work for Stylus from the Chrome Web Store.

Edit: The warning in the stylus options disappears, but it it doesn't actually work.
error

@mmikeww
Copy link

mmikeww commented Nov 4, 2024

so if a mv3 build is in the works, what sacrifices/compromises had to have been made?

@tophf
Copy link
Member

tophf commented Nov 4, 2024

  1. By default the extension will restart frequently, which is wasteful. Users can prevent it via a new option "Style cache duration".
  2. The "Patch CSP" option will only work if you install the extension via a special policy.
  3. The source code is peppered with conditional compilation for MV2/MV3, which is not good generally as it complicates development.

@tophf
Copy link
Member

tophf commented Nov 5, 2024

@Mottie, I think it's ready to be uploaded to beta in the web store using a zip from my latest comment in #1828. Ideally, we should add a publishing action for that, maybe from that stalled PR #1407 or another one from github actions...

@Vangelis66
Copy link

Vangelis66 commented Nov 9, 2024

Apologies for asking this here (but it is kinda related 😉), what is the plan on the MV2 version of Stylus?
Older Chrome versions (<=88) do NOT support MV3; Stylus beta 1.5.51 (code-identical to 1.5.50, BTW), supposedly supports Chrome 56 and up (via manifest.json; though this number is untested, latest Stylus is somewhat broken in Cr69, but works OK in Cr86/87)...

The new BETA expects at least Cr128 to install, I suspect because needed APIs are not there in Cr<=127 (?). Supermium is a Chromium fork very popular in older OS users (Win8.1/7SP1/VistaSP2/XPSP3); the exact OSes Google cut support for in their browser; Supermium won't remove support for MV2-type extensions any time soon (so uBlock origin MV2 will continue to work there); it's currently in the Chromium-126ESR branch, so while it does support MV3, latest Stylus-BETA 3.0.0 won't install there...

Will you be willing to continue publishing (say, on GitHub) MV2 versions of Stylus for some additional time (if possible, code-wise) for the sake of those Chrome forks targeting Win < 10 ? If MV2 is to be axed pretty soon, then at least one last MV2 version based on the latest master branch would be highly welcome...

Thanks for your precious time reading this 😄 .

@tophf
Copy link
Member

tophf commented Nov 9, 2024

MV2 version will be used in Firefox, because its support for MV3 is still spotty and MV3 doesn't yet offer any advantages for userstyles. It'll be added to github releases as well.

supposedly supports Chrome 56 and up

The MV2 version does.

latest Stylus is already mostly broken in Cr69

I don't know what you referring to. The stable version in the web store works in Chrome 56. If something is broken you can make a bug report and if I can replicate it here I'll fix it.

@Vangelis66

This comment was marked as resolved.

@tophf
Copy link
Member

tophf commented Nov 10, 2024

Can the Fx MV2 version, with some manual fiddling in its manifest.json, be installed in Chromium forks

No, it's not a universal build, it's just for Firefox web store, so it won't have Chromium-specific code. A separate Chromium build will be attached to github releases.

Chrome 69 is way outdated

It works for me, just as Chrome 56, and the options are displayed properly using Stylus from the web store.

@tophf
Copy link
Member

tophf commented Nov 10, 2024

Ah I see, I have to make the window smaller. Should be an easy fix then. Anyway, don't hijack issues with unrelated problems.

The fix itself is simple and you can use it as a userstyle:

@-moz-document url-prefix("chrome-extension://clngdbkpkpeebahjckkjfobafhncgmne/options.html") {
.block {
  flex-shrink: 0;
}
}

@Vangelis66

This comment was marked as off-topic.

@tophf
Copy link
Member

tophf commented Nov 10, 2024

Please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests