Skip to content

Instantly share code, notes, and snippets.

@b1nary
Last active April 1, 2016 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b1nary/6d40599556e3fd8e85be888dbf3089d8 to your computer and use it in GitHub Desktop.
Save b1nary/6d40599556e3fd8e85be888dbf3089d8 to your computer and use it in GitHub Desktop.
HAIL PAGGAUNT

HAIL PAGGAUNT

  • Grow automatically
  • Have some fancy stats
  • Chat history on reload
  • Autoscroll (that was broken for me, maybe you want to remove it see the comments)

Beware its very lazy and bad done, but it does its job.

screenshot

// ==UserScript==
// @name HAIL PAGGAUNT
// @description HAIL PAGGAUNT
// @include https://www.reddit.com/robin/
// @version 0.1
// ==/UserScript==
// Initialize
$(function(){
if(window.location.toString().indexOf('unicorn') == -1){
if(localStorage.chat){
$("#robinChatMessageList").prepend(localStorage.chat);
}
$("#robinDesktopNotifier").prepend('<br>');
$("#robinDesktopNotifier").prepend('<label id="unicorn_robin_user_count" style="padding:2px 4px; font-size:11px;">~</label>');
$("#robinDesktopNotifier").prepend('<label id="unicorn_round_info" style="padding:2px 4px; font-size:11px;">~</label>');
$("body").append('<iframe id="unicorn_iframe" style="width:1px; height:1px"></iframe>');
do_shit();
window.setInterval(function(){
do_shit();
},15000);
// Get the how long it still takes thingy info from a iframe
$("#unicorn_iframe").on('load', function(){
var round_end = $("#unicorn_iframe").contents().find('.robin-message:nth-child(2) .robin-message--message').text();
$("#unicorn_round_info").html(round_end);
});
// Save 100 last chat messages on F5/reload
$(window).bind('beforeunload', function() {
localStorage.chat = $("#robinChatMessageList").html();
});
// Scroll to bottom in chat. That did not work for, apparently it does for some.
window.setInterval(function(){
$('#robinChatWindow').scrollTop($('#robinChatWindow')[0].scrollHeight);
},500);
}
});
function do_shit(){
var online_users = $("#robinUserList .robin--username").length;
var voting_grow = $("#robinUserList .robin--vote-class--increase").length;
var voting_stay = $("#robinUserList .robin--vote-class--continue").length;
$("#unicorn_robin_user_count").html("There are <b>"+online_users+"</b> users here. <b>"+voting_grow+"</b>"+
" voting for grow.<br><b>"+voting_stay+"</b> are voting to stay. There is also you!");
$(".robin--vote-class--increase").click(); // Vote Grow!!
$("#unicorn_iframe").attr('src', 'https://www.reddit.com/robin/?unicorn');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment