Last active
September 9, 2025 21:03
-
-
Save stpettersens/ecd6c9038170f4cb22eb0bfd1b23cd7a to your computer and use it in GitHub Desktop.
Rotten Tomatoes Links for Jellyfin user script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Rotten Tomatoes Links for Jellyfin | |
// @namespace http://stpettersen.xyz | |
// @version 2025-09-07 | |
// @description This script adds a Rotten Tomatoes link for TV and movies on Jellyfin. | |
// @author Sam Saint-Pettersen | |
// @match https://jfdemo.stpettersen.xyz/* | |
// @icon https://www.rottentomatoes.com/assets/pizza-pie/images/favicon.ico | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
// Replace @match with your Jellyfin server URL. | |
'use strict'; | |
function waitForElement(selector, targetNode = document.body) { | |
return new Promise((resolve) => { | |
const element = document.querySelector(selector); | |
if (element) { | |
return resolve(element); | |
} | |
const observer = new MutationObserver(() => { | |
const foundElement = document.querySelector(selector); | |
if (foundElement) { | |
observer.disconnect(); | |
resolve(foundElement); | |
} | |
}); | |
observer.observe(targetNode, { | |
childList: true, | |
subtree: true | |
}); | |
}); | |
} | |
function injectRTLink() { | |
console.log("RTLfJF: injectRTLink invoked; inserting link."); | |
let targetEl = null; | |
let links = document.getElementsByClassName('button-link') | |
for (let i = 0; i < links.length; i++) { | |
if (links[i].href.startsWith("https://www.themoviedb.org")) { | |
targetEl = links[i]; | |
break; | |
} | |
if (targetEl != null) { | |
break; | |
} | |
} | |
let genre = "m"; | |
let year = ""; | |
let title = document.getElementsByTagName("bdi")[0].innerHTML.toLowerCase() | |
.replace(/ /g,"_").replace(/'/g,"").replace(/_&/g, "").replace(/:/g, "").replace(/,/g, "").replace(/-/g, "_"); | |
let otm = document.getElementsByClassName("originalTitle")[0]; | |
if (otm) { | |
let ot = document.getElementsByClassName("originalTitle")[0].innerHTML; | |
if (ot.length > 0) year = "_" + ot; | |
} | |
let ott = document.getElementsByClassName("originalTitle")[0]; | |
if (ott) { | |
let ot = document.getElementsByClassName("originalTitle")[0].innerHTML; | |
if (ot == "TV") genre = "tv"; | |
} | |
targetEl.insertAdjacentHTML("afterend", | |
`, <a id="rt-link" target="_blank" class="button-link emby-button" href="https://www.rottentomatoes.com/${genre}/${title}${year}">Rotten Tomatoes</a>` | |
.replace("_TV", "")); | |
} | |
// Wait for bottom cards to load before attempting to get/insert links. | |
waitForElement('.card').then(element => { | |
console.log("RTLfJF: Title cards loaded..."); | |
injectRTLink(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment