Adds a button to the movie genre page to open the chart, and redirects "genre" links to the corresponding "film_genre" page.
// ==UserScript== // @name Rateyourmusic Movie Genre Chart Button // @description Adds a button to the movie genre page to open the chart, and redirects "genre" links to the corresponding "film_genre" page. // @version 1.3.1 // @namespace https://greasyfork.org/users/908137 // @match *://rateyourmusic.com/charts/*/film/* // @match *://rateyourmusic.com/film_genre/* // @run-at document-start // @license GPLv3 // ==/UserScript== const GENRES_NEEDING_SUFFIX = ['comedy', 'experimental', 'satire']; const formatGenreName = (path, toFilmGenre = false) => { let genre = path.split('/')[2].toLowerCase(); return toFilmGenre ? genre.replace('-1', '').replace('-', '+') : genre.replace('+', '-').concat(GENRES_NEEDING_SUFFIX.includes(genre) ? '-1' : ''); }; (() => { const { pathname } = window.location; // Handle chart pages: redirect genre links if (pathname.startsWith('/charts/')) { document.addEventListener('DOMContentLoaded', () => document.querySelectorAll('a.genre').forEach(link => { link.href = `/film_genre/${formatGenreName(link.pathname, true)}`; }) ); } // Handle genre pages: add chart button if (pathname.startsWith('/film_genre/')) { const genre = formatGenreName(pathname); const button = Object.assign(document.createElement('a'), { textContent: 'View genre chart', href: `/charts/top/film/all-time/g:${genre}`, style: 'display: inline-block; float: right;' }); document.getElementById('page_breadcrumb')?.appendChild(button); } })();