Someone already has a project for that on GitHub. I haven't tried it yet tho. The creator is also rewriting it to support other clients such as transmission and qbittorrent (v3 branch).
Piped uses the Newpipe Extractor, so they basically use the same tech. But IMO the biggest advantage of Piped is that you can sync your subs and playlists between devices. Piped is also more private as it's not your phone that talks with YouTube.
You can also do it with the normal settings menu (about:preferences). The setting is called "Enable Firefox Sync" under the tab "LibreWolf". Might be a bit easier this way.