tabtouch.mobi

Automatically updates race info every 15 seconds and moves to the next race once the current one has ended.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        tabtouch.mobi
// @namespace   tabtouch.mobi.override
// @include     https://*tabtouch.mobi/*
// @version     2
// @grant       none
// @description Automatically updates race info every 15 seconds and moves to the next race once the current one has ended.
// ==/UserScript==

function checkHash()
{
	var patt = /#tote\/meetings\/[^\/]*\/[0-9]*/i;
	return patt.test(location.hash);
}

function checkOpen()
{
	var details = $("#race-details");
	return details.length == 1 && !details.hasClass('closed');
}

var previousHash;
var previousOpen = false;

function hashChanged()
{
	if (previousHash != location.hash)
	{
		previousHash = location.hash;
		return true;
	}
	return false;
}

function clickLink(link)
{
    var cancelled = false;

    if (document.createEvent)
		{
        var event = document.createEvent("MouseEvents");
        event.initMouseEvent("click", true, true, window,
            0, 0, 0, 0, 0,
            false, false, false, false,
            0, null);
        cancelled = !link.dispatchEvent(event);
    }
    else if (link.fireEvent)
		{
        cancelled = !link.fireEvent("onclick");
    }

    if (!cancelled)
		{
        window.location = link.href;
    }
}

function autoRefreshInterval()
{
	if (!checkHash()) { return; }

	var newPage = hashChanged();
	var open = checkOpen();
	
	console.log("newPage: " + newPage + " - open: " + open + " - previousOpen: " + previousOpen);
	
	if (open)
	{
		var button = $(".refresh-button");
		if (button.length < 1) { return; }
		clickLink(button[0]);
		//button.click();
	}
	else if (!newPage && previousOpen)
	{
		console.log("Next Page");
		var button = $(".next-race-button");
		if (button.length < 1) { return; }
		clickLink(button[0]);
		//button.click();
	}
	
	previousOpen = open;
}

function autoRefreshInstall(interval)
{
	console.log("Installing Race Refresher (" + (interval / 1000.0) + "sec)");
	
	if (window.intervalVar)
	{
		clearInterval(window.intervalVar);
		window.intervalVar = undefined;
	}
	
	window.intervalVar = setInterval(autoRefreshInterval, interval);
}

autoRefreshInstall(15000);



$('head').append(
	
	"<style id='style_hideScratched'>" +
		"#betting-form #startersfield > li.scratched { display: none !important; }" +
	"</style>" +
	
	"<style id='style_hideSorting'>" +
		".sort-group { display: none !important; }" +
	"</style>"
	
);



function showScratched(bool)
{
	$('#style_hideScratched').prop('disabled', bool);
}

function showSorting(bool)
{
	$('#style_hideSorting').prop('disabled', bool);
}


showScratched(true);
showSorting(true);