// ==UserScript== // @name Add to Sonarr/Radarr for IMDb and Letterboxd // @namespace http://tampermonkey.net/ // @version 1.5 // @description Adds buttons to IMDb and Letterboxd to search for content in Sonarr/Radarr // @author xdpirate // @license GPLv3 // @match https://www.imdb.com/title/* // @match https://letterboxd.com/film/* // @icon https://www.google.com/s2/favicons?sz=64&domain=sonarr.tv // @grant GM_getValue // @grant GM_setValue // @downloadURL none // ==/UserScript== let radarrURL = GM_getValue("radarrURL", "http://localhost:7878"); let sonarrURL = GM_getValue("sonarrURL", "http://localhost:8989"); let imdbID, referenceNode, titleName; let site = window.location.hostname.includes("imdb.com") ? "imdb" : "lb"; if(site == "imdb") { let pagePath = window.location.pathname.split("/"); imdbID = pagePath[pagePath.length - 2]; referenceNode = document.querySelector("section.ipc-page-section > div > div > h1"); titleName = referenceNode.querySelector("span").innerText.trim(); } else if(site == "lb") { let urlPath = document.querySelector("a.micro-button[href^='http://www.imdb.com/title/']").href.split("/"); imdbID = urlPath[urlPath.length - 2]; referenceNode = document.querySelector("section.film-header-group"); titleName = referenceNode.querySelector("span.name").innerText.trim(); } let buttons = `
`; referenceNode.insertAdjacentHTML(site == "imdb" ? "afterend" : "beforeend", buttons); document.getElementById("ATSRSettingsButton").addEventListener("click", function() { let rURL = prompt("Enter the URL to your Radarr instance:", radarrURL); if(rURL != null) { GM_setValue("radarrURL", rURL); } let sURL = prompt("Enter the URL to your Sonarr instance:", sonarrURL); if(sURL != null) { GM_setValue("radarrURL", sURL); } if(rURL =! null && sURL != null) { location.reload(); } });