TraktTvNumberOfElements

Display the number of Shows on the progress page(s)

  1. // ==UserScript==
  2. // @name TraktTvNumberOfElements
  3. // @namespace notableTieView
  4. // @description Display the number of Shows on the progress page(s)
  5. // @include http://trakt.tv/users/*/progress
  6. // @include http://trakt.tv/users/*/progress**
  7. // @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=19641
  8. // @version 1.1
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. waitForKeyElements('#progress-wrapper div.container', execute);
  13.  
  14. function execute() {
  15. var foundShows = 0;
  16. paginationLis = $('.pagination-bottom ul.pagination li');
  17. n = paginationLis.length;
  18. numPages = n - 2;
  19. if ((paginationLis.length > 0) && !(paginationLis.eq(n - 1).hasClass('disabled'))) {
  20. ref = $(paginationLis).eq(n - 2).children().eq(0).attr('href');
  21. $.ajax({
  22. url: ref,
  23. success: function (responseData) {
  24. res = responseData;
  25. foundShows = $(res).find('.container').eq(3).children('div').length - 1;
  26. },
  27. async: false
  28. });
  29. } else {
  30. foundShows = $('#progress-wrapper>.container>div').length - 1; // the last div is pagination
  31. }
  32. numShows = foundShows;
  33. if (numPages > 0) {
  34. numShows = 60 * (numPages - 1) + foundShows;
  35. }
  36. $('#progress-wrapper div.container').prepend('<h1>'.concat(numShows).concat(' Shows</h1>'));
  37. $('#huckster-content-page').remove();
  38. }