Jump to content

Wallet Balances in USD, TamperMonkey Script


BlackDragon

Recommended Posts

// ==UserScript==
// @name         Wallet Balance
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Devilla
// @match        https://bc.game/home
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

function getWallet(){
  fetch("https://bc.game/api/user/amount/?source=", {
      "credentials": "include",
      "headers": {
          "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0",
          "Accept": "application/json, text/plain, */*",
          "Accept-Language": "en-US,en;q=0.5",
          "Cache-Control": "max-age=0",
          "Cookie": `${document.cookie}`
      },
      "referrer": "https://bc.game",
      "method": "GET",
      "mode": "cors"
  }).then(response => response.json())
  .then((data) => {
    let total = 0, i = 0;
    const res = data.data;
    res.map((coin)=>{
      fetch(`https://api.cryptonator.com/api/ticker/${coin.currencyName.toLowerCase()}-usd`)
      .then(response => response.json())
      .then((data) => {
        total = data.ticker.price * coin.amount;
          console.log(total, coin.currencyName);
          var header = document.getElementById('header');
          var coinIcon = header.getElementsByClassName('coin-icon')[i];
          coinIcon.src=`https://bc.game/coin/${coin.currencyName}.black.png`;
          var coinAmount = header.getElementsByClassName('coin-amount')[i];
          coinAmount.innerHTML = total;
          var coinName = header.getElementsByClassName('coin-name')[i];
          coinName.innerHTML = 'USD';
        i++;

      })
      .catch(err=>{})
    })
  })
  .catch(err => console.log(err))
}

getWallet();

})();

 

Link to comment
Share on other sites

5 hours ago, BlackDragon said:

// ==UserScript==
// @name         Wallet Balance
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Devilla
// @match        https://bc.game/home
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

function getWallet(){
  fetch("https://bc.game/api/user/amount/?source=", {
      "credentials": "include",
      "headers": {
          "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0",
          "Accept": "application/json, text/plain, */*",
          "Accept-Language": "en-US,en;q=0.5",
          "Cache-Control": "max-age=0",
          "Cookie": `${document.cookie}`
      },
      "referrer": "https://bc.game",
      "method": "GET",
      "mode": "cors"
  }).then(response => response.json())
  .then((data) => {
    let total = 0, i = 0;
    const res = data.data;
    res.map((coin)=>{
      fetch(`https://api.cryptonator.com/api/ticker/${coin.currencyName.toLowerCase()}-usd`)
      .then(response => response.json())
      .then((data) => {
        total = data.ticker.price * coin.amount;
          console.log(total, coin.currencyName);
          var header = document.getElementById('header');
          var coinIcon = header.getElementsByClassName('coin-icon')[i];
          coinIcon.src=`https://bc.game/coin/${coin.currencyName}.black.png`;
          var coinAmount = header.getElementsByClassName('coin-amount')[i];
          coinAmount.innerHTML = total;
          var coinName = header.getElementsByClassName('coin-name')[i];
          coinName.innerHTML = 'USD';
        i++;

      })
      .catch(err=>{})
    })
  })
  .catch(err => console.log(err))
}

getWallet();

})();

 

I like it but there is no need for an outside API. Take a look at 

 

document.querySelector("#header > div.header-pc > div.right > div.user-balance > button > svg").__vue__.$store.state.system.currency



It has all the coins USD values. 

Intelligenci_logo_on_transparent.thumb.png.a0b4eeba91c8fb82b7749ebf5bcb9246.png

Link to comment
Share on other sites

oOo and also  the fetch to get the wallet balance can also be done via 

 

document.querySelector("#header > div.header-pc > div.right > div.user-balance > button > svg").__vue__.$store.state.account.currencys

 

The querySelector is selecting the wallet button next to your balance, so it should always be there whenever you are on bcGame's website. Just food for thought 

Intelligenci_logo_on_transparent.thumb.png.a0b4eeba91c8fb82b7749ebf5bcb9246.png

Link to comment
Share on other sites

