4U6U57 / redrobins.propaganda

// ==UserScript==
// @name         redrobins.propaganda
// @namespace    http://reddit.com/r/RedRobins
// @version      04.05.2
// @description  Red Robin Propaganda Bot
// @author       /u/eighthmoon (credit to /u/keythkatz for original Robin Autovoter)
// @match        https://www.reddit.com/robin*
// @grant        none
// ==/UserScript==
/* jshint -W097 */

/* RED ROBINS
Please, take this script and modify it as you will, to spread the word of Marx
and the Red Robins Communist Party http://reddit.com/r/RedRobins.
However, if you do modify it, please keep this section of the code (between the
RED ROBINS) intact. Thank you, and welcome to the botnet Comrade.
 RED ROBINS*/

// ALL CUSTOMIZATION FEATURES BELOW
var VERSION = "04.05.2";
var TAG = "redrobins"; // You can filter messages in the developer console
var time = 0; // The time for Communist Revolution is now
var mainDelay = inSeconds(5); // Do not change or Marx will die
var msgDelay = inMinutes(4); // Amount of time between messages
// Feel free to change Minutes into Seconds (must be divisible by mainDelay) or Hours, and change the quantity

// Below is array of messages, feel free to modify/change the number of them (surrounded by quotes, separated by commas)
var messages = [
	"We must liberate the working class! Join the Party! http://reddit.com/r/RedRobins",
	"Distribute the karma fairly to the masses! Join the Party! http://reddit.com/r/RedRobins",
	"Form a dictatorship of the proletariat! Join the Party! http://reddit.com/r/RedRobins",
	"Seize the means of production! Join the Party! http://reddit.com/r/RedRobins",
	"Overthrow the bourgeois shitposting system! Join the Party! http://reddit.com/r/RedRobins",
	"Embrace the teachings of Marx! Join the Party! http://reddit.com/r/RedRobins",
	"Seize the means of reposting! Join the Party! http://reddit.com/r/RedRobins",
	"Take part in our 4 year plan to decrease shitposting! Join the Party! http://reddit.com/r/RedRobins",
	"Estabish the reddit Communist regime! Join the Party! http://reddit.com/r/RedRobins",
	"We accept comrades of all colors! Join the Party! http://reddit.com/r/RedRobins",
	"Join us as a Comrade! Join the Red Robins! http://reddit.com/r/RedRobins",
	"John Madden is a capitalist and must be impeached! Join the Party! http://reddit.com/r/RedRobins",
	"Distribute the banana facts to the working class! Join the Party! http://reddit.com/r/RedRobins",
	"Growth is capitalism. Staying is consenting to injustice. Overthrow the broken system! http://reddit.com/r/RedRobins"
];
var channels = ["-", "*", "$", ".", ">", ""];
var prefix = "/me";

function randomInt() {
    return Math.floor(Math.random() * 100);
}
function randomFrom(array) {
    return array[randomInt() % array.length];
}
function inSeconds(time){
	return time * 1000;
}
function inMinutes(time){
	return inSeconds(time) * 60;
}
function inHours(time){
	return inMinutes(time) * 60;
}
function currentSeconds(){
	return time / 1000;
}
function currentMinutes(){
	return currentSeconds() / 60;
}
function currentHours(){
	return currentMinutes() / 60;
}
function currentTime(){
    var seconds = time / 1000;
    var hours = parseInt( seconds / 3600 );
    seconds = seconds % 3600;
    var minutes = parseInt( seconds / 60 );
    seconds = seconds % 60;
    return hours + ":" + minutes + ":" + seconds;
}
function intervalOf(denominator){
	return time % denominator === 0;
}
function logger(msg){
	console.log(TAG + " (" + VERSION + ") : " + msg);
}

function sendMessage(message){
	logger("msg: " + message);
	$("#robinSendMessage > input[type='text']").val(message);
	$("#robinSendMessage > input[type='submit']").click();
}

function main(){

	if(intervalOf(inSeconds(30))) logger("time: " + currentTime());
	setTimeout(function(){
		//var participants = $(".robin-room-participant").length;
		//var partiText = "";
		//if (participants == 200) partiText = 200 + " " + $(".robin-user-list-overflow-indicator").text();
		//else partiText = participants;

		//var timeRemText = "] " + $("span:contains('Voting will end')").first().text();

		//sendMessage("/vote grow");
		//if(Math.random() < 0.2) sendMessage("[Robin Autovoter 1.10] Autovoted grow! https://www.reddit.com/r/joinrobin/comments/4cx02w/better_working_automatic_grow_script/");

		/*setTimeout(function(){
                if($("span:contains('" + timeRemText + "')")[0] == undefined){
                sendMessage("[Robin Autovoter 1.12] " + $("span:contains('Voting will end')").first().text() + " redd.it/4cx02w");
                }
                }, 10000);
                setTimeout(function(){
                window.location.reload();
                }, inMinutes(20));
                */

		if(intervalOf(msgDelay)) {
		    var message = randomFrom(messages);
		    if(channels.length > 0) message = randomFrom(channels) + " " + message;
		    if(prefix.length > 0) message = prefix + " " + message;
		    sendMessage(message);
		}
		
		// Continue
		time += mainDelay;
		main();
	}, mainDelay);
}
main();
setTimeout(function(){
    window.location.reload();
}, inHours(1));