Vulcun Loot Autoclicker + Streams scan

Autoscans streams for drops and enters the loot. Please set your browser to allow Vulcun popup when it asks you.

Verze ze dne 30. 11. 2015. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         Vulcun Loot Autoclicker + Streams scan
// @namespace    http://tampermonkey.net/
// @version      1.01
// @description  Autoscans streams for drops and enters the loot. Please set your browser to allow Vulcun popup when it asks you.
// @author       You
// @match        https://vulcun.com/user/lobby*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
/**
 * Hello dear Vulcunians,
 * The waiting is finally over. A very smart autolooter is here and ready to grow.
 * If this script helps you and you get rich please consider donating me for a coffee.
 * Helps with the coding sessions. (Paypal: [email protected])
 *
 * What you should do:
 * Open https://vulcun.com/user/lobby#page-live in a new tab
 * The script will scan for red drops
 * First time a 'red' drop is found, it will try to open it in a new tab
 * (YOU NEED TO CLICK ON ALLOW POPUPS FROM VULCUN IN YOUR BROWSER, only first time)
 *
 *
 * How it works:
 * 1. Scans the stream list every few minutes.
 * 2. If a 'red' drop is found opens it in a new tab
 * 3. It will click the Enter loot button
 * 4. It will close the loot tab after few minutes
 * 5. The initial tab will continue to scan for drops every minute,
 * and will also refresh the stream list every 10 minutes
 *
 * Good luck!
 *
 * PS: Use the Feedback forum if you have problems.
 */


'use strict';
var GREEN = '/img/lootdrop/long_pulse.gif';
var YELLOW = '/img/lootdrop/med_pulse.gif';
var RED = '/img/lootdrop/short_pulse.gif';

var STREAM_SCAN_STEP = 10000;

function setCookie(key, value) {
    var expires = new Date();
    //expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
    expires.setTime(expires.getTime() + (5 * 1000));
    console.debug('Set cookie(' + key + ',' + value + ')');
    document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}

function getCookie(key) {
    var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
    var result = keyValue ? keyValue[2] : null;
    console.debug('Get cookie(' + key + ')=' + result);
    return result;
}

function scan() {
    var streams = $('.vu-channel-tab');
    for (var i = 0; i < streams.length; i++) {
        var stream = streams[i];
        setTimeout(check, STREAM_SCAN_STEP * (i+1), stream);
    }

    setTimeout(refresh, 600000);
}

function check(stream) {
    $(stream).click();
    var idd = $(stream).attr('data-league');
    setTimeout(function(uniqueId) {

        var channelName = $("div[data-league='" + uniqueId + "'] .indexVideoPanelTitle").text();
        var eta = $("#lootdrop-eta").attr('src');
        var lootChestStyle = $("#lootdrop-eta").css('display');

        var color = 'none';
        if(eta == RED)    color = 'RED   ';
        if(eta == YELLOW) color = 'YELLOW';
        if(eta == GREEN)  color = 'GREEN ';
        if(lootChestStyle == 'none') {
            color = 'NONE  ';
        }
        console.info(uniqueId + " - " + color + " - " + channelName);
        if(eta == RED) {
            console.log("Red detected on " + channelName);
            setCookie('redId', uniqueId);
            var win = window.open('https://vulcun.com/user/lobby#page-live', '_blank');
            //win.focus();
        }
    }, STREAM_SCAN_STEP - 1000, idd);
}

function enterContest() {
    $('#enter-lootdrop').each(function() {

        var parentDiv = $(this).parent();

        console.log(parentDiv);
        var parentCss = parentDiv.css('display');
        console.log(parentCss);
        var closeTimeout = 120000;
        if(parentCss == 'block') {
            this.click();
            console.log("Button clicked");
            //console.log("Loot dialog is open... Will close it in "+closeTimeout / 1000 +" seconds");
            //setTimeout(closeModal, closeTimeout);

            //console.log('Stop enterLoot scanning.');
            // clearInterval(enterLoot);
        }

    });


}

function closeModal() {
    $('.close').each(function() {
        this.click();
        console.log("Modal closed");
    });
}

function refresh() {
    location.reload();
}

function closeTab() {
    window.top.close();
}

var enterLoot;

//$("div[data-league='1306']").click();

setTimeout(function() {
    var redId = getCookie('redId');
    if (redId == null) {
        console.log(new Date() + ' : Scanning streams......');
        scan();
        setInterval(scan, 180000);
    } else {
        var channelName = $("div[data-league='" + redId + "'] .indexVideoPanelTitle").text();
        console.log('Not scanning streams. Prepare for drop on ' + channelName);
        $("div[data-league='"+redId+"']").click();
        enterLoot = setInterval(enterContest, 10000);
        setTimeout(closeTab, 180000);
    }
}, 2000);