dougppaz / youtube-music-dl

Chrome Extension to download music file with tags and cover from Youtube Music.
MIT License
44 stars 4 forks source link

Update to manifest v3 #18

Closed Xylobyte closed 1 month ago

Xylobyte commented 1 year ago

When install this extension, I have this error: Manifest version 2 is deprecated, and support will be removed in 2023. See https://developer.chrome.com/blog/mv2-transition/ for more details.

I use Chrome version 108.0.5359.100 on Windows

ipince commented 1 year ago

I spent a couple hours yesterday trying to change the manifest so that it supports v3 using this migration guide. I made progress, but ultimately got stuck.

It looks like the code uses a nodejs package named buffer. But when you webpack this dependency into the extension and try to load it in Chrome, you'll get an error like:

Uncaught TypeError: Cannot use 'in' operator to search for 'Buffer' in undefined

which is on this line of the un-minified background.js:

        NodeBuffer:  true && "Buffer" in global,

Seems like global is undefined. Now. I think this might be related to the fact that the new chrome extensions cannot access window, yet the webpacked buffer seems to access it.

Now, I've never built a Chrome extension, nor have I worked with nodejs/yarn/webpack, so I'm really out of my depth here. But maybe with a little guidance from @dougppaz I can make it work?

I tried searching to see if there was a way to avoid using the buffer package, but that seems hard. I also tried using the Offscreen API like the guide shows, but failed there too.

Happy to share the progress in a PR or something

ipince commented 1 year ago

I tried searching to see if there was a way to avoid using the buffer package

For this, I saw that it's really only used directly in utils.js, so I changed that call to use btoa and removed the buffer dependency. Unforunately webpacking that failed--looks like buffer is still needed (maybe indirectly by other packages?).

gloupit commented 10 months ago

Hey, any news about the migration to manifest v3 ?

dougppaz commented 1 month ago

V3 integrate CSP, this makes it impossible to interact with the content of the yt music application. https://developer.chrome.com/docs/extensions/reference/manifest/content-security-policy