Create Summary From IMDb [User+][KAT]

Creates a summary from any IMDB page.

  1. // ==UserScript==
  2. // @name Create Summary From IMDb [User+][KAT]
  3. // @namespace pxgamer
  4. // @description Creates a summary from any IMDB page.
  5. // @include *kat.cr/*-i*/*
  6. // @include *imdb.com/title/tt*
  7. // @include *imdb.com/search/title?*
  8. // @author pxgamer
  9. // @version 1.3
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. var url = window.location.pathname;
  14. var elem;
  15. var summary;
  16. var summaryCustom = '<p style="color:#136CB2;cursor:pointer;display: inline-block;" id="setSummary">Set Custom Summary</p>';
  17. var movieid;
  18. /* PAGES */
  19. if (/.*-i\d{5,7}\//.test(url)) { /* KAT Metadata Page */
  20. /* remove blankrefer :D */
  21. $('.dataList [href*="www.imdb.com/title/tt"]').attr('href', $('.dataList [href*="www.imdb.com/title/tt"]').attr('href').split('?')[1]);
  22.  
  23. if (window.location.search.length > 6) {
  24. summary = (window.location.search.substring(6));
  25. movieid = $('.dataList [href*="imdb.com/title/tt"]').text();
  26.  
  27. if ($('.movieCover img[src=""]').length) { /* If no metadata */
  28. $('.dataList [href*="imdb.com/title/tt"]').after(' <i class="ka ka16 ka-torrent" id="generateMetadata"></i>'); /* For when was not auto */
  29. generateMetadata(); /* Auto generate some */
  30. }else if (!$('div#summary').length){ /* If summary isn't there */
  31. addSummary(); /* Auto create summary */
  32. }
  33. }
  34. }else if(/\/synopsis$/.test(url)) {
  35. movieid = window.location.pathname.split('tt')[1].split('/')[0];
  36.  
  37. $('.summary_text[itemprop="description"]').before(summaryCustom);
  38. }else if (/\/title\/tt/.test(url)) {
  39. movieid = window.location.pathname.split('tt')[1].split('/')[0];
  40.  
  41. if (!$('[itemprop="description"] [href^="/updates?"]').length) {
  42. var descOne = $('[itemprop="description"]');
  43. $('#titleStoryLine [itemprop="description"] p *').remove();
  44. var secondSynopsis = $('#titleStoryLine [itemprop="description"] p').html();
  45. if (descOne.find('a[href*="/plotsummary?"]').length) { /* Read more */
  46. descOne.html(secondSynopsis);
  47. descOne.find('*').remove();
  48. }else{
  49. descOne.after('<div style="border: 1px solid rgb(219, 219, 219); border-radius: 5px; right: 4px; position: relative; padding-left: 2px; margin-right: -4px;">'+
  50. '<p style="color:#136CB2;cursor:pointer;" onclick="$(this).next().toggle();">Second Summary</p>'+
  51. '<p id="descTwo" itemprop="description">'+secondSynopsis+'</p>'+
  52. '</div><br/>');
  53. $('#descTwo em.nobr').remove();
  54. }
  55. descOne.before('<a href="https://kat.cr/movie-i'+movieid+'?desc='+encodeURIComponent(descOne.text())+'">Summary One</a> | <a href="https://kat.cr/movie-i'+movieid+'?desc='+encodeURIComponent(secondSynopsis)+'">Summary Two</a> | '+summaryCustom);
  56. }
  57.  
  58.  
  59. }else{
  60. $('.detailed .title > a[href^="/title/tt"]').addClass('fadeOnClick');
  61. /* Hides ones with no posters (and IMDb Pro exclusives). You don't wanna write a summary if there is no poster! */
  62. $('.detailed [src="http://i.media-imdb.com/images/SF1f0a42ee1aa08d477a576fbbf7562eed/realm/feature.gif"], .detailed [href^="/r/"]').closest('.detailed').hide();
  63. }
  64.  
  65. $(document).delegate('#setSummary', 'click', function() {
  66. var text = prompt('Enter Summary:' ,'');
  67. if (text)
  68. window.location = 'https://kat.cr/movie-i'+movieid+'?desc='+encodeURIComponent(text);
  69. });
  70. /* Events for IMDb Search Page */
  71. $(document).delegate('.fadeOnClick', 'mouseup', function() {
  72. $(this).closest('.detailed').fadeOut(200);
  73. });
  74. /* Events for KAT Metadata Page */
  75. $(document).delegate('#generateMetadata', 'click', function() {
  76. generateMetadata(); /* Mainly for non auto - pfft */
  77. });
  78. function generateMetadata() {
  79. $.ajax({
  80. type: "POST",
  81. url: '/moderator/torrent/changeimdb/f00344a0c480ecca8076237ca68fb0bb8e833e3b/', /* My personal test torrent, it doesn't update it tho */
  82. data: { ajax: 1, imdbid: movieid },
  83. dataType: "json",
  84. success: function(response) {
  85. addSummary(); /* Continue onto adding summary */
  86. }
  87. });
  88. return false;
  89. }
  90. function addSummary() {
  91. $.ajax({
  92. type: "POST",
  93. url: '/summary/create/movie/'+movieid+'/',
  94. data: { objectId: movieid, text: decodeURIComponent(summary) },
  95. dataType: "json",
  96. success: function(response) {
  97. window.location = window.location.split("?")[0]; /* Reload page - DONE */
  98. }
  99. });
  100. return false;
  101. }