May0 / CSGO Lounge Bot

// ==UserScript==
// @name         CSGO Lounge Bot
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Jake Mayeux
// @match        https://csgolounge.com/*
// @grant        GM_getValue
// @grant        GM_setValue
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js
// ==/UserScript==
/* jshint -W097 */
'use strict';

var text = GM_getValue('text', 'bump');
var time = GM_getValue('time', 10000);
var bumping = GM_getValue('bump', false);

$('div#offer').append('<a class="button" id="bumpButton">Start Bump</a>');
$('div#offer').append('<a class="button" id="bumpSettings"><img src="https://cdn0.iconfinder.com/data/icons/duesseldorf/32/settings.png" height=10px></a>');

$('#bumpButton').click(bumpClick);
$('#bumpSettings').click(settings);

if(bumping){
    $('#bumpButton').html('Stop Bump');
    setInterval(bump, time);
}else{
    $('#bumpButton').html('Start Bump');
}

function bumpClick(){
    bumping = !bumping;
    GM_setValue('bump', bumping);
    
    if(bumping){
        setInterval(bump, time);
        $('#bumpButton').html('Stop Bump');
    }else{
        setInterval(bump, 100000000000);
        $('#bumpButton').html('Start Bump');
    }
}

function settings(){
    var text = prompt('bump message', 'bump');
    var time = parseInt(prompt('delay in milliseconds', 10000));
    if(typeof(time) != 'number'){
        time = 10000;   
    }
    console.log(text, time);
    GM_setValue('text', text);
    GM_setValue('time', time);
}

function bump(){
    $('#notes').val(text);
    $('#offer a').first().click();
}