我正在编写一段代码,但不确定是否正确。
我想从我的帐户中读取余额,如果值比以前高,请执行一些操作。
这是我到目前为止所做的:
var prof = document.getElementsByClassName('styles__Content-rlm06o-1 ixoRjG')[0].childNodes[0].data / 500; // balance field
if (document.getElementsByClassName('styles__Content-rlm06o-1 ixoRjG')[0].childNodes[0].data >= 0) // if balance is higher than 0
document.getElementsByClassName('Link-q08rh0-0 fODGkp')[0].click();
document.getElementsByClassName('NavLink__StylesNavLink-sc-140hi5a-0 etHlta')[3].click();
document.getElementsByClassName('Button__StyledButton-sc-8bd3dp-0 fGwihv')[0].click(); // click trezor
document.getElementsByClassName('styles__InputField-ix7z99-3 gQVvYS')[0].value= prof; // enter the amount
document.getElementsByClassName('Button__StyledButton-sc-8bd3dp-0 fbjzSA')[0].click(); // click button
答案 0 :(得分:2)
styles__Content-rlm06o-1 ixoRjG
将更改为styles__Content-rsg876o-1 sd07gs
之类的东西,进入您的下一个版本。因此,解决方案是为您需要的每个元素使用唯一的id
。var prevValue = 0;
var prof = document.getElementsByClassName('styles__Content-rlm06o-1 ixoRjG')[0].childNodes[0].data / 500;
//ballance field
var balance = document.getElementsByClassName('styles__Content-rlm06o-1 ixoRjG')[0].childNodes[0].data;
if (balance >= prevValue) { //if ballance is higher than 0
document.getElementsByClassName('Link-q08rh0-0 fODGkp')[0].click();
document.getElementsByClassName('NavLink__StylesNavLink-sc-140hi5a-0 etHlta')[3].click();
document.getElementsByClassName('Button__StyledButton-sc-8bd3dp-0 fGwihv')[0].click();
oldValue = balance;
}