D
D
Denis Black2017-08-13 01:38:04
JavaScript
Denis Black, 2017-08-13 01:38:04

How to write a condition: if more than a certain number -> click() in JS?

Hello everyone, please tell me how to get the numerical value 6.31 from the page:

<div class="scale scale--sm js-profile-score" data-score="6.31" data-delimiter="," data-digits-count="2" data-line-width="7" data-size="70" data-style="LIGHT" data-timing="0">
<canvas width="70" height="70" class="scale-display " style="width: 70px; height: 70px;"></canvas>
<b class="scale-value no-dps">6,31</b></div>

And write in the condition if more than 6.31 press the button
document.getElementsByClassName('js-profile-header-vote')[0].click()

In general, the algorithm is:
window.setInterval(function(){  
    [].forEach.call(
    	document.getElementsByClassName('js-profile-header-name')[0].click()); -- жмем кнопку на странице

//////////////
Условие if >6.31, то жмем document.getElementsByClassName('js-profile-header-vote')[0].click()
              esle то жмем document.getElementsByClassName('js-profile-header-vote')[1].click()
////////////// Вот в этом моменте немного буксую(
}, 3000);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-08-13
@qskyhigh

var headers = document.querySelectorAll('.js-profile-header-vote')
if (x > 6.31) {
  headers[0].click()
} else {
  headers[1].click()
}

It remains to find out what exactly you are comparing with 6.31, that is, where "x" comes from.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question