WSOP

GreaseMonkey / TamperMonkey script that show percentable status of actual bracelet level.

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==
// @id           wsop-script@pida42
// @name         WSOP
// @description  GreaseMonkey / TamperMonkey script that show percentable status of actual bracelet level.
// @namespace    https://github.com/pida42/wsop-script
// @version      1.0.0
// @author       You
// @include      http://*
// @include      https://*
// @match        http://*
// @match        https://*
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// @grant        GM_addStyle
// ==/UserScript==

(function (jQuery) {

    if (false === document.location.host.match(/playwsop\.com/g)) return;

    var intervals      = {};
    var removeListener = function (selector) {
        if (intervals[selector]) {
            window.clearInterval(intervals[selector]);
            intervals[selector] = null;
        }
    };
    var found          = 'waitUntilExists.found';

    jQuery.fn.waitUntilExists = function (handler, shouldRunHandlerOnce, isChild) {
        var selector  = this.selector;
        var $this     = jQuery(selector);
        var $elements = $this.not(
            function () {
                return jQuery(this).data(found);
            }
        );
        if (handler === 'remove') {
            removeListener(selector);
        } else {
            $elements.each(handler).data(found, true);
            if (shouldRunHandlerOnce && $this.length) {
                removeListener(selector);
            } else if (!isChild) {
                intervals[selector] = window.setInterval(
                    function () {
                        $this.waitUntilExists(handler, shouldRunHandlerOnce, true);
                    }, 500
                );
            }
        }
        return $this;
    };

    jQuery('.bpMeterValueMask').waitUntilExists(
        function () {
            var _interval = null;
            clearInterval(_interval);
            _interval = window.setInterval(
                function () {
                    if (jQuery('.bpMeterValueMask').length !== 0) {
                        var meterValueMask = parseInt(jQuery('.bpMeterValueMask').css('width'));
                        var meterContainer = parseInt(jQuery('.bpBarMeterContainer').css('width'));
                        var bpValuePercent = ((meterValueMask / meterContainer) * 100);
                        jQuery('.bpBarNextChip').text(parseFloat(bpValuePercent).toFixed(2) + '%').css({lineHeight: 5, fontSize: '20px'});
                    }
                }, 5000
            );
        }
    );

})(jQuery);