A
A
aDope2018-03-01 14:23:58
JavaScript
aDope, 2018-03-01 14:23:58

How to teach to read values ​​from a block by id?

I have minimal knowledge of JS, I'm trying to write an auto-withdrawal function, if there is a def. balance on the site.
The balance sheet looks like this:

<li class="balanceli"><span id="balance">0.00525239</span> BTC</li>

That is, if the balance is greater than or equal to the specified value, then the action occurs. But nothing works for me :(
if (AUTO_WITHDRAW == "ON") //Авто-вывод средств
        {
          if (!window.content.document.getElementById("balance"))
          {
            log('Выводим биткоин...');
            limDisplay("Выводим биткоин...")
            
            iret = limPlay("CODE:"+"SET !ERRORIGNORE YES"+n+"SET !TIMEOUT_PAGE 60"+n+"SET !TIMEOUT_STEP 10"+n+"TAB CLOSEALLOTHERS"+n+"TAB T=1"+n+"URL GOTO=https://freebitco.in"+n+"WAIT SECONDS=10"+n)
            
            var accountBTC = Number(window.content.document.getElementById("balance")[0].innerHTML.replace(',',''));
            if (accountBTC < 0.00002)
            {
              //NO OPERATION
            }
            else if ((accountBTC >= 0.00002))
            {
              iret = limPlay("CODE:"+"SET !ERRORIGNORE YES"+n+"SET !TIMEOUT_STEP 10"+n+"TAG POS=1 TYPE=BUTTON ATTR=TXT:WITHDRAW+n+WAIT SECONDS=3"+n+"TAG POS=2"+n);	
            }
          }
        }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
VoidVolker, 2018-03-01
@aDope

For mathematical operations on currencies, either special libraries or integers are used, not floating point numbers.

> 31.01+1
< 32.010000000000005
> 31.02+1
< 32.019999999999996
> 9007199254740993
< 9007199254740992

Do you get many decimal places when adding in JavaScript?
How to store and work with money in code and database?

V
Vladimir Skibin, 2018-03-01
@megafax

Oh oh oh. This is not the front should do, but the back. Otherwise you can get XSS.
And about the correctness - check what your limPlay is doing and run it through console.log - what do you have in the variables there.

S
string15, 2018-03-01
@string15

window.content.document.getElementById("balance")what is this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question