Last active
November 7, 2026 07:48
-
-
Save micsthepick/6c8dbf87bb8241ca3a94272f2f4084eb to your computer and use it in GitHub Desktop.
MusicVerse MPRIS track info userscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name MusicVerse Media Session Fix | |
| // @namespace local.musicverse | |
| // @version 1.0 | |
| // @description Publish MusicVerse track metadata to MPRIS | |
| // @match https://player.musicverse.org/* | |
| // @run-at document-idle | |
| // @grant none | |
| // ==/UserScript== | |
| (() => { | |
| 'use strict'; | |
| let lastKey = ''; | |
| function updateMetadata() { | |
| const player = document.querySelector('.music-player-wrapper'); | |
| if (!player) return; | |
| const title = player.querySelector('.mpw-song-name') | |
| ?.textContent?.trim(); | |
| const artist = player.querySelector('.mpw-artist-name') | |
| ?.textContent?.trim() || ''; | |
| const artwork = player.querySelector('.mpw-artist-img')?.src; | |
| if (!title) return; | |
| const key = JSON.stringify([title, artist, artwork]); | |
| if (key === lastKey) return; | |
| navigator.mediaSession.metadata = new MediaMetadata({ | |
| title, | |
| artist, | |
| album: 'MusicVerse', | |
| artwork: artwork ? [{ src: artwork }] : [] | |
| }); | |
| lastKey = key; | |
| console.debug('[MusicVerse MPRIS]', title, artist); | |
| } | |
| let pending = false; | |
| const observer = new MutationObserver(() => { | |
| if (pending) return; | |
| pending = true; | |
| requestAnimationFrame(() => { | |
| pending = false; | |
| updateMetadata(); | |
| }); | |
| }); | |
| observer.observe(document.documentElement, { | |
| subtree: true, | |
| childList: true, | |
| characterData: true, | |
| attributes: true, | |
| attributeFilter: ['src'] | |
| }); | |
| updateMetadata(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment