Concise Firefox web extension and Golang server for updating your Discord activity with songs playing on Youtube Music. Works on all operating systems.
- Download the source code
- Go to
about:debugging
in FireFox - Select
This Firefox
>load Temporary Add-on
and select the directory containing the web extension (i.eextension
- Ensure Discord application is started (not the browser version)
- Ensure Golang version >= 1.22.5 is installed
- Start the Golang server by building
go build ./gobackend/main.go
and running the executable (e.g:./main
after building on Linux) - Go to
https://music.Youtube.com/*
and start any song - Your Discord rich presence should now be updated
- Golang backend connects to Discord using IPC and listens on an end-point for active song metadata data.
- The web extension uses a
MutationObserver
to send updates to the server when the "pause-play" button changes (indicating a pause, seek-forward, seek-backward or a new song starting event)
-
Why not connect to Discord directly through the Firefox extension?
- (Firefox) extensions are sandboxed to increase safety in cases of malicious or malfunctioning code. This means they cannot freely access the Discord IPC socket located in the operating system filesystem. read more about it here
-
Why not use
mediaSession.setActionhandler()
instead ofMutationObserver
?- Using the
setActionHandler()
would be the "proper" way to implement an event based update model. However, on Firefox the required APIs (start, stop, etc) seemed to not be supported, (even if the official documentation states elsewise?)
- Using the
- Extension only sends an update if the Youtube Music browser is actively open
- This happens due to browser optimizations; MutationObserver does not detect a change in HTML as the HTML is not actively changing
- Firefox extension requires permissions on
<all_urls>
(Seemanifest.json
).- Technically the extension only requires access to the server endpoint (e.g: http://127.0.0.1:8080/song-data), but the extension
received a network error when
<all_urls>
was removed (not sure why?)
- Technically the extension only requires access to the server endpoint (e.g: http://127.0.0.1:8080/song-data), but the extension
received a network error when
- Firefox extension has to be manually reloaded each time the browser is reset
- This happens as the Extension is not available on the Firefox marketplace.
- Ads
- Ads are currently not filtered when creating the rich presence, this is a nice issue to solve if anyone is interested.
This project was patched together to:
- Orientate in Golang
- Better understand all technologies used
- Create a simple Discord rich presence alternative for listening on Youtube Music