malygos / Maly Crypts

// ==UserScript==
// @name Maly Crypts
// @include https://www.kraken.com/u/trade*
// @include https://www.kraken.com/
// @include https://www.trade.kraken.com*
// @include kraken
// @grant none
// ==/UserScript==

function login () { $('.btn.btn-primary.signup').click();}
if (window.location.href =="https://www.kraken.com/")
{
setInterval(function(){login();}, 10000);

}
function leverage1 () { $('#order-placement > form > div > div:nth-child(3) > div.opf-cell-input > div > div:nth-child(1)[class="button-group__button"]').click();}

if (window.location.href.indexOf("trade.kraken.com") !== -1)
{
console.log("Activate anti leverage")
setInterval(function(){leverage1();}, 1000);

}
function trade_display(){
//update trad val
$totaleurval = Number($('#DataTables_Table_2 tfoot th[name=total]').text().replace('€', '').replace(',',''));

   $rows = $('#DataTables_Table_2 tr');
      for (var i=1; i<$rows.length; i++){
        $nbCoins = Number( $rows.eq(i).find('td.ralign').eq(0).attr('sort'));
         $eurChangeRate = Number($rows.eq(i).find('td.ralign').eq(1).attr('sort'));
         if ($nbCoins ===undefined || $nbCoins ===0){
             $nbCoins = 0;}
           if ($eurChangeRate ===undefined || $eurChangeRate ===0){
             $eurChangeRate = 1;}

          $eurCoinsVal = ($nbCoins*$eurChangeRate).toFixed(2)
          if($eurCoinsVal ===undefined)
             $eurCoinsVal = ''
        if(  $rows.eq(i).find('td.balance_column_eur').length === 0){
            $rows.eq(i).append('<td class="ralign balance_column_eur">'+$eurCoinsVal+'€</td>')
        }
        else{
           $rows.eq(i).find('td.balance_column_eur').eq(0).innerHTML =$eurCoinsVal+'€'
            }

        if(  $rows.eq(i).find('td.percent_column_eur').length === 0){
            $rows.eq(i).append('<td class="ralign percent_column_eur">'+(($eurCoinsVal/$totaleurval) * 100).toFixed(2)+'%</td>')
        }
        else{
           $rows.eq(i).find('td.percent_column_eur').eq(0).innerHTML =(($eurCoinsVal/$totaleurval) * 100).toFixed(2)+'%'
            }
      }
}
if (window.location.href =="https://www.kraken.com/u/trade")
{
setInterval(function(){trade_display();}, 300);
}