Greasy Fork

Greasy Fork is available in English.

Heroeswm - Comfort Roulette

Крутой балдеж для рулетки

当前为 2020-06-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Heroeswm - Comfort Roulette
// @author       JUSTteen15
// @namespace    JUSTteen15
// @version      2.0
// @description  Крутой балдеж для рулетки

// @include     /^https{0,1}:\/\/((www|qrator)\.heroeswm\.ru|178\.248\.235\.15)\/(inforoul|pl_info)\.php.*/

// @icon         https://dcdn.heroeswm.ru/avatars/2210/nc-55/2210892.jpg
// @encoding 	 utf-8

// @grant        GM.setValue
// @grant        GM.getValue

// ==/UserScript==

if (/inforoul/.test(location.href)){
    var url = document.URL;
    var rouletteId = parseInt(url.substring(url.lastIndexOf('=') + 1));

    var parent = document.createElement ('div');
    var locationUrl = 'http://'+location.hostname+'/inforoul.php?id=';

    parent.innerHTML = '<br/><div style="display: flex;justify-content: center;"><button id="back" type="button"><<</button>&ensp;<button id="reload" type="button">Обновить</button>&ensp;<button id="next" type="button">>></button></div>';
    document.getElementsByTagName("td")[0].appendChild(parent);

    let roulleteRows = document.querySelectorAll("body > center > table:nth-child(2) > tbody > tr > td > table > tbody tr");

    var infoText = '';
    var totalWinSum = parseInt(0);

    (async () => {
        let playerJson = await GM.getValue('players');

        let playerArray = JSON.parse(playerJson);

        playerArray.forEach(function(entry) {
            for (let i = 0; i < roulleteRows.length; i++) {
                let player = {};

                player.url = document.querySelector('body > center > table:nth-child(2) > tbody > tr > td > table > tbody > tr:nth-child(' + i + ') > td:nth-child(2) > a');

                if (player.url !== undefined && player.url !== null) {
                    player.name = player.url.text;

                    if (entry == player.name) {
                        var betValue = document.querySelector('body > center > table:nth-child(2) > tbody > tr > td > table > tbody > tr:nth-child(' + i + ') > td:nth-child(1) > b');
                        if (betValue !== undefined && betValue !== null){
                            player.bet = betValue.innerText.replace(/<([^ >]+)[^>]*>.*?<\/\1>|<[^\/]+\/>/ig, "");
                        }

                        var straight = document.querySelector('body > center > table:nth-child(2) > tbody > tr > td > table > tbody > tr:nth-child(' + i + ') > td:nth-child(3)');
                        if (straight !== undefined && straight !== null){
                            player.straight = straight.textContent;
                        }

                        var resultValue = document.querySelector('body > center > table:nth-child(2) > tbody > tr > td > table > tbody > tr:nth-child(' + i + ') > td:nth-child(4)')
                        if (resultValue !== undefined && resultValue !== null){
                            player.result = resultValue.innerText.replace(/<([^ >]+)[^>]*>.*?<\/\1>|<[^\/]+\/>/ig, "");
                        }

                        totalWinSum = parseInt(player.result.replace(',','')) + parseInt(totalWinSum);

                        infoText += '<tr>' +
                            '<td class="wbwhite" align="right">' + player.bet +
                            '</td>' +

                            '<td class="wbwhite"><a style="text-decoration:none;" href="' + player.url.href +'">' + player.name + '</a>' +
                            '</td>' +

                            '<td class="wbwhite">' + player.straight + '</td>' +

                            '<td class="wbwhite">' + player.result + '</td>' +
                            '</tr>'
                    }
                }
            }
        })

        var additionalContainer = document.createElement ('div');
        additionalContainer.innerHTML = '<br/>'+
            '<table align="center" cellpadding="4" class="wbwhite" style="min-width:600px;">' +
            '<tr>' +
            '<td class="wbwhite" colspan="4">' +
            '<div align="center"><b>Ваш список</b></div><br>' +
            '</td>' +
            '</tr>' +

            '<tr>' +
            '<td class="wbwhite" colspan="4"><center>Все ставки:</center>' +
            '</td>' +
            '</tr>' +

            '<tr>' +
            '<td class="wblight" width="120" align="right"><b>Ставка</b></td>' +
            '<td class="wblight" width="150" align="center"><b>Игрок</b></td>' +
            '<td class="wblight" width="150" align="center"><b>Поле</b></td>' +
            '<td class="wblight" width="120"><b>Выигрыш</b></td>' +
            '</tr>' +

            infoText +

            '<tr>' +
            '<td class="wb2" align="right">' +
            '<td class="wb2" align="center" colspan="2"><b>Всего</b>' +
            '</td>' +

            '<td class="wb2">' +
            '<table border="0" cellspacing="0" cellpadding="0">' +
            '<tr>' +
            '<td><img width="24" height="24" src="https://dcdn2.heroeswm.ru/i/r/gold.png?v=3.23de65" border="0" title="Золото" alt="" class="rs"></td>' +
            '<td>' + totalWinSum.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</td>' +
            '</tr>' +
            '</table>' +
            '</td>' +
            '</tr>' +

            '</table>' +
            '<br/>';
        document.getElementsByTagName("td")[0].appendChild(additionalContainer);
    })();

    document.getElementById('reload').onclick = function() {
        location.reload();
    }

    document.getElementById('back').onclick = function() {
        window.location = locationUrl + (rouletteId - 1);
    }

    document.getElementById('next').onclick = function() {
        window.location = locationUrl + (rouletteId + 1);
    }
}
else {
    var personalInfoView = document.querySelector('body > center > table:nth-child(2) > tbody > tr > td > table:nth-child(1) > tbody > tr:nth-child(1) > td:nth-child(1) > table > tbody > tr > td:nth-child(2) > table > tbody > tr');
    var usernameLabel = document.querySelector('body > center > table:nth-child(2) > tbody > tr > td > table:nth-child(1) > tbody > tr:nth-child(1) > td:nth-child(1) > table > tbody > tr > td:nth-child(1) > b');

    var username = usernameLabel.textContent.replace(/ *\[[^\]]*]/, '').trim();

    var buttonParent = document.createElement ('td');

    var userExistInDb = false;

    (async () => {
        let playerJson = await GM.getValue('players');

        var playerArray = JSON.parse(playerJson);

        playerArray.forEach(function(entry) {
            if (entry == username){
                userExistInDb = true;
                return
            }
        })

        if (userExistInDb) {
            buttonParent.innerHTML = '<div id="roulleteAction" style="cursor: pointer;width: 33px;"><div id="buttonText">(R-)</div></div>';
        } else {
            buttonParent.innerHTML = '<div id="roulleteAction" style="cursor: pointer;width: 33px;"><div id="buttonText">(R+)</div></div>';
        }

        personalInfoView.insertBefore(buttonParent, personalInfoView.firstChild);

        document.getElementById('roulleteAction').onclick = function() {
            if (userExistInDb) {
                playerArray = playerArray.filter(e => e !== username);

                document.getElementById('roulleteAction').textContent = "(R+)";

                userExistInDb = false;
            } else {
                playerArray.push(username);

                playerArray = Array.from(new Set(playerArray));

                document.getElementById('roulleteAction').textContent = "(R-)";

                userExistInDb = true;
            }

            GM.setValue("players", JSON.stringify(playerArray));
        }
    })();
}