Gormogon Enhancer

Better display for Gormogon

  1. // ==UserScript==
  2. // @name Gormogon Enhancer
  3. // @namespace surrealmoviez.info
  4. // @description Better display for Gormogon
  5. // @include http://www.gormogon.com/*
  6. // @require http://code.jquery.com/jquery-1.11.1.min.js
  7. // @grant none
  8. // @version 0.3.10
  9. // ==/UserScript==
  10.  
  11. // Link the page banner to the index
  12. $('.tracker_logo').wrap('<a href="index.php"></a>');
  13. // Properly center the site logo (OCD, you know...)
  14. $('#logo > table').attr('width', 'auto');
  15. $('#logo .tracker_logo').css('width', '675px');
  16.  
  17. // If present, modify the main menu
  18. if ($('#menu').length === 1) {
  19. // Remove the user bar toggler
  20. $('#slideIt img[alt=click]').closest('span').hide();
  21. // Shrink unnecessary empty spaces
  22. $('#menu').css('height', '40px');
  23. // Add a link to 'All torrents' to 'Torrents Menu' and the 'Torrents' submenu
  24. $('#menu .level2 .fly:contains("Torrents")').attr('href', 'http://www.gormogon.com/index.php?page=torrents&search=&category=0&active=0');
  25. $('.level1-li .level1-a:contains("Torrent Menu")').attr('href', 'http://www.gormogon.com/index.php?page=torrents&search=&category=0&active=0');
  26. // Rename the 'User Menu' panel
  27. $('.level1-li .level1-a:contains("User Menu")').text('Community');
  28. // Place 'My Panel' as a top level menu
  29. var uid = $('ul.level2 a:contains("CP Home")').attr('href');
  30. uid = uid.substring(uid.indexOf('uid=') + 4);
  31. $('.fly:contains("My Panel")').parent().remove();
  32. var myPanelMenu = '<li class="level1-li"><a href="index.php?page=usercp&amp;uid=' + uid + '" class="level1-a drop">My panel</a>'
  33. + '<!--[if gte IE 7]><!--><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->'
  34. + '<ul class="level2">'
  35. + '<li><a href="index.php?page=usercp&amp;uid=' + uid + '">My profile</a></li>'
  36. + '<li><a href="index.php?page=usercp&amp;uid=' + uid + '&amp;do=pm&amp;action=list&amp;what=inbox" class="fly">My PMs</a>'
  37. + '<!--[if gte IE 7]><!--><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->'
  38. + '<ul class="level3">'
  39. + '<li><a href="index.php?page=usercp&amp;uid=' + uid + '&amp;do=pm&amp;action=list&amp;what=inbox">Inbox</a></li>'
  40. + '<li><a href="index.php?page=usercp&amp;uid=' + uid + '&amp;do=pm&amp;action=list&amp;what=outbox">Outbox</a></li>'
  41. + '<li><a href="index.php?page=usercp&amp;uid=' + uid + '&amp;do=pm&amp;action=edit&amp;uid=' + uid + '&amp;what=new">Write new</a></li>'
  42. + '</ul><!--[if lte IE 6]></td></tr></table></a><![endif]--></li>'
  43. + '<li><a href="index.php?page=usercp&amp;do=user&amp;action=change&amp;uid=' + uid + '" class="fly">Edit Profile</a>'
  44. + '<!--[if gte IE 7]><!--><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->'
  45. + '<ul class="level3">'
  46. + '<li><a href="index.php?page=usercp&amp;do=user&amp;action=change&amp;uid=' + uid + '">General</a></li>'
  47. + '<li><a href="index.php?page=usercp&amp;do=pwd&amp;action=change&amp;uid=' + uid + '">Password</a></li>'
  48. + '<li><a href="index.php?page=usercp&amp;do=pid_c&amp;action=change&amp;uid=' + uid + '">Change PID</a></li>'
  49. + '</ul><!--[if lte IE 6]></td></tr></table></a><![endif]--></li>'
  50. + '<li><a href="logout.php">Logout</a></li>'
  51. + '</ul><!--[if lte IE 6]></td></tr></table></a><![endif]--></li>';
  52. $('#menu > ul.level1').append(myPanelMenu);
  53. // Add 'Collections' as a 'Torrents' menu item
  54. $('<li><a href="smf/index.php?board=12.0">Collections</a></li>').insertAfter('#menu .level2 li:contains("Requests")');
  55. // Remove redundant 'Logout'
  56. $('#menu .level1-li > a:contains("Logout")').remove();
  57. }
  58.  
  59. // Remove lateral blocks
  60. var blocksToRemove = ['.block-head-title:contains("Clock")', // every computer has a clock... and it's too glittery
  61. '.block-head-title:contains("Lottery")', // Closed since ever
  62. '.block-head-title:contains("User Info")', // Redundant
  63. '.block-head-title:contains("Main Menu")']; // Redundant
  64. for (var i = 0; i < blocksToRemove.length; i++) {
  65. var el = $(blocksToRemove[i]).closest('.block');
  66. el.prev('br').remove();
  67. el.remove();
  68. }
  69.  
  70. // Place some bottom blocks in the empty space left by the removed ones
  71. var blocksToMove = ['.block-head-title:contains("Tracker Info")',
  72. '.block-head-title:contains("Poll")'];
  73. var pivotBlock = $('.block-head-title:contains("Support US")').closest('.block');
  74. for (var i = 0; i < blocksToMove.length; i++) {
  75. $(blocksToMove[i]).closest('.block').insertAfter(pivotBlock);
  76. }
  77.  
  78. // Fix select elements with black font over black background
  79. $('select.drop_pager').css('color', '#855C45');
  80.  
  81. // Align the current user stats to the right to read it easily
  82. $('#mcol .b-content > .lista tr:not(:last-child) td:first-child').attr('align', 'right');
  83.  
  84. // Remove duplicated elements from iframes
  85. if (window.self !== window.top) {
  86. $('#logo').remove();
  87. }
  88.  
  89. // Modifications to 'Torrent details' pages
  90. if (document.documentURI.indexOf("page=torrent-details") !== -1) {
  91. // Add the film title to the page title (to be remembered in Firefox' autocompletition)
  92. document.title = 'Gormogon .::. ' + $('.header:contains("Name")').eq(0).next('td').text();
  93. // Display the IMDb ID in each article
  94. var imdbRow = '<tr><td align="right" class="header">IMDb ID</td><td id="imdbRow" valign="top" align="center" style="text-align:left;" class="lista">No IMDb found</td></tr>';
  95. $(imdbRow).insertAfter($('.header:contains("Torrent")').eq(0).parent());
  96. var iframeImdb = $('#online_ifrm');
  97. if (iframeImdb.length === 1) {
  98. // Search for an IMDb ID in the foreseen section
  99. var imdbId = iframeImdb.attr('src');
  100. imdbId = 'tt' + imdbId.substring(imdbId.indexOf('=') + 1).trim();
  101. $('#imdbRow').html('<a href="http://anonym.to/?http://www.imdb.com/title/' + imdbId + '/" target="_blank">' + imdbId + '</a>');
  102. } else {
  103. // Search for IMDb IDs in the description
  104. var description = $('.header:contains("Description")').next('td').html();
  105. var pattern = /(tt\d+)/gi;
  106. var found = description.match(pattern);
  107.  
  108. if (found.length > 0) {
  109. var uniqueIds = [];
  110. $.each(found, function(i, el) {
  111. if ($.inArray(el, uniqueIds) === -1)
  112. uniqueIds.push(el);
  113. });
  114. var stringLinksImdb = "";
  115. for (var i = 0; i < uniqueIds.length; i++) {
  116. stringLinksImdb += '<a href="http://anonym.to/?http://www.imdb.com/title/' + uniqueIds[i] + '/" target="_blank">' + uniqueIds[i] + '</a> ';
  117. }
  118. $('#imdbRow').html(stringLinksImdb + '(guessed from the description content)');
  119. }
  120. }
  121. }
  122.  
  123. // Add a global search bar
  124. if (window.self === window.top && document.documentURI.indexOf("page=torrents") === -1) {
  125. var placeholder;
  126. if (document.documentURI.indexOf("/smf/") === -1) {
  127. placeholder = $('#slideIt img[alt=click]').closest('span');
  128. $('#menu li').css('z-index', '100');
  129. } else {
  130. placeholder = $('#logo');
  131. $('#logo').css('margin-bottom', '3px');
  132. $('#logo').next('table').css('margin-top', '3px');
  133. }
  134. var searchDiv = '<form id="searchBar" action="index.php" style="margin-left: 8px; margin-right: 12px; text-align: center;">'
  135. + '<input type="text" name="search" style="width: 85%; height: 20px; border: 1px solid rgb(51, 51, 51); background-color: rgb(25, 25, 25); color: white; border-radius: 3px; margin-right: 3px; padding-left: 4px; padding-right: 4px;" placeholder="Search torrents" name="search" maxlength="250" value="">'
  136. + '<select size="1" name="options" style="width: auto; height: 20px; border: 1px solid rgb(51, 51, 51); background-color: rgb(25, 25, 25); color: grey; border-radius: 3px;">'
  137. + '<option selected="selected" value="0">File name</option>'
  138. + '<option value="2">Description</option>'
  139. + '<option value="1">Both</option>'
  140. + '</select>'
  141. + '<input type="hidden" name="page" value="torrents">'
  142. + '<input type="hidden" name="category" value="0">'
  143. + '<input type="hidden" name="options" value="0">'
  144. + '<input type="hidden" name="active" value="0">'
  145. + '</form>';
  146. $(searchDiv).insertAfter(placeholder);
  147. }
  148.  
  149. // Remove the huge redundant yellow buttons
  150. if (document.documentURI === 'http://www.gormogon.com/' || document.documentURI === "http://www.gormogon.com/index.php") {
  151. var trButtons = $('#img5').closest('.lista').parent();
  152. trButtons.hide();
  153. trButtons.prev().hide();
  154. }