// ==UserScript== // @name RARBG torrent links to TVMaze // @description Adds RARBG torrent links for every episode to various sections of TVMaze // @namespace NotNeo // @include http*://*tvmaze.com/calendar* // @include http*://*tvmaze.com/shows*/episodes // @version 2 // @grant none // @downloadURL none // ==/UserScript== var URL = window.location.href; if ( URL.indexOf("tvmaze.com/calendar") >= 0 ) { //do the following if we are in the calendar section var selected = document.querySelectorAll("span.show"); //get all episode divs for(var i = 0; i < selected.length; i++) { //Loop through the nodes and do the following to all targets var showNameTemp = selected[i].innerHTML; //Getting showname showNameTemp = showNameTemp.split('">')[1]; //removing HTML content off of showname var showName = showNameTemp.split(" RARBG DL Link " } } else if ( URL.indexOf("tvmaze.com/shows") >= 0 && URL.indexOf("/episodes") >= 0 ) { //do the following if we are in the show: episodes section var showNameTemp = document.querySelectorAll("h1")[0].textContent; //Getting showname var showName = showNameTemp.split(" - ")[0]; //cutting useless text off the showname var selected = document.querySelectorAll("[data-key]"); //get all episode divs for(var i = 0; i < selected.length; i++) { //Loop through the nodes and do the following to all targets var epNum = selected[i].firstChild.textContent; //Getting the episode number if (epNum.length < 2) { epNum = "0" + epNum; } //adding prefix 0 if needed var seaNum = selected[i].parentNode.parentNode.parentNode.previousElementSibling.getAttribute("name"); //Getting season number var seaEpNum = seaNum + "E" + epNum; //Putting season number and episode number together //append torrent button selected[i].firstChild.nextElementSibling.nextElementSibling.innerHTML += " RARBG DL Link " } }