[0]Balance-Wingman Send shares on win to Vaulet

Every time you win a bet the script sends your desired % to the Vaulet

Versione datata 12/08/2020. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         [0]Balance-Wingman Send shares on win to Vaulet
// @description  Every time you win a bet the script sends your desired % to the Vaulet
// @description  Create your acc here to support my work https://stake.com/?c=263733c1bc
// @version      1.6
// @author       Dauersendung
// @namespace    https://greasyfork.org/de/users/444902-dauersendung
// @match        https://stake.com/*
// @run-at document-start
// ==/UserScript==



var accessToken = localStorage.getItem('session').replace(/"/g, '');
var oldBal = localStorage.getItem("oldBal");
if (!oldBal) oldBal = 0;
else oldBal = parseFloat(oldBal);


function getCurrency() {
    return JSON.parse(localStorage.getItem("v2_currency")).currency;
}

function getRate(cur) {
    return JSON.parse(localStorage.getItem('v2_currency')).conversions.rates[cur];
}

function convertCurrency(cur, val) {
    return val * getRate(cur);
}

function getConversionElem() {
    var ele = document.querySelector("#conversionElem");
    if(ele == null) {
        ele = document.createElement("span");
        ele.id = "conversionElem";
        ele.innerText = "$0.000";
        document.querySelector(".styles__Wrap-rlm06o-0.bGSyHm").insertBefore(ele, null);
    }

    return ele;
}

function depositBal(depositAmount) {
    var curr = getCurrency();

    var data = [
        {
            operationName: "CreateVaultDeposit",
            query: "mutation CreateVaultDeposit($amount: Float!, $currency: CurrencyEnum!) { createVaultDeposit(amount: $amount, currency: $currency) { id amount currency user { id balances { available { amount currency __typename } vault { amount currency __typename } __typename } __typename } __typename } } ",
            variables: {
                amount: depositAmount,
                currency: curr,
            }
        }
    ]
    return fetch("https://api.stake.com/graphql", {
        "credentials": "omit",
        "headers": {
            "content-type": "application/json",
            'x-access-token': accessToken,
            'x-lockdown-token': undefined
        },
        "referrer": "https://stake.com/?currency=" + curr + "&modal=vault&operation=deposit",
        "body": JSON.stringify(data),
        "method": "POST",
        "mode": "cors"
    });
}

function checkBalance() {
    var curBalEle = document.querySelector(".styles__Cashier-puey40-2.dMSTdD .styles__Content-rlm06o-1.ixoRjG");
    if (!curBalEle) return false;

    var curBal = curBalEle.innerText;
    if (!curBal) return false;

    if (curBal > oldBal) {
        var depositAmount = ((curBal - oldBal) * 20) / 100;
        depositBal(depositAmount).then(() => {
            oldBal = curBalEle.innerText
            localStorage.setItem("oldBal", oldBal);
        });
    }

    getConversionElem().innerText = "$" + convertCurrency(getCurrency(), curBal).toFixed(3);
}

window.setInterval(checkBalance, 3300);