Robin Enhancement Suite

Trying to make Robin more awesome (revised by teknogeek)

  1. // ==UserScript==
  2. // @name Robin Enhancement Suite
  3. // @namespace http://github.com/teknogeek
  4. // @version 0.6.1
  5. // @description Trying to make Robin more awesome (revised by teknogeek)
  6. // @author teknogeek
  7. // @credits sprngr
  8. // @match https://www.reddit.com/robin*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var notifications = $('.robin-chat--sidebar-widget.robin-chat--notification-widget');
  16. var vote = $('.robin-chat--sidebar-widget.robin-chat--vote-widget');
  17. var resWidget = [
  18. '<h2 style="display:inline-block;"><span class="count"></span> Participants</h2>',
  19. '<p style="display:inline-block; padding-left:5px;"><small>(<span class="active"></span> Active / <span class="away"></span> Away)</small></p>',
  20. '<h3 style="margin: 5px 0px;"><span class="abandon-count"></span> Abandon | ',
  21. '<span class="stay-count"></span> Stay | ',
  22. '<span class="grow-count"></span> Grow | ',
  23. '<span class="novote-count"></span> No Vote</h3>'
  24. ].join("");
  25.  
  26. notifications.prepend(resWidget);
  27.  
  28. $('.robin--username :not(a)').each(function(index) {
  29. var username = $(this).text();
  30. if (username != '[robin]') {
  31. $(this).html('<a href="//reddit.com/u/' + username + '">' + username + '</a>');
  32. }
  33. });
  34. var reapTime = parseInt(document.head.innerHTML.match(/"robin_room_reap_time": "([^"]+)"/)[1]);
  35. vote.prepend('<h2 style="display:inline-block;"><span id="timeLeftMinutes"></span>min <span id="timeLeftSeconds"></span>sec remaining</h2>');
  36.  
  37. update();
  38.  
  39. function update() {
  40. // Total, Active/Away
  41. var reapSeconds = (reapTime - Date.now()) / 6e4,
  42. minutes = reapSeconds | 0,
  43. seconds = ((reapSeconds - minutes) * 60) | 0;
  44. $("#timeLeftMinutes").text(minutes);
  45. $("#timeLeftSeconds").text(seconds);
  46.  
  47. var participantTotal = $('.robin-room-participant').length;
  48. var participantActive = $('.robin-room-participant.robin--presence-class--present').length;
  49. var participantAway = $('.robin-room-participant.robin--presence-class--away').length;
  50.  
  51. var abandonCount = $('.robin-room-participant.robin--vote-class--abandon').length;
  52. var growCount = $('.robin-room-participant.robin--vote-class--increase').length;
  53. var stayCount = $('.robin-room-participant.robin--vote-class--continue').length;
  54. var noVoteCount = $('.robin-room-participant.robin--vote-class--novote').length;
  55.  
  56. $('.robin-chat--notification-widget h2 .count').text(participantTotal);
  57. $('.robin-chat--notification-widget small .active').text(participantActive);
  58. $('.robin-chat--notification-widget small .away').text(participantAway);
  59.  
  60. $('.robin-chat--notification-widget h3 .abandon-count').text(abandonCount);
  61. $('.robin-chat--notification-widget h3 .stay-count').text(stayCount);
  62. $('.robin-chat--notification-widget h3 .grow-count').text(growCount);
  63. $('.robin-chat--notification-widget h3 .novote-count').text(noVoteCount);
  64.  
  65. $('.robin--username').each(function(index) {
  66. var username = $(this).text();
  67. if (username != '[robin]') {
  68. $(this).html('<a style="color:inherit;" target="_blank" href="//reddit.com/u/' + username + '">' + username + '</a>');
  69. }
  70. });
  71.  
  72. setTimeout(update, 500);
  73. }
  74. })();