Greasy Fork

Greasy Fork is available in English.

Rateyourmusic Movie Genre Chart Button

Adds a button to the top of the movie genre page to open the chart.

当前为 2022-05-03 提交的版本,查看 最新版本

// ==UserScript==
// @name Rateyourmusic Movie Genre Chart Button
// @license GPLv3
// @description Adds a button to the top of the movie genre page to open the chart.
// @run-at document-start
// @version 1.1.2
// @match *://rateyourmusic.com/film_genre/*
// @namespace http://greasyfork.icu/users/908137
// ==/UserScript==

// Genre names that also describe a music genre need a "-1" appended in the chart URL to differentiate themsa
const ADD_ONE = ["comedy", "experimental", "satire"];

function init(f) {
  let genreName = window.location.pathname
    .replaceAll("+", "-")
    .split("/")[2]
    .toLowerCase();

  let a = document.createElement("a");
  a.innerHTML = "View genre chart";
  a.href = `https://rateyourmusic.com/charts/top/film/all-time/g:${genreName}`;

  if (ADD_ONE.includes(genreName)) a.href = a.href.concat("-1");

  a.style = "display: inline-block; float: right;";
  f.appendChild(a);
}

window.addEventListener("load", function () {
  const frame = document.getElementById("page_breadcrumb");
  init(frame);
});