Skip to content

Commit

Permalink
Switch to reduce() instead of eval.
Browse files Browse the repository at this point in the history
 - use parseInt to convert strings to numbers
 - add missing semicolon
 - bump version
  • Loading branch information
vBm committed Jul 22, 2014
1 parent a221981 commit efbcabb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions remaining.episodes.followshows.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// @author vBm <[email protected]>
// @oujs:author vBm
// @include http://followshows.com/user/*
// @version 1
// @date 20/07/2014
// @version 2
// @date 22/07/2014
// @grant none
// ==/UserScript==

Expand All @@ -28,8 +28,10 @@ $.ajax({
}).done(function(data) {
var totalEpisodes = [];
$(data).find('.stats').each(function() {
totalEpisodes.push($(this).text().match(/\d+/)[0])
totalEpisodes.push(parseInt($(this).text().match(/\d+/)[0], 10));
});
var totalEpisodesSum = totalEpisodes.reduce(function(a, b) {
return a + b;
});
var totalEpisodesSum = eval(totalEpisodes.join('+'));
$('.addic7ed').text(totalEpisodesSum);
});

0 comments on commit efbcabb

Please sign in to comment.