Skip to content

Instantly share code, notes, and snippets.

@micsthepick
Last active November 7, 2026 07:48
Show Gist options
  • Select an option

  • Save micsthepick/6c8dbf87bb8241ca3a94272f2f4084eb to your computer and use it in GitHub Desktop.

Select an option

Save micsthepick/6c8dbf87bb8241ca3a94272f2f4084eb to your computer and use it in GitHub Desktop.
MusicVerse MPRIS track info userscript
// ==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