Skip to content

Instantly share code, notes, and snippets.

@jruz
Last active August 29, 2015 14:17
Show Gist options
  • Save jruz/0a53176b749e846356b1 to your computer and use it in GitHub Desktop.
Save jruz/0a53176b749e846356b1 to your computer and use it in GitHub Desktop.
Points calculator
javascript:void%20function(){var%20n,t=[];$(%22.tb-stream-as-block%22).each(function(n,e){var%20r=$(e).find(%22.js-task-list-title%22).text(),o=$(e).find('a[style=%22color:%20rgb(0,%200,%200);%20background-color:%20rgb(74,%20204,%20230);%22]'),a=_.reduce(o,function(n,t){return%20n+parseInt(t.text)},0);return%20t.push({name:r,points:a})}),t.pop(),t.push({name:t[0].name+%22%20+%20%22+t[1].name,points:t[0].points+t[1].points}),n=_.reduce(t,function(n,t){return%20n+t.name+%22:%20%22+t.points+%22\n%22},%22%22),alert(n)}();
var text, result = [];
$('.tb-stream-as-block').each(function(i, list){
var name = $(list).find('.js-task-list-title').text();
var tags = $(list).find('a[style="color: rgb(0, 0, 0); background-color: rgb(74, 204, 230);"]');
var points = _.reduce(tags, function(total, node){return total + parseInt(node.text)}, 0);
return result.push({name: name, points: points});
});
result.pop();
result.push({name: result[0].name + ' + ' + result[1].name, points: result[0].points + result[1].points});
text = _.reduce(result, function(text, count){return text + count.name + ': ' + count.points + '\n'}, '');
alert(text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment