// ==UserScript==
// @name Heroeswm - Comfort Roulette v2.0
// @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
// @downloadURL none
// ==/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 = '
';
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');
if (playerJson !== undefined && playerJson !== null) {
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 += '' +
'| ' + player.bet +
' | ' +
'' + player.name + '' +
' | ' +
'' + player.straight + ' | ' +
'' + player.result + ' | ' +
'
'
}
}
}
})
}
var additionalContainer = document.createElement ('div');
additionalContainer.innerHTML = '
'+
'' +
'' +
'| ' +
' Ваш список ' +
' | ' +
'
' +
'' +
'| Все ставки:' +
' | ' +
'
' +
'' +
'| Ставка | ' +
'Игрок | ' +
'Поле | ' +
'Выигрыш | ' +
'
' +
infoText +
'' +
'| ' +
' | Всего' +
' | ' +
'' +
'' +
'' +
' | ' +
'' + totalWinSum.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' | ' +
' ' +
' ' +
' | ' +
'
' +
'
' +
'
';
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 = new Array();
if (playerJson !== undefined && playerJson !== null) {
playerArray = JSON.parse(playerJson);
playerArray.forEach(function(entry) {
if (entry == username){
userExistInDb = true;
return
}
})
}
if (userExistInDb) {
buttonParent.innerHTML = '';
} else {
buttonParent.innerHTML = '';
}
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));
}
})();
}