9 hours ago, ][NT3L][G3NC][ said:

oOo and also  the fetch to get the wallet balance can also be done via 

 


document.querySelector("#header > div.header-pc > div.right > div.user-balance > button > svg").__vue__.$store.state.account.currencys

 

The querySelector is selecting the wallet button next to your balance, so it should always be there whenever you are on bcGame's website. Just food for thought 

Sure, will use this. Thanks man.

Link to comment
Share on other sites

20 hours ago, BlackDragon said:

// ==UserScript==
// @name         Wallet Balance
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Devilla
// @match        https://bc.game/home
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

function getWallet(){
  fetch("https://bc.game/api/user/amount/?source=", {
      "credentials": "include",
      "headers": {
          "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0",
          "Accept": "application/json, text/plain, */*",
          "Accept-Language": "en-US,en;q=0.5",
          "Cache-Control": "max-age=0",
          "Cookie": `${document.cookie}`
      },
      "referrer": "https://bc.game",
      "method": "GET",
      "mode": "cors"
  }).then(response => response.json())
  .then((data) => {
    let total = 0, i = 0;
    const res = data.data;
    res.map((coin)=>{
      fetch(`https://api.cryptonator.com/api/ticker/${coin.currencyName.toLowerCase()}-usd`)
      .then(response => response.json())
      .then((data) => {
        total = data.ticker.price * coin.amount;
          console.log(total, coin.currencyName);
          var header = document.getElementById('header');
          var coinIcon = header.getElementsByClassName('coin-icon')[i];
          coinIcon.src=`https://bc.game/coin/${coin.currencyName}.black.png`;
          var coinAmount = header.getElementsByClassName('coin-amount')[i];
          coinAmount.innerHTML = total;
          var coinName = header.getElementsByClassName('coin-name')[i];
          coinName.innerHTML = 'USD';
        i++;

      })
      .catch(err=>{})
    })
  })
  .catch(err => console.log(err))
}

getWallet();

})();

 

Script for??

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

There are a few production bugs in the wallet :

1. USD Balance doesn't update after each bet (without refreshing the page manually).

2. Scrollbar doesn't work for Firefox browser to scroll different coins (FIX : ```overflow-y : scroll``` should be added).

 

scroll.gif

usdbalance.gif

Link to comment
Share on other sites

  • 2 months later...

Use this in console :

var currencies = document.querySelector("#header > div.header-pc > div.right > div.user-balance > button > svg").__vue__.$store.state.account.currencys;


var symbol= document.querySelector("#header > div.header-pc > div.right > div.user-balance > button > svg").__vue__.$store.state.system.currency;

currencies.map((coin)=>{
 console.log(
   coin.currencyName,
   coin.amount*symbol[`${coin.currencyName}`].usdPrice + ' USD'
 )
})

 

Link to comment
Share on other sites

On 9/24/2020 at 4:15 PM, BlackDragon said:

// ==UserScript==
// @name         Wallet Balance
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Devilla
// @match        https://bc.game/home
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

function getWallet(){
  fetch("https://bc.game/api/user/amount/?source=", {
      "credentials": "include",
      "headers": {
          "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0",
          "Accept": "application/json, text/plain, */*",
          "Accept-Language": "en-US,en;q=0.5",
          "Cache-Control": "max-age=0",
          "Cookie": `${document.cookie}`
      },
      "referrer": "https://bc.game",
      "method": "GET",
      "mode": "cors"
  }).then(response => response.json())
  .then((data) => {
    let total = 0, i = 0;
    const res = data.data;
    res.map((coin)=>{
      fetch(`https://api.cryptonator.com/api/ticker/${coin.currencyName.toLowerCase()}-usd`)
      .then(response => response.json())
      .then((data) => {
        total = data.ticker.price * coin.amount;
          console.log(total, coin.currencyName);
          var header = document.getElementById('header');
          var coinIcon = header.getElementsByClassName('coin-icon')[i];
          coinIcon.src=`https://bc.game/coin/${coin.currencyName}.black.png`;
          var coinAmount = header.getElementsByClassName('coin-amount')[i];
          coinAmount.innerHTML = total;
          var coinName = header.getElementsByClassName('coin-name')[i];
          coinName.innerHTML = 'USD';
        i++;

      })
      .catch(err=>{})
    })
  })
  .catch(err => console.log(err))
}

getWallet();

})();

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...