Adds download links to MyEpisodes website
当前为
// ==UserScript==
// @name MyEpisodes Downloader
// @description Adds download links to MyEpisodes website
// @namespace https://greatest.deepsurf.us/en/users/814-bunta
// @include *myepisodes.com/myshows.php*
// @include *myepisodes.com/allinone*
// @include *myepisodes.com/epslist*
// @version 1.3
// @Author Bunta
// @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 "Marvel's Agents of S.H.I.E.L.D":
query = "Marvels Agents";
break;
case "Ash vs Evil Dead":
tSearchURL = "https://kat.cr/usearch/ettv -720 -1080 ";
tIcon = "https://kat.cr/favicon.ico";
tShortname = "Kickass";
break;
case "Fairy Tail":
query = "";
tUseNumbers = false;
tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=fairy+tail+horrible+480";
tIcon = "http://anidb.net/favicon.ico";
tShortname = "Anime";
break;
case "Hunter x Hunter":
query = "";
tUseNumbers = false;
tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=hunter+horrible+480p";
tIcon = "http://anidb.net/favicon.ico";
tShortname = "Anime";
break;
case "God Eater":
query = "";
tUseNumbers = false;
tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=god+eater+horrible+480p";
tIcon = "http://anidb.net/favicon.ico";
tShortname = "Anime";
break;
case "Magi: The Labyrinth of Magic":
query = "";
tUseNumbers = false;
tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=magi+hatsuyuki+480";
tIcon = "http://anidb.net/favicon.ico";
tShortname = "Anime";
break;
case "Naruto: Shippuuden":
query = "";
tUseNumbers = false;
tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=naruto+horrible+480p";
tIcon = "http://anidb.net/favicon.ico";
tShortname = "Anime";
break;
case "Kiseijuu":
query = "";
tUseNumbers = false;
tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=parasyte+horrible+480p";
tIcon = "http://anidb.net/favicon.ico";
tShortname = "Anime";
break;
case "One Piece":
query = "";
//tSearchURL = "http://tracker.yibis.com/index.php";
tUseNumbers = false;
tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=one+piece+horrible+480";
tIcon = "http://anidb.net/favicon.ico";
tShortname = "Anime";
break;
default:
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 width=\"14\" heigth=\"14\" border=\"0\" src=\"" + tIcon + "\" alt=\"" + tShortname + "\">";
} else {
html += tShortname;
}
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 addDownloadSeriesWatch(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;\">Download</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>" + downloadURL.getHTML(showTitle, episode) + "</td>");
});
});
}
function addDownloadPrivateShowList(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 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 downloadURL = new Tracker("EZTV", "http://eztv.ag/favicon.ico", "https://eztv.ag/search/", false);
//var downloadURL = new Array();
//downloadURL.push(new Tracker("Kickass", "https://kastatic.com/images/favicon.ico", "https://kickass.to/usearch/?field=time_add&sorder=desc&q=ettv -720p -1080p ", false));
// --------------- END OF downloadURL ---------------
/** Old title check
if($("title").text().contains("SeriesWatch")){
addDownloadSeriesWatch(downloadURL);
} else if($("title").text().contains("Private Show List")){
addDownloadPrivateShowList(downloadURL);
}
*/
if (window.location.href.indexOf("allinone") > -1) {
addDownloadSeriesWatch(downloadURL);
} else if (window.location.href.indexOf("epslist") > -1) {
addDownloadPrivateShowList(downloadURL);
}
})();