TVmaze Downloader

Adds download links to TVmaze website

当前为 2015-10-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name TVmaze Downloader
  3. // @description Adds download links to TVmaze website
  4. // @namespace https://greasyfork.org/en/users/814-bunta
  5. // @include http://www.tvmaze.com/*
  6. // @version 1.0
  7. // @Author Bunta
  8. // @license http://creativecommons.org/licenses/by-nc-sa/3.0/us/
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12.  
  13. /* Console import for testing:
  14. var body = document.getElementsByTagName("body")[0];
  15. var script = document.createElement('script');
  16. script.type = "text/javascript";
  17. script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";
  18. body.appendChild(script);
  19. var $ = JQuery
  20. */
  21.  
  22. (function() {
  23. var $ = unsafeWindow.jQuery;
  24. function Tracker(shortname, icon, searchurl, useNumbers) {
  25. this.shortname = shortname;
  26. this.icon = icon;
  27. this.searchurl = searchurl;
  28. this.useNumbers = useNumbers;
  29. this.getHTML = function (query) {
  30. var tShortname = this.shortname;
  31. var tIcon = this.icon;
  32. var tSearchURL = this.searchurl;
  33. var tUseNumbers = this.useNumbers;
  34. // Alter search or link parameters for special cases
  35. switch (query)
  36. {
  37. case "Marvel's Agents of S.H.I.E.L.D":
  38. query = "Marvels Agents";
  39. break;
  40. case "Fairy Tail":
  41. query = "";
  42. tUseNumbers = false;
  43. tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=fairy+tail+horrible+480";
  44. tIcon = "http://anidb.net/favicon.ico";
  45. tShortname = "Anime";
  46. break;
  47. case "Hunter x Hunter":
  48. query = "";
  49. tUseNumbers = false;
  50. tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=hunter+horrible+480p";
  51. tIcon = "http://anidb.net/favicon.ico";
  52. tShortname = "Anime";
  53. break;
  54. case "Magi: The Labyrinth of Magic":
  55. query = "";
  56. tUseNumbers = false;
  57. tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=magi+hatsuyuki+480";
  58. tIcon = "http://anidb.net/favicon.ico";
  59. tShortname = "Anime";
  60. break;
  61. case "Naruto: Shippuuden":
  62. query = "";
  63. tUseNumbers = false;
  64. tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=naruto+horrible+480p";
  65. tIcon = "http://anidb.net/favicon.ico";
  66. tShortname = "Anime";
  67. break;
  68. case "Kiseijuu":
  69. query = "";
  70. tUseNumbers = false;
  71. tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=parasyte+horrible+480p";
  72. tIcon = "http://anidb.net/favicon.ico";
  73. tShortname = "Anime";
  74. break;
  75. case "One Piece":
  76. query = "";
  77. //tSearchURL = "http://tracker.yibis.com/index.php";
  78. tUseNumbers = false;
  79. tSearchURL = "http://www.nyaa.se/?page=search&cats=1_37&filter=0&term=one+piece+horrible+480";
  80. tIcon = "http://anidb.net/favicon.ico";
  81. tShortname = "Anime";
  82. break;
  83. default:
  84. break;
  85. }
  86. /*
  87. if(tUseNumbers){
  88. search = query + " " + episode;
  89. } else{
  90. search = query;
  91. }
  92. */
  93. var html = "<a target=\"_blank\" href=\"" + tSearchURL;
  94. html += escape(query);
  95. html += "\">";
  96.  
  97. if (tIcon != "") {
  98. html += "<img width=\"14\" heigth=\"14\" border=\"0\" src=\"" + tIcon + "\" alt=\"" + tShortname + "\">";
  99. } else {
  100. html += tShortname;
  101. }
  102. html += "</a>";
  103. return html;
  104. }
  105. // Used for old EZTV site POST process
  106. this.getEZTVPostHTML = function (query) {
  107. var html = "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-2\">" +
  108. "<form target=\"_blank\" action=\"https://eztv.ag/search/\" method=\"POST\" name=\"search\" id=\"search\">" +
  109. //"<script type=\"text/javascript\">function search_submit_form( obj ) { $( '#' + obj ).click(); return false; }</script>" +
  110. "<input type=\"submit\" value=\"Search\" name=\"search\" id=\"search_submit\" style=\"display: none;\" />" +
  111. "<input type=\"hidden\" name=\"SearchString1\" value=\""
  112. html += query;
  113. html += "\" /><a href=\"javascript:void(0);\" onclick=\"parentNode.submit()\">";
  114.  
  115. if (this.icon != "") {
  116. html += "<img width=\"14\" heigth=\"14\" border=\"0\" src=\"" + this.icon + "\" alt=\"" + this.shortname + "\">";
  117. } else {
  118. html += this.shortname;
  119. }
  120. html += "</a></form></font>";
  121. return html;
  122. }
  123. }
  124. function addDownloadWatchList(downloadURL) {
  125. // iterate through all series tables
  126. $("table.table-striped").each(function() {
  127. // Create Download column
  128. $(this).find("thead tr th").last().attr({ colspan: '2' });
  129. // Remove "Mark as watched" text
  130. $(this).find("span.show-for-medium-up").text("Mark as acquired")
  131. // Get series title
  132. var showTitle = $(this).parent().parent().prev().children("a").text();
  133. // Add download link to each episode
  134. $(this).find("tbody tr").append("<td style='width:5px'>" + downloadURL.getHTML(showTitle) + "</td>");
  135. });
  136. }
  137. function addDownloadEpisodeList(downloadURL) {
  138. // Get series title
  139. var showTitle = $("h1").text().replace(" - Episode List","");
  140. // iterate through all series tables
  141. $("table.table-striped").each(function() {
  142. // Alter "Watched" column header
  143. $(this).find("thead tr th").last().children("a").text("")
  144. // Create Download column
  145. $(this).find("thead tr").append("<th></th>");
  146. // Add download link to each episode
  147. $(this).find("tbody tr").append("<td style='width:5px'>" + downloadURL.getHTML(showTitle) + "</td>");
  148. });
  149. }
  150. // --------------- downloadURL ---------------
  151. var downloadURL = new Tracker("EZTV", "http://eztv.ag/favicon.ico", "https://eztv.ag/search/", false);
  152. //var downloadURL = new Array();
  153. //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));
  154. // --------------- END OF downloadURL ---------------
  155.  
  156. if($("title").text().contains("Watch List")){
  157. addDownloadWatchList(downloadURL);
  158. } else if($("title").text().contains("Episode List")){
  159. addDownloadEpisodeList(downloadURL);
  160. }// else if($("title").text().contains("Episode")){
  161. // addDownloadEpisode(downloadURL);
  162. // }
  163. })();