Fix Yify

Add content ratings to Yify listings and replace torrent urls with magnet links.

  1. // ==UserScript==
  2. // @name Fix Yify
  3. // @namespace yts.to
  4. // @description Add content ratings to Yify listings and replace torrent urls with magnet links.
  5. //
  6. // @include http://yify-movie.com/search*
  7. // @include http://yify-movie.com/recent*
  8. // @include http://yify-movie.com/genres/*
  9. // @include http://yify-movie.com/years/*
  10. // @require http://code.jquery.com/jquery-1.11.0.min.js
  11. // @version 0.2.3
  12. // @grant GM_xmlhttpRequest
  13. // @grant GM_addStyle
  14. // ==/UserScript==
  15.  
  16. // Bigger fonts
  17. GM_addStyle('\
  18. .imdb-high { \
  19. background: green; \
  20. color: white; \
  21. padding: 1px 4px 1px 4px; \
  22. } \
  23. .imdb-med { \
  24. background: orange; \
  25. color: white; \
  26. padding: 1px 4px 1px 4px; \
  27. } \
  28. .imdb-low { \
  29. background: red; \
  30. color: white; \
  31. padding: 1px 4px 1px 4px; \
  32. } \
  33. figcaption { \
  34. font-weight: bold; \
  35. } \
  36. figcaption { \
  37. background: white; \
  38. border-radius: 15px; \
  39. height: 90px !important; \
  40. } \
  41. figcaption:hover { \
  42. color: white; \
  43. background: gray; \
  44. } \
  45. ');
  46.  
  47. function imdbRating(imdb) {
  48. var score = parseInt(imdb, 10);
  49. var rating = null;
  50. if (score > 6.9) {
  51. rating = 'imdb-high';
  52. } else if (score > 4.5) {
  53. rating = 'imdb-med';
  54. } else {
  55. rating = 'imdb-low';
  56. }
  57.  
  58. return '<span class="' + rating + '">' + imdb + '</span>';
  59. }
  60.  
  61. function addTorrentLink(dom, div) {
  62. $("dd:nth-child(17)", $(dom)).each(function(i) {
  63. mpr = $(this).text();
  64. });
  65. $("dd:nth-child(20)", $(dom)).each(function(i) {
  66. imdb = $(this).text();
  67. });
  68. $("#dm", $(dom)).each(function(i) {
  69. magnet = $(this).attr('href');
  70. });
  71.  
  72. var title = div.find('h3').text();
  73.  
  74. var newText = '<figcaption><a href="'+magnet+'" title="click to download">';
  75. newText += "<h3>" + title + '</h3>';
  76. newText += '<div>MPR: '+mpr+'</div>';
  77. newText += '<div>IMDB: '+imdbRating(imdb)+'</div>';
  78. newText += "</figcaption></a>";
  79.  
  80. div.find('figcaption').replaceWith(newText);
  81. }
  82.  
  83. function addPopupCast(dom, div) {
  84. var cast = 'ACTORS: ';
  85. $("span:nth-child(5) span", $(dom)).each(function(i) {
  86. cast += $(this).text() + ', ';
  87. });
  88. cast = cast.replace(/, $/, '');
  89. // console.log("CAST: "+cast);
  90. div.find("a").prop("title", cast);
  91. }
  92.  
  93. function imposeMyWill(url, div) {
  94. var data = null;
  95. // console.log("DIV: "+ div);
  96. GM_xmlhttpRequest({
  97. method: "GET",
  98. url: url,
  99. onload: function(response) {
  100. // We've received a response
  101. data = $.parseHTML(response.responseText);
  102. // console.log("DATA: "+ data);
  103. addTorrentLink(data, div);
  104. addPopupCast(data, div);
  105. return;
  106. },
  107. onerror: function(response) {
  108. data = JSON.parse(response.responseText);
  109. console.log('ERROR: '+data);
  110. // $('#yts-options').html('<p>ERROR! Failed to connect to the YTS website.</p>');
  111. }
  112. });
  113. }
  114.  
  115. function removeAds() {
  116. var ads = $('a.hidden-xs');
  117. if (ads.length) {
  118. console.log('Removing ad box.');
  119. ads.remove();
  120. }
  121. }
  122.  
  123. $(document).ready(function() {
  124. var divs = $("article.img-item");
  125. var link = null;
  126. var url = null;
  127.  
  128. // removeAds();
  129.  
  130. $(divs).each(function(i) {
  131. link = $(this).find('h3 a');
  132. url = link.attr('href');
  133. // console.log("URL: "+url);
  134. imposeMyWill(url, $(this));
  135. });
  136. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址