Advertisement
hero0fwar

aaaaa

Feb 23rd, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. var stor = {};
  2. var comments = [];
  3. var $comments = $('.commentarea > .nestedlisting > .comment:not(.deleted) > .entry > .usertext > .usertext-body > .md');
  4. var matchRpt = 'MATCHES:';
  5.  
  6. var competitors = 92;
  7. var matches = 0;
  8. var overflow;
  9. var overCount;
  10.  
  11. // get data
  12. for(var i = 0; i < $comments.length; i++) {
  13. var $ele = $($comments[i]);
  14. var user = $ele.closest('.comment').find('.author').text();
  15. var comment = $ele.text().trim();
  16. stor[user] = {
  17. el: $ele,
  18. score: $ele.closest('.comment').find('.score.likes').text().match(/[0-9]+/).pop(),
  19. comment: comment
  20. };
  21. comments.push(user);
  22. }
  23.  
  24. // generate matches report
  25. competitors = comments.slice(0, competitors);
  26. // currently the overflow is not reported on
  27. overflow = comments.length > competitors ? comments.slice(competitors, comments.length+1) : [];
  28.  
  29. // do the matching from outside to middle
  30. while(competitors.length > 0) {
  31. var hi = competitors.shift();
  32. var lo = competitors.pop();
  33. matches++;
  34.  
  35. 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';
  36. }
  37.  
  38. // report on the overflow users while ranking them
  39. overCount = 0;
  40. while(overflow.length > 0) {
  41. var u = overflow.shift();
  42. overCount++;
  43. }
  44.  
  45. // spit the reports
  46. console.log('\n%c#'+matchRpt, 'background: transparent; color: blue; font-size: 10px; font-style:bold; font-family: monospace; display: block; width: 90%');
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement