Created
December 13, 2016 11:32
-
-
Save anonymous/6592860e0099abe77b8f6d377090f07b to your computer and use it in GitHub Desktop.
This file contains 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 MyEpisodes Downloader | |
// @description Adds download links to MyEpisodes website | |
// @namespace https://greasyfork.org/en/users/814-bunta | |
// @include *myepisodes.com/allinone* | |
// @include *myepisodes.com/epslist* | |
// @include *myepisodes.com/show* | |
// @include *myepisodes.com/epsbyshow* | |
// @include *myepisodes.com/quickcheck* | |
// @version 1.4 EDIT 0.2 | |
// @Author Bunta [edited by PaulBags] | |
// @license http://creativecommons.org/licenses/by-nc-sa/3.0/us/ | |
// @grant none | |
// ==/UserScript== | |
/* Console import for testing: | |
var body = document.getElementsByTagName("body")[0]; | |
var script = document.createElement('script'); | |
script.type = "text/javascript"; | |
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"; | |
body.appendChild(script); | |
var $ = JQuery | |
*/ | |
(function() { | |
function Tracker(shortname, icon, searchurl, useNumbers) { | |
this.shortname = shortname; | |
this.icon = icon; | |
this.searchurl = searchurl; | |
this.useNumbers = useNumbers; | |
this.getHTML = function (query, episode) { | |
var tShortname = this.shortname; | |
var tIcon = this.icon; | |
var tSearchURL = this.searchurl; | |
var tUseNumbers = this.useNumbers; | |
// Alter search or link parameters for special cases | |
//switch (query) | |
// { | |
//case "Ash vs Evil Dead": | |
// tSearchURL = "https://kat.cr/usearch/ettv -720 -1080 "; | |
// tIcon = "https://kat.cr/favicon.ico"; | |
// tShortname = "Kickass"; | |
// break; | |
// } | |
// Add episode numbers if enabled | |
if(tUseNumbers){ | |
search = query + " " + episode; | |
} else { | |
search = query; | |
} | |
var html = "<a target=\"_blank\" href=\"" + tSearchURL; | |
html += escape(search); | |
html += "\">"; | |
if (tIcon != "") { | |
html += "<img style=\"margin-left:0.5em;margin-right:0.5em;padding:2px;border:1px solid black;background-color:white;\" width=\"14\" heigth=\"14\" src=\"" + tIcon + "\" alt=\"" + tShortname + "\">"; | |
} else { | |
html += "<span style=\"padding-left:0.5em;padding-right:0.5em;\">" + tShortname + "</span>"; | |
} | |
html += "</a>"; | |
return html; | |
} | |
// Used for old EZTV site POST process | |
this.getEZTVHTML = function (query) { | |
var html = "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-2\">" + | |
"<form target=\"_blank\" action=\"https://eztv.ag/search/\" method=\"POST\" name=\"search\" id=\"search\">" + | |
// "<script type=\"text/javascript\">function search_submit_form( obj ) { $( '#' + obj ).click(); return false; }</script>" + | |
"<input type=\"submit\" value=\"Search\" name=\"search\" id=\"search_submit\" style=\"display: none;\" />" + | |
"<input type=\"hidden\" name=\"SearchString1\" value=\"" | |
html += query; | |
html += "\" /><a href=\"javascript:void(0);\" onclick=\"parentNode.submit()\">"; | |
if (this.icon != "") { | |
html += "<img width=\"14\" heigth=\"14\" border=\"0\" src=\"" + this.icon + "\" alt=\"" + this.shortname + "\">"; | |
} else { | |
html += this.shortname; | |
} | |
html += "</a></form></font>"; | |
return html; | |
} | |
} | |
function addDownloadAllInOne(downloadURL) { | |
WaitForState("div#serieswatch table span.shows").done(function() { | |
// iterate through series table | |
var seriesTable = $("div#serieswatch").children("table"); | |
// Create Download column | |
seriesTable.find("tr.header").append("<td style=\"border-bottom: solid 1px black;\">D</td>"); | |
// iterate through rows | |
seriesTable.find("tr[class!=header]").each(function() { | |
// Get series title | |
var showTitle = $(this).find("span.shows").text(); | |
// Get episode number | |
var episode = $(this).find("td b").first().text().trim(); | |
// Add download link to each episode | |
$(this).append("<td style=\"padding:0px;\">" + downloadURL.getHTML(showTitle, episode) + "</td>"); | |
}); | |
}); | |
} | |
function addDownloadEpisodeList(downloadURL) { | |
WaitForState("div#myepisodes_views table.mylist").done(function() { | |
// iterate through series table | |
var seriesTable = $("div#myepisodes_views table.mylist"); | |
// Create Download column | |
seriesTable.find("tr.header").append("<th title=\"Download\">D</th>"); | |
// iterate through rows | |
seriesTable.find("tr[class!=header]").each(function() { | |
// Get series title | |
var showTitle = $(this).find("td.showname a").text(); | |
// Get episode number | |
var episode = "S" + $(this).find("td.longnumber").text().replace("x", "E"); | |
// Add download link to each episode | |
$(this).append("<td>" + downloadURL.getHTML(showTitle, episode) + "</td>"); | |
}); | |
}); | |
} | |
function addDownloadQuickList(downloadURL) { | |
WaitForState("div#myepisodes_views table.mylist").done(function() { | |
// iterate through series table | |
var seriesTable = $("div#myepisodes_views table.mylist"); | |
// Create Download column | |
seriesTable.find("tr.header").append("<th title=\"Download\">D</th>"); | |
// iterate through rows | |
seriesTable.find("tr.Episode_One, tr.Episode_Two").each(function() { | |
// Get series title | |
var showTitle = $(this).find("td.showname a").text(); | |
// Get episode number | |
var episode = "S" + $(this).find("td.longnumber").text().replace("x", "E"); | |
// Add download link to each episode | |
$(this).append("<td>" + downloadURL.getHTML(showTitle, episode) + "</td>"); | |
}); | |
}); | |
} | |
function addDownloadEpisodesByShow(downloadURL) { | |
WaitForState("div#myepisodes_views table.mylist").done(function() { | |
var showTitle = $("div.showname").next().text() | |
// iterate through series table | |
var seriesTable = $("div#myepisodes_views table.mylist"); | |
// Create Download column | |
seriesTable.find("tr.header").append("<th title=\"Download\">D</th>"); | |
// iterate through rows | |
seriesTable.find("tr.odd, tr.even").each(function() { | |
// Get episode number | |
var episode = "S" + $(this).find("td.longnumber").text().replace("x", "E"); | |
// Add download link to each episode | |
$(this).append("<td>" + downloadURL.getHTML(showTitle, episode) + "</td>"); | |
}); | |
}); | |
} | |
function WaitForState(query) { | |
var dfd = $.Deferred(); | |
window.setTimeout(function() {AttemptResolve(query, dfd);}, 100); // Doesn't work without a short delay | |
return dfd; | |
} | |
function AttemptResolve(query, dfd) { | |
if (query === "" || $(query).length) { | |
dfd.resolve(); | |
} else { | |
window.setTimeout(function() {AttemptResolve(query, dfd);}, 100); // Try again in a little bit | |
} | |
} | |
// --------------- downloadURL --------------- | |
var downloadURL0 = new Tracker("EZTV", "http://eztv.ag/favicon.ico", "https://eztv.ag/search/", true); | |
var downloadURL1 = new Tracker("ZQ", "https://zooqle.com/img/zq-favicon16.png", "https://zooqle.com/search?q=", true); | |
var downloadURL2 = new Tracker("IMDB", "http://ia.media-imdb.com/images/G/01/imdb/images/favicon-2165806970._CB527169355_.ico", "http://www.imdb.com/find?q=", false); | |
// --------------- END OF downloadURL --------------- | |
if (window.location.href.indexOf("allinone") > -1) { | |
addDownloadAllInOne(downloadURL0); | |
addDownloadAllInOne(downloadURL1); | |
addDownloadAllInOne(downloadURL2); | |
} else if (window.location.href.indexOf("epslist") > -1) { | |
addDownloadEpisodeList(downloadURL0); | |
addDownloadEpisodeList(downloadURL1); | |
addDownloadEpisodeList(downloadURL2); | |
} else if (window.location.href.indexOf("show") > -1) { | |
addDownloadEpisodesByShow(downloadURL0); | |
addDownloadEpisodesByShow(downloadURL1); | |
addDownloadEpisodesByShow(downloadURL2); | |
} else if (window.location.href.indexOf("quickcheck") > -1) { | |
addDownloadQuickList(downloadURL0); | |
addDownloadQuickList(downloadURL1); | |
addDownloadQuickList(downloadURL2); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment