function refresh(){
var search_btn = document.getElementById("query_ticket");
var result_table = document.getElementById("queryLeftTable");//获取火车票查询结果的表格节点
var book_btns = result_table .getElementsByClassName("btn72");
searrch_btn.click();
result_table.addEventListener('click',function(e){//人为查阅并进行预订,同时停止脚本继续刷新
e.target = e.target||e.srcElement;
if(e.target.nodeType === 1 && e.target.nodeName === 'TD' && e.target.innerText === '预订'){
clearInterval(timerId);
}
});
//自动检测车票余票情况,并自动执行预订
var ticket_76000K11580B_trNode = document.getElementById("ticket_76000K11580B");//K1158行节点
var K1158B_tdNode = document.getElementById("YZ_76000K11580B");//K1158硬座节点
var K1158_book_tdNode = ticket_76000K11580B_trNode.getElementsByTagName("td")[12]; //预订车票节点
if(parseInt(K1158B_tdNode.innerText) != (NaN || 0)){
K1158_book_tdNode.click();
}
}

var timerId = setInterval(refresh,10000);

05-11 11:24