MyEpisodes Downloader

Adds download links to MyEpisodes website

  1. // ==UserScript==
  2. // @name MyEpisodes Downloader
  3. // @description Adds download links to MyEpisodes website
  4. // @namespace https://greasyfork.org/en/users/814-bunta
  5. // @include *myepisodes.com/allinone*
  6. // @include *myepisodes.com/epslist*
  7. // @include *myepisodes.com/show*
  8. // @include *myepisodes.com/epsbyshow*
  9. // @version 1.12.1
  10. // @Author Bunta
  11. // @license http://creativecommons.org/licenses/by-nc-sa/3.0/us/
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15.  
  16. /* Console import for testing:
  17. var body = document.getElementsByTagName("body")[0];
  18. var script = document.createElement('script');
  19. script.type = "text/javascript";
  20. script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";
  21. body.appendChild(script);
  22. var $ = JQuery
  23. */
  24.  
  25. (function() {
  26. function Tracker(shortname, icon, searchurl, useNumbers, appendText='') {
  27. this.shortname = shortname;
  28. this.icon = icon;
  29. this.searchurl = searchurl;
  30. this.useNumbers = useNumbers;
  31. this.appendText = appendText;
  32. this.getHTML = function (query, episode) {
  33. var tShortname = this.shortname;
  34. var tIcon = this.icon;
  35. var tSearchURL = this.searchurl;
  36. var tUseNumbers = this.useNumbers;
  37. query = query.replace("'","");
  38. // Alter search or link parameters for special cases
  39. switch (query)
  40. {
  41. case "The Promised Neverland":
  42. query = "";
  43. tUseNumbers = false;
  44. tSearchURL = "https://animekaizoku.com/the-promised-neverland-season-2-39617/";
  45. tIcon = "https://animekaizoku.com/favicon.ico";
  46. tShortname = "Anime";
  47. break;
  48. case "That Time I Got Reincarnated as a Slime":
  49. query = "";
  50. tUseNumbers = false;
  51. tSearchURL = "https://animekaizoku.com/that-time-i-got-reincarnated-as-a-slime-season-2-39551/";
  52. tIcon = "https://animekaizoku.com/favicon.ico";
  53. tShortname = "Anime";
  54. break;
  55. case "World Trigger":
  56. query = "";
  57. tUseNumbers = false;
  58. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=World+Trigger+SSA";
  59. tIcon = "https://nyaa.si/static/favicon.png";
  60. tShortname = "Anime";
  61. break;
  62. case "Boku no Hero Academia":
  63. query = "";
  64. tUseNumbers = false;
  65. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=Boku+no+Hero+Academia";
  66. tIcon = "https://nyaa.si/static/favicon.png";
  67. tShortname = "Anime";
  68. break;
  69. case "Vinland Saga":
  70. query = "";
  71. tUseNumbers = false;
  72. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=vinland+saga";
  73. tIcon = "https://nyaa.si/static/favicon.png";
  74. tShortname = "Anime";
  75. break;
  76. case "Sword Art Online":
  77. query = "";
  78. tUseNumbers = false;
  79. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=sword+art+online+judas";
  80. tIcon = "https://nyaa.si/static/favicon.png";
  81. tShortname = "Anime";
  82. break;
  83. case "Tokyo Ghoul":
  84. query = "";
  85. tUseNumbers = false;
  86. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=tokyo+ghoul";
  87. tIcon = "https://nyaa.si/static/favicon.png";
  88. tShortname = "Anime";
  89. break;
  90. case "Attack on Titan":
  91. query = "";
  92. tUseNumbers = false;
  93. tSearchURL = "https://animekaizoku.com/attack-on-titan-the-final-season-40028/";
  94. tIcon = "https://animekaizoku.com/favicon.ico";
  95. tShortname = "Anime";
  96. break;
  97. case "Fairy Tail":
  98. query = "";
  99. tUseNumbers = false;
  100. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=fairy+tail";
  101. tIcon = "https://nyaa.si/static/favicon.png";
  102. tShortname = "Anime";
  103. break;
  104. case "Fairy Tail Zero":
  105. query = "";
  106. tUseNumbers = false;
  107. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=fairy+tail+zero";
  108. tIcon = "https://nyaa.si/static/favicon.png";
  109. tShortname = "Anime";
  110. break;
  111. case "Hunter x Hunter":
  112. query = "";
  113. tUseNumbers = false;
  114. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=hunter";
  115. tIcon = "https://nyaa.si/static/favicon.png";
  116. tShortname = "Anime";
  117. break;
  118. case "God Eater":
  119. query = "";
  120. tUseNumbers = false;
  121. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=god+eater";
  122. tIcon = "https://nyaa.si/static/favicon.png";
  123. tShortname = "Anime";
  124. break;
  125. case "Magi: The Labyrinth of Magic":
  126. query = "";
  127. tUseNumbers = false;
  128. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=magi+hatsuyuki+480";
  129. tIcon = "https://nyaa.si/static/favicon.png";
  130. tShortname = "Anime";
  131. break;
  132. case "Naruto: Shippuuden":
  133. query = "";
  134. tUseNumbers = false;
  135. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=naruto";
  136. tIcon = "https://nyaa.si/static/favicon.png";
  137. tShortname = "Anime";
  138. break;
  139. case "Boruto: Naruto Next Generations":
  140. query = "";
  141. tUseNumbers = false;
  142. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=boruto";
  143. tIcon = "https://nyaa.si/static/favicon.png";
  144. tShortname = "Anime";
  145. break;
  146. case "Kiseijuu":
  147. query = "";
  148. tUseNumbers = false;
  149. tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=parasyte";
  150. tIcon = "https://nyaa.si/static/favicon.png";
  151. tShortname = "Anime";
  152. break;
  153. case "One Piece":
  154. query = "";
  155. tUseNumbers = false;
  156. //tSearchURL = "http://tracker.yibis.com/index.php";
  157. //tSearchURL = "https://nyaa.si/?f=0&c=1_2&q=one+piece";
  158. tSearchURL = "https://animekaizoku.com/one-piece-21/";
  159. tIcon = "https://animekaizoku.com/favicon.ico";
  160. tShortname = "Anime";
  161. break;
  162. default:
  163. break;
  164. }
  165. // Add episode numbers if enabled
  166. if(tUseNumbers){
  167. query = query + " " + episode;
  168. }
  169. var html = "<a target=\"_blank\" href=\"" + tSearchURL;
  170. html += escape(query);
  171. html += appendText;
  172. html += "\">";
  173. if (tIcon != "") {
  174. html += "<img width=\"14\" height=\"14\" border=\"0\" src=\"" + tIcon + "\" alt=\"" + tShortname + "\">";
  175. } else {
  176. html += tShortname;
  177. }
  178. html += "</a>";
  179. return html;
  180. }
  181. // Used for old EZTV site POST process
  182. this.getEZTVHTML = function (query) {
  183. var html = "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-2\">" +
  184. "<form target=\"_blank\" action=\"https://eztv.ag/search/\" method=\"POST\" name=\"search\" id=\"search\">" +
  185. // "<script type=\"text/javascript\">function search_submit_form( obj ) { $( '#' + obj ).click(); return false; }</script>" +
  186. "<input type=\"submit\" value=\"Search\" name=\"search\" id=\"search_submit\" style=\"display: none;\" />" +
  187. "<input type=\"hidden\" name=\"SearchString1\" value=\""
  188. html += query;
  189. html += "\" /><a href=\"javascript:void(0);\" onclick=\"parentNode.submit()\">";
  190. if (this.icon != "") {
  191. html += "<img width=\"14\" heigth=\"14\" border=\"0\" src=\"" + this.icon + "\" alt=\"" + this.shortname + "\">";
  192. } else {
  193. html += this.shortname;
  194. }
  195. html += "</a></form></font>";
  196. return html;
  197. }
  198. }
  199. function addDownloadAllInOne(downloadURL) {
  200. WaitForState("div#serieswatch table span.shows").done(function() {
  201. // iterate through series table
  202. var seriesTable = $("div#serieswatch").children("table");
  203. // Create Download column
  204. seriesTable.find("tr.header").append("<td style=\"border-bottom: solid 1px black;\">Download</td>");
  205. // iterate through rows
  206. seriesTable.find("tr[class!=header]").each(function() {
  207. // Get series title
  208. var showTitle = $(this).find("span.shows").text();
  209. // Get episode number
  210. var episode = $(this).find("td b").first().text().trim();
  211. // Add download link to each episode
  212. $(this).append("<td>" + downloadURL.getHTML(showTitle, episode) + "</td>");
  213. });
  214. });
  215. }
  216. function addDownloadEpisodeList(downloadURL) {
  217. WaitForState("div#myepisodes_views table.mylist").done(function() {
  218. // iterate through series table
  219. var seriesTable = $("div#myepisodes_views table.mylist");
  220. // Create Download column
  221. seriesTable.find("tr.header").append("<th title=\"Download\">D</th>");
  222. // iterate through rows
  223. seriesTable.find("tr[class!=header]").each(function() {
  224. // Get series title
  225. var showTitle = $(this).find("td.showname a").text();
  226. // Get episode number
  227. var episode = "S" + $(this).find("td.longnumber").text().replace("x", "E");
  228. // Add download link to each episode
  229. $(this).append("<td>" + downloadURL.getHTML(showTitle, episode) + "</td>");
  230. });
  231. });
  232. }
  233. function addDownloadEpisodesByShow(downloadURL) {
  234. WaitForState("div#myepisodes_views table.mylist").done(function() {
  235. var showTitle = $("div.showname").next().text()
  236. // iterate through series table
  237. var seriesTable = $("div#myepisodes_views table.mylist");
  238. // Create Download column
  239. seriesTable.find("tr.header").append("<th title=\"Download\">D</th>");
  240. // iterate through rows
  241. seriesTable.find("tr.odd, tr.even").each(function() {
  242. // Get episode number
  243. var episode = "S" + $(this).find("td.longnumber").text().replace("x", "E");
  244. // Add download link to each episode
  245. $(this).append("<td>" + downloadURL.getHTML(showTitle, episode) + "</td>");
  246. });
  247. });
  248. }
  249. function WaitForState(query) {
  250. var dfd = $.Deferred();
  251. window.setTimeout(function() {AttemptResolve(query, dfd);}, 100); // Doesn't work without a short delay
  252. return dfd;
  253. }
  254. function AttemptResolve(query, dfd) {
  255. if (query === "" || $(query).length) {
  256. dfd.resolve();
  257. } else {
  258. window.setTimeout(function() {AttemptResolve(query, dfd);}, 100); // Try again in a little bit
  259. }
  260. }
  261.  
  262. function useSeenOnly() {
  263. acquiredLinks = $("div#serieswatch table tbody td a[href$='seen=0']");
  264. acquiredLinks.attr('href', function (i, attr) {
  265. return attr.replace('seen=0','seen=1');
  266. });
  267. // Dim "Coming" icons
  268. $("img[src*='coming.gif']").attr('style',"filter: sepia(50%) grayscale(70%);");
  269. // Enhance "Acquire" icons
  270. $("img[src*='acquire.gif']").attr('style',"filter: saturate(150%);");
  271. }
  272. // --------------- downloadURL ---------------
  273. var downloadURL = new Tracker("EZTV", "https://eztv.ag/favicon.ico", "https://eztv.ag/search/", false);
  274. var downloadURL2 = new Tracker("IPT", "https://ipt.lol/favicon.ico", "https://iptorrents.com/t?99=&q=", false, "#torrents");
  275. //var downloadURL = new Tracker("Kickass", "https://kastatic.com/images/favicon.ico", "https://kickass.to/usearch/?field=time_add&sorder=desc&q=ettv -720p -1080p ", false));
  276. // --------------- END OF downloadURL ---------------
  277. var seenLinksOnly = false;
  278. if (window.location.href.indexOf("allinone") > -1) {
  279. addDownloadAllInOne(downloadURL);
  280. addDownloadAllInOne(downloadURL2);
  281. if (seenLinksOnly) { useSeenOnly(); }
  282. } else if (window.location.href.indexOf("epslist") > -1) {
  283. addDownloadEpisodeList(downloadURL);
  284. } else if (window.location.href.indexOf("show") > -1) {
  285. addDownloadEpisodesByShow(downloadURL);
  286. }
  287. })();