Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var stor = {};
- var comments = [];
- var $comments = $('.commentarea > .nestedlisting > .comment:not(.deleted) > .entry > .usertext > .usertext-body > .md');
- var matchRpt = 'MATCHES:';
- var competitors = 92;
- var matches = 0;
- var overflow;
- var overCount;
- // get data
- for(var i = 0; i < $comments.length; i++) {
- var $ele = $($comments[i]);
- var user = $ele.closest('.comment').find('.author').text();
- var comment = $ele.text().trim();
- stor[user] = {
- el: $ele,
- score: $ele.closest('.comment').find('.score.likes').text().match(/[0-9]+/).pop(),
- comment: comment
- };
- comments.push(user);
- }
- // generate matches report
- competitors = comments.slice(0, competitors);
- // currently the overflow is not reported on
- overflow = comments.length > competitors ? comments.slice(competitors, comments.length+1) : [];
- // do the matching from outside to middle
- while(competitors.length > 0) {
- var hi = competitors.shift();
- var lo = competitors.pop();
- matches++;
- matchRpt += '\n '+matches+': /u/'+hi+' ('+stor[hi].score+'pts) VS /u/'+lo+' ('+stor[lo].score+'pts)\n'+stor[hi].comment+'\nVS\n'+stor[lo].comment+'\n';
- }
- // report on the overflow users while ranking them
- overCount = 0;
- while(overflow.length > 0) {
- var u = overflow.shift();
- overCount++;
- }
- // spit the reports
- console.log('\n%c#'+matchRpt, 'background: transparent; color: blue; font-size: 10px; font-style:bold; font-family: monospace; display: block; width: 90%');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement