video countdown wait

video countdown wait|play click

As of 31. 03. 2016. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        video countdown wait
// @namespace   manobastardo
// @include     *vodlocker.com*
// @include     *gorillavid*
// @include     http://bestreams.net*
// @include     *thevideo*
// @include     *streamin*
// @include     *vidbull*
// @include     *daclips*
// @version     1
// @grant       none
// @description video countdown wait|play click
// ==/UserScript==

current_url = window.location.href;

var click_event = document.createEvent('MouseEvents');
click_event.initEvent('click', true, true);

function get_player(player) {
    if (typeof(jwplayer) === typeof(Function)) {
        return jwplayer()
    }
    return $(player);
}

function elements() {
    var values = {
        "button": "",
        "player": "",
        "wanted": "",
        "current": ""
    };

    if (current_url.indexOf("gorillavid") > -1) {
        values.button = $('#btn_download');
        values.player = get_player("#flvplayer");
        values.wanted = "continue";
        values.current = values.button.attr("value");
    } else if (current_url.indexOf("daclips") > -1) {
        values.button = $('#btn_download');
        values.player = get_player("#flvplayer");
        values.wanted = "continue";
        values.current = values.button.attr("value");
    } else if (current_url.indexOf("bestreams") > -1) {
        values.button = $('#btn_download');
        values.player = get_player("#flvplayer");
        values.wanted = "hidden";
        values.current = $("#countdown_str").css("visibility");
    } else if (current_url.indexOf("vodlocker") > -1) {
        values.button = $('#btn_download');
        values.player = get_player("#flvplayer");
        values.wanted = "hidden";
        values.current = $("#countdown_str").css("visibility");
    } else if (current_url.indexOf("thevideo") > -1) {
        values.button = $('#btn_download');
        values.player = get_player("#flvplayer");
        values.wanted = "proceed";
        values.current = values.button.text();
    } else if (current_url.indexOf("streamin") > -1) {
        values.button = $('#btn_download');
        values.player = get_player("#flvplayer");
        values.wanted = "hidden";
        values.current = $("#countdown_str").css("visibility");
    } else if (current_url.indexOf("vidbull") > -1) {
        values.button = $('#btn_download');
        values.player = get_player("#flvplayer");
        values.wanted = "block";
        values.current = $('#download_linkb').css("display");
    }

    return values
}

function is_player(player) {
    console.log("is_player");
    return player.length > 0 || typeof player === "object";
}

function is_button(button) {
    console.log("is_button");
    return button.length > 0;
}

function wait_button() {
    console.log("wait_button");
    check_button = setInterval(function () {
        var e = elements();
        if (e.current.toLowerCase().indexOf(e.wanted) > -1) {
            clearInterval(check_button);
            e.button[0].dispatchEvent(click_event);
            wait_player(e.player);
        } else {
            console.log("wait_button");
        }
    }, 111);
}


function play_player(player) {
    console.log("play_player");
    player.play();
    player[0].play();
    jwplayer().play();
}

function wait_player(player) {
    console.log("wait_player");
    check_video = setInterval(function () {
        if (is_player(player)) {
            clearInterval(check_video);
            play_player(player);
        } else {
            console.log("wait_player");
        }
    }, 111);
}

function wait_check() {
    console.log("wait_check");
    var e = elements();
    if (is_button(e.button)) {
        wait_button();
    } else {
        wait_player(e.player);
    }
}

console.log("wait");
window.onload = wait_check;