RYM descriptor links

links RYM descriptors to their respective chart pages

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         RYM descriptor links
// @namespace    https://github.com/zettaexa/userscripts
// @version      2025-11-22
// @description  links RYM descriptors to their respective chart pages
// @author       zetta
// @match        https://rateyourmusic.com/release/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rateyourmusic.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    "use strict";

    const row = document.querySelector("tr.release_descriptors");
    if (!row) return;

    const priSpan = row.querySelector("span.release_pri_descriptors");
    if (priSpan) {
        priSpan.style.display = "none";
    }

    // grab all <meta> elements under that row
    const metas = row.querySelectorAll("meta");

    metas.forEach((meta, i) => {
        const content = meta.getAttribute("content");
        if (!content) return;

        // 1. Remove a leading space if present
        let cleaned = content.replace(/^\s+/, "");

        // 2. Replace *any* remaining spaces with "-"
        cleaned = cleaned.replace(/\s+/g, "-");
        const url = `https://rateyourmusic.com/charts/top/album/all-time/d:${cleaned}`;
        // you can change the "album" part of the url to "album,ep,comp,single,video,unauth,mixtape,musicvideo,djmix,additional" to get all releases

        // create link
        const link = document.createElement("a");
        link.href = url;
        link.textContent = content;
        link.style.fontSize = ".9em";
        link.style.lineHeight = "1.4";
        link.style.textDecoration = "underline var(--mono-b) !important";
        link.style.color = "var(--mono-6)";

        // replace meta with the link
        const wrapper = document.createElement("span");
        wrapper.appendChild(link);
        if (i < metas.length - 1) {
            wrapper.appendChild(document.createTextNode(", "));
            wrapper.style.color = "var(--mono-6)";
        }

        meta.replaceWith(wrapper);
    });
})();