简单的抢票js脚本

帮朋友

function checkTimeAndClick() {
    // Get current time
    const currentTime = new Date();
    console.log('action a', currentTime);
    // Define the target time (e.g., 09:00 AM)
    const targetTime = new Date();
    targetTime.setHours(13, 59, 30); // 这里设置抢票开始时间,如下午2点则为14,00,00
    // Check if the current time is equal to or past the target time
    if (currentTime >= targetTime) {
        // Execute the click operation
        const element = document.querySelectorAll('.status-wrapper')[0];
        if (element) {
            element.click();
            console.log('ticket click 在抢了');
        }
    } else if(new Date()-targetTime>3000){ //这里设置超过3秒后结束脚本
        console.log('已超过抢票时间3秒,抢票结束。');
    }else {
        const timeRange = targetTime - new Date(); //距离目标时间毫秒数
        console.log('离抢票开始还有' + timeRange + '间隔时间');
        setTimeout(checkTimeAndClick, timeRange / 1000.0 < 10 ? 0 : 8000);
    }
}
checkTimeAndClick();

posted @ 2023-07-16 07:30  ukyo--君君小时候  阅读(162)  评论(0编辑  收藏  举报