Skip to content

Commit

Permalink
Don't try to calcaulate remaining number of shows if we're not on our…
Browse files Browse the repository at this point in the history
… profile
  • Loading branch information
vBm committed Jul 28, 2014
1 parent 5fa910b commit c40a787
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions remaining.episodes.followshows.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// @oujs:author vBm
// @supportURL https://github.com/vBm/snippets/issues
// @include http://followshows.com/user/*
// @version 2
// @date 22/07/2014
// @version 3
// @date 28/07/2014
// @grant none
// ==/UserScript==

Expand All @@ -23,20 +23,24 @@ $('#stats').append(
)
);

$.ajax({
url: "http://followshows.com/home/watchlist",
cache: false,
}).done(function(data) {
var totalEpisodesSum, totalEpisodes = [];
if ($(data).find('.stats').size() !== 0 ) {
$(data).find('.stats').each(function() {
totalEpisodes.push(parseInt($(this).text().match(/\d+/)[0], 10));
});
totalEpisodesSum = totalEpisodes.reduce(function(a, b) {
return a + b;
});
$('.addic7ed').text(totalEpisodesSum);
} else {
$('.addic7ed').text('N/A');
}
});
if (!$('a.btn-follow-user').attr('user')) {
$.ajax({
url: "http://followshows.com/home/watchlist",
cache: false,
}).done(function(data) {
var totalEpisodesSum, totalEpisodes = [];
if ($(data).find('.stats').size() !== 0 ) {
$(data).find('.stats').each(function() {
totalEpisodes.push(parseInt($(this).text().match(/\d+/)[0], 10));
});
totalEpisodesSum = totalEpisodes.reduce(function(a, b) {
return a + b;
});
$('.addic7ed').text(totalEpisodesSum);
} else {
$('.addic7ed').text('N/A');
}
});
} else {
$('.addic7ed').text('N/A');
}

0 comments on commit c40a787

Please sign in to comment.