Greasy Fork

Greasy Fork is available in English.

RYMLyricsViewer

Allows the viewing of song lyrics on Rate Your Music without a subscription.

当前为 2024-10-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name               RYMLyricsViewer
// @name:de            RYMLyricsViewer
// @name:en            RYMLyricsViewer
// @namespace          sun/userscripts
// @version            1.1.0
// @description        Allows the viewing of song lyrics on Rate Your Music without a subscription.
// @description:de     Erlaubt das Ansehen von Songtexten auf Rate Your Music ohne ein Abonnement.
// @description:en     Allows the viewing of song lyrics on Rate Your Music without a subscription.
// @compatible         chrome
// @compatible         edge
// @compatible         firefox
// @compatible         opera
// @compatible         safari
// @homepageURL        https://forgejo.sny.sh/sun/userscripts
// @supportURL         https://forgejo.sny.sh/sun/userscripts/issues
// @contributionURL    https://liberapay.com/sun
// @contributionAmount €1.00
// @author             Sunny <[email protected]>
// @include            https://rateyourmusic.com/song/*
// @match              https://rateyourmusic.com/song/*
// @run-at             document-end
// @inject-into        auto
// @grant              none
// @noframes
// @icon               https://forgejo.sny.sh/sun/userscripts/raw/branch/main/icons/RYMLyricsViewer.png
// @copyright          2024-present, Sunny (https://sny.sh/)
// @license            Hippocratic License; https://forgejo.sny.sh/sun/userscripts/src/branch/main/LICENSE.md
// ==/UserScript==

(() => {
  const frame = document.getElementById("page_song_section_lyrics_frame");
  const inner = document.getElementsByClassName(
    "page_song_section_lyrics_lyric_inner",
  );

  const observer = new MutationObserver(() => {
    const button = document.getElementById(
      "page_song_section_lyrics_view_full_btn",
    );
    const error = document.getElementsByClassName(
      "page_song_section_lyrics_status_error",
    );

    if (frame.classList.contains("show_overlay"))
      frame.classList.remove("show_overlay");

    if (button) button.remove();

    if (error.length)
      Array.from(error).forEach((element) => {
        if (element.style.display !== "none") element.style.display = "none";
      });
  });

  observer.observe(frame, {
    attributes: true,
    childList: true,
  });

  unsafeWindow.rym.request
    .api("GET", `/api/1/lyric/${frame.dataset.lfid}/view`)
    .then((response) => response.json())
    .then((data) => {
      const lyric = data.lyric;
      const lfid = data.lfid || undefined;
      const writers = data.writers || undefined;
      const publishers =
        data.publishers.filter(Boolean).join(", ") || undefined;

      let html = '<div style="font-size: 0.75em; margin-top: 2em;">';
      if (lfid) html += `<p style=\"margin-bottom: 0;\">LFID: ${lfid}</p>`;
      if (writers)
        html += `<p style=\"margin-bottom: 0;\">Written by: ${writers}</p>`;
      if (publishers)
        html += `<p style=\"margin-bottom: 0;\">Published by: ${publishers}</p>`;
      html += "</div>";

      Array.from(inner).forEach((element) => {
        element.innerText = lyric;
        if (writers || publishers || lfid) element.innerHTML += html;
      });
    });
})();