码迷,mamicode.com
首页 > 其他好文 > 详细

抢券代码

时间:2016-12-24 16:20:50      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:define   doc   efi   lin   dex   scroll   控制   span   out   

(function(window, document, undefined) {
    var interval = 800;
    var closeDelay = 200;
    var index = 0;
    var couponLinks;
    var getCoupon = function() {
        if (index >= couponLinks.length) {
            console.log("领取完毕");
            return;
        }
        var coponLink = couponLinks[index];
        coponLink.click(); index++;
        console.log("领取 第" + index + "");
        setTimeout(getCoupon, interval);
        setTimeout(function() {
            var close = document.querySelector(.mui-dialog-close);
            if (close != null) close.click();
        }, closeDelay);
    };
    var _scrollTop = 0;
    var _scrollStep = document.documentElement.clientHeight;
    var _maxScrollTop = document.body.clientHeight - document.documentElement.clientHeight;
    var autoScrollDown = setInterval(function() {
        _scrollTop += _scrollStep;
        if (_scrollTop > _maxScrollTop) {
            clearInterval(autoScrollDown);
            couponLinks = document.querySelectorAll(.mui-act-item-yhqbtn);
            console.log("总共:" + couponLinks.length + "条张优惠券待领取...");
            getCoupon();
        } else {
            document.body.scrollTop = _scrollTop;
        }
    }, 500);
}) (window, document);

//直接粘贴到控制台 运行

抢券代码

标签:define   doc   efi   lin   dex   scroll   控制   span   out   

原文地址:http://www.cnblogs.com/vali/p/6217313.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!