好吧,其实这个还是靠RP比较多,
链接是来自qq空间里面的抢购,
2014年3月26日
在该页面源码,我们可以看到,判断时间是否到整点12点是js判断的
(function() { var mods = [], version = parseFloat(seajs.version); define(["qzact.v8.lib", "jquery", "qzact.v8/common.pc/act.title/index"], function(require, exports, module) { var uri = module.uri || module.id, m = uri.split('?')[0].match(/^(.+\/)([^\/]*?)(?:\.js)?$/i), root = m && m[1], name = m && ('./' + m[2]), i = 0, len = mods.length, curr, args, undefined; for (; i < len; i++) { args = mods[i]; if (typeof args[0] === 'string') { name === args[0] && (curr = args[2]); args[0] = root + args[0].replace('./', ''); (version > 1.0) && define.apply(this, args) } } mods = []; require.get = require; return typeof curr === 'function' ? curr.apply(this, arguments) : require }); define.pack = function() { mods.push(arguments); (version > 1.0) || define.apply(null, arguments) } })(); define.pack("./index", ["qzact.v8.lib", "jquery", "qzact.v8/common.pc/act.title/index", "./tmpl"], function(require, exports, module) { var ACT = require('qzact.v8.lib'), $ = require('jquery'); var header = require('qzact.v8/common.pc/act.title/index'); var tmpl = require('./tmpl'); var lock; var timer; function prefix(num) { return (num > 10 ? '' + num : '0' + num).split('') } var mod = { init: function() { var self = this; if (!ACT.user.isLogin()) { $('.j_has_checkin').addClass('st-c').find('.ma-show').html('<div class="cont"><p class="tips">你还未登录,请登录后查看你的预约码,<a href="javascript:void(0)" class="j_login">立即登录</a></p></div>') } header.setShareData({ url: 'http://xiaomi.qzone.qq.com', content: '799元!真8核神器空间首发', summary: '红米Note 799元——真8核,5.5寸全贴合高清大屏手机,3月26日中午12点整QQ空间独家首发30万台,马上点击预约!', pic: 'http://qzonestyle.gtimg.cn/aoi/sola/20140319222004_65dpxf4aai.png' }); header.init(); $('.j_num').show().html('已有<em>15187578</em>人参与预约'); var code = ACT.storage.global.get('codenum' + ACT.user.getUin()) || ACT.storage.cookie.get('codenum' + ACT.user.getUin()); mod.getCheck({ type: code ? 0 : 1 }).done(function(data) { data.now *= 1000; var timediff = new Date() - data.now; var endCountDown = new Date('2014/3/26 11:59:59').getTime() + timediff; var timeLeft = endCountDown - new Date(); if (timeLeft > 0) { mod.countDown(timeLeft) } else { $('.j_timer').hide(); $('.j_buybtn').addClass('j_buybtn_start').removeClass('btn-now-disabled').addClass('btn-tra') } mod.update(data.code || code && code.split('_')[0]); mod.code = code || (data.code + '_' + data.subcode); if (data.code) { try { ACT.storage.global.set('codenum' + ACT.user.getUin(), data.code + '_' + data.subcode) } catch (e) { ACT.storage.cookie.set('codenum' + ACT.user.getUin(), data.code + '_' + data.subcode) } } }); self.bind() }, bind: function() { $('body').delegate('.j_follow_btn', 'click', function(e) { if (!ACT.user.isLogin()) { ACT.user.showLogin(); return } mod.getFollow().done(function(data) { $('.j_follow_btn').addClass('btn-flow-done').removeClass('btn-flow j_follow_btn').attr('target', '_blank').attr('href', 'http://user.qzone.qq.com/2451201053'); ACT.storage.global.set('has_follow', 1) }).fail(function(message) { ACT.msg.show('error', message, 3000) }); return false }).delegate('.j_share', 'click', function(e) { $('#shareContainer .icon_qz').click() }).delegate('.j_buybtn_start', 'click', function() { if (!ACT.user.isLogin()) { ACT.user.showLogin(); return } mod.getCheck({ type: 2 }); this.target = '_blank'; this.href = 'http://p.www.xiaomi.com/zt/d1b48dc1b3e3eb890c4e7c396f2114a4/index.html#' + mod.code }).delegate('.j_login', 'click', function() { if (!ACT.user.isLogin()) { ACT.user.showLogin(); return } }) }, update: function(code) { if (code) { $('.j_has_checkin').show().find('.ma-num').html(code); $('.j_no_checkin').hide(); $('.ma-show .tit').show() } else { $('.j_follow').show(); $('.j_has_checkin').hide(); if (ACT.storage.global.get('has_follow')) { $('.j_follow_btn').addClass('btn-flow-done').removeClass('btn-flow j_follow_btn').attr('href', 'http://user.qzone.qq.com/2451201053') } } }, countDown: function(timeLeft) { timer = setInterval(function() { var h = prefix(Math.floor(timeLeft / 3600000)); var m = prefix(Math.floor((timeLeft % 3600000) / 60000)); var s = prefix(Math.floor((timeLeft % 60000) / 1000)); $('.j_timer .h i').each(function(i, el) { el.className = 'n' + h[i] }); $('.j_timer .m i').each(function(i, el) { el.className = 'n' + m[i] }); $('.j_timer .s i').each(function(i, el) { el.className = 'n' + s[i] }); timeLeft -= 1000; if (timeLeft <= 0) { $('.j_timer').hide(); $('.j_buybtn').addClass('j_buybtn_start').removeClass('btn-now-disabled').addClass('btn-tra'); clearInterval(timer) } }, 1000) }, get: function(opt) { var defer = $.Deferred(); ACT.ajax.request({ url: opt.url, type: opt.type, dataType: opt.dataType, qzoneCoolCbName: true, data: opt.data, success: function(res) { if (res && res.code === 0) { defer.resolve(res.data) } else { defer.reject(res && res.message) } }, error: function(res) { defer.reject(res) } }); return defer }, getCount: function(opt) { return this.get($.extend({ url: 'http://taotao.qq.com/cgi-bin/fcg_act_spread_count_xiaominote', type: 'get', dataType: 'jsonp', qzoneCoolCbName: true, data: { rekey: 'xiaominote' } }, opt)) }, getFollow: function(opt) { return this.get($.extend({ url: 'http://taotao.qq.com/cgi-bin/fcg_act_spread_focus_xiaominote', type: 'get', dataType: 'jsonp', qzoneCoolCbName: true, data: { uin: ACT.user.getUin(), rekey: 'xiaominote' } }, opt)) }, getCheck: function(opt) { return this.get({ url: 'http://taotao.qq.com/cgi-bin/fcg_act_spread_buy_xiaominote', type: 'get', dataType: 'jsonp', qzoneCoolCbName: true, data: $.extend({ type: 1, uin: ACT.user.getUin(), rekey: 'xiaominote' }, opt) }) } }; return mod }); define.pack("./tmpl", [], function(require, exports, module) { var tmpl = { 'pop': function(data) { var __p = [], _p = function(s) { __p.push(s) }; with(data || {}) { var typeMap = { '5': 'pop-a', '3': 'pop-b', '6': 'pop-c', 'thank': 'pop-d' }; __p.push('<div class="pop j_dialog '); _p(typeMap[type]); __p.push('" style="position:fixed;top:50%;left:50%;margin:-123px 0 0 -248px;"><div class="inner"><i class="btn-close j_close">关闭</i><div class="cont"><div class="tit">'); if (type == 'thank') { __p.push('<a href="http://z.qzone.com/" target="_blank">QQ空间手机版4.2</a><p class="none">感谢您的参与!预约方式已通过手机QQ发送到您的QQ空间公众号您也可以直接打开QQ空间手机版4.2参与活动!</p>') } else { __p.push('<p class="none">'); if (data.awardExpressType == 3 || data.awardExpressType == 5) { __p.push('恭喜你 抽中'); _p(data.awardName); __p.push('!') } else { __p.push('真可惜 只差一点点就抽中了!') } __p.push('') } __p.push('</p></div>'); if (data.awardExpressType == 3) { __p.push('<div class="ma-box">'); _p(data.award_desc); __p.push('</div><p class="tips">凭F码,3月26日12点可直接购买红米Note!</p>') } else if (data.awardExpressType == 5) { __p.push('<p class="tips">我们将在7个工作日内联系你</p>') } __p.push('</div></div></div>') } return __p.join("") } }; return tmpl });
其中,第65、66行的
$(‘.j_timer’).hide();
$(‘.j_buybtn’).addClass(‘j_buybtn_start’).removeClass(‘btn-now-disabled’).addClass(‘btn-tra’)
表示到点了,执行这个方法{
在浏览器控制台(火狐是ctrl+shift+k,chrome是ctrl+shift+j,其他浏览器自测)输入这个语句,然后回车即可
},也就是移除计时器,抢购按钮可用
点进去后,到达抢购界面,但是一闪而退
这时候,手快的可以用ESC按钮定住这个页,继续捕获
会使用扩展利器的,可以监听http请求,拦截最后一个重定向请求即可,博主用的是火狐的 Tamper Data
然后继续探求这页的源码
var xmCookie = function(a, b, c) { var d, e, f, g; return arguments.length > 1 && "[object Object]" !== String(b) ? (c = jQuery.extend({}, c), (null === b || void 0 === b) && (c.expires = -1), "number" == typeof c.expires && (d = c.expires, e = c.expires = new Date, e.setDate(e.getDate() + d)), b = String(b), document.cookie = [encodeURIComponent(a), "=", c.raw ? b : encodeURIComponent(b), c.expires ? "; expires=" + c.expires.toUTCString() : "", c.path ? "; path=" + c.path : "", c.domain ? "; domain=" + c.domain : "", c.secure ? "; secure" : ""].join("")) : (c = b || {}, g = c.raw ? function(a) { return a } : decodeURIComponent, (f = new RegExp("(?:^|; )" + encodeURIComponent(a) + "=([^;]*)").exec(document.cookie)) ? g(f[1]) : null) }, xmLogin = { init: function() { this.orderSite = "http://order.xiaomi.com", this.quickLoginUrl = "https://account.xiaomi.com/pass/static/login.html", this._isLogined() }, _proxyiframe: function() { var a = this.orderSite + "/user/proxy/stop/1", b = "<iframe src='" + a + "' width='0' height='0' name='proxy' id='proxy' frameborder='0' scrolling='no'></iframe>"; $(document.body).append(b), $("iframe[name='proxy']").load(function() { $("iframe[name='proxy']").remove() }) }, _toLogin: function() { function d(a) { var c = a ? a : b.quickLoginUrl, d = "<iframe src='" + c + "' width='100%' height='100%' name='miniLoginFrame' id='miniLoginFrame' frameborder='0' scrolling='no'></iframe>", e = xmCookie("sns_type") ? $("#boxlogin").attr("data-width-sns") : $("#boxlogin").attr("data-width"), f = $("#boxlogin").attr("data-Height"); $("#loginBox-con").css({ height: f }).html(d), xmCookie("sns_type") && $("#loginBox-con").css({ "padding-left": "100px" }), $("#loginBox").css({ width: e }), buyPhone.showBox("login") } var b = this; encodeURIComponent(window.location.href), d("https://www.account.xiaomi.com/pass/static/minilogin.html?third=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fp.www.xiaomi.com%25252Fzt%25252Fd1b48dc1b3e3eb890c4e7c396f2114a4%25252Findex.html%2526sign%253DZDk4MjUxMzQwYjQ2ZmIwODc3ZTczMjAzZjI4ZDkyZmUzNWYzYjIwMw%252C%252C%26sid%3Deshop&sid=eshop&callback=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fp.www.xiaomi.com%25252Fzt%25252Fd1b48dc1b3e3eb890c4e7c396f2114a4%25252Findex.html%2526sign%253DZDk4MjUxMzQwYjQ2ZmIwODc3ZTczMjAzZjI4ZDkyZmUzNWYzYjIwMw%252C%252C&sign=t9GpE2yFdbeeGJOYyWzjwoN5CJA%253D&inframe=true&1395758502914&inframe=true") }, _isLogined: function() { return xmCookie("serviceToken") ? !0 : xmCookie("userId") ? !0 : (this._toLogin(location.href), !1) } }, setLoginInfo = { data: { userId: 0, userName: "" }, miid: xmCookie("userId"), init: function(a) { if (this.data.userId = this.miid, this.userInfoObj = a, this.data.userId) if (this.data.userName = this.miid ? xmCookie("XM_" + this.miid + "_UN") : "", null == this.data.userName || "" === this.data.userName) { var b = document.createElement("script"); b.src = "https://account.xiaomi.com/pass/userInfoJsonP?userId=" + this.miid + "&callback=setLoginInfo.getAccountInfo", b.type = "text/javascript", b.async = !0, document.getElementsByTagName("head")[0].appendChild(b) } else this.updateDom() }, updateDom: function() { var a = this.data.userName; this.userInfoObj.html("<span>" + a + "</span><a href='http://order.xiaomi.com/site/logout'>退出</a") }, getAccountInfo: function(a) { if (a.userId) { this.data.userName = a.uniqName ? a.uniqName : a.userId; var b = { path: "/", domain: ".xiaomi.com" }; xmCookie("XM_" + this.miid + "_UN", this.data.userName, b), this.updateDom() } } }, buyPhone = { init: function() { this.phoneType = "", this.noteCode = "", this.inTheQueue = !1, this.phoneSku = "", this.hmOverCount = 0, this.startTime = new Date("2014/3/26 10:00:00").getTime() / 1e3, this.phoneData = { "HM-note": { sku: "2141200012", name: "红米Note 移动版799元" }, "HM-td": { sku: "2135000510", name: "红米手机 移动版699元" }, "HM-wcdma": { sku: "2135100067", name: "红米手机 联通版799元" }, "HM-telcom": { sku: "2140700031", name: "红米手机 电信版799元" } }; var a = this; a.noteCode = a.getCode().substring(1), a.noteCode ? xmCookie("noteCode", a.noteCode, { path: "/", domain: ".xiaomi.com", expires: 1 }) : a.noteCode || xmCookie("noteCode") && (a.noteCode = xmCookie("noteCode"), location.href += "#" + a.noteCode), a.phone("http://p.www.xiaomi.com/m/sopen/buy/hmnote/index.html#" + a.noteCode), xmLogin.init(), this.getHdInfo(), $("[data-dismiss]").on("click", function() { var b = $(this).attr("data-dismiss"); a.hideBox(b) }), $(document).on("click", ".buyBtn", function() { if ($(this).hasClass("btn-over")) return !1; var b = xmLogin._isLogined(); a.phoneType = $(this).attr("data-type"), b === !0 && ($("#phoneName").html(a.phoneData[a.phoneType].name).parent().show(), a.phoneSku = a.phoneData[a.phoneType].sku, $(".btn").removeClass("btn-selected"), $(this).addClass("btn-selected"), a.winScroll(), $("#btnNext").removeClass("btn-disabled")) }), $("#btnNext").on("click", function() { if (!$(this).hasClass("btn-disabled")) { if (!a.phoneType) return alert("请选择手机版本!"), $("html,body").animate({ scrollTop: 0 }, 500), !1; a.getDmSys(), a.startQueue() } return !1 }), $("#xmDmReload").on("click", function() { $("#btnNext").trigger("click") }) }, getCode: function() { var a = window.location.hash.toString(); return a }, checkCode: function() {}, codeError: function() { this.showBox("Code") }, getHdInfo: function() { var a = this, b = "http://tp.hd.xiaomi.com/hdinfo/cn?_=" + (new Date).getTime(); $.ajax({ type: "GET", url: b, dataType: "jsonp", jsonp: "jsonpcallback", jsonpCallback: "hdinfo", timeout: 3e4, error: function() { a.getInfoError() }, success: function(b) { if (b) { if (b.stime < a.startTime) return location.href = "http://xiaomi.qzone.qq.com/", !1; a.checkInfoStatus(b.status) } } }) }, checkInfoStatus: function(a) { var b, c, d, e, f; for (b in this.phoneData)"undefined" == typeof a[this.phoneData[b].sku] && (a[this.phoneData[b].sku] = {}, a[this.phoneData[b].sku].hdstart = !1, a[this.phoneData[b].sku].hdstop = !0); c = a[this.phoneData["HM-note"].sku].hdstart === !1 && a[this.phoneData["HM-note"].sku].hdstop === !0 ? !0 : !1, d = a[this.phoneData["HM-td"].sku].hdstart === !1 && a[this.phoneData["HM-td"].sku].hdstop === !0 ? !0 : !1, e = a[this.phoneData["HM-wcdma"].sku].hdstart === !1 && a[this.phoneData["HM-wcdma"].sku].hdstop === !0 ? !0 : !1, f = a[this.phoneData["HM-telcom"].sku].hdstart === !1 && a[this.phoneData["HM-telcom"].sku].hdstop === !0 ? !0 : !1, c === !0 ? ($("#NoteBtn").html('<span class="btn btn-over" data-type="HM-note">移动版 799元</span>'), $(".phone .note").addClass("over"), $(".phone .note .subTitle").html("已售罄")) : $("#NoteBtn").html('<span class="btn buyBtn" data-type="HM-note">移动版 799元</span>'), d === !0 ? ($("#HMBtn").html('<span class="btn btn-over" data-type="HM-td">移动版 699元</span>'), this.hmOverCount += 1) : $("#HMBtn").html('<span class="btn buyBtn" data-type="HM-td">移动版 699元</span>'), e === !0 ? ($("#HMBtn").append('<span class="btn btn-over" data-type="HM-wcdma">联通版 799元</span>'), this.hmOverCount += 1) : $("#HMBtn").append('<span class="btn buyBtn" data-type="HM-wcdma">联通版 799元</span>'), f === !0 ? ($("#HMBtn").append('<span class="btn btn-over" data-type="HM-telcom">电信版 799元</span>'), this.hmOverCount += 1) : $("#HMBtn").append('<span class="btn buyBtn" data-type="HM-telcom">电信版 799元</span>'), d === !0 && e === !0 && f === !0 && ($(".phone .hongmi").addClass("over"), $(".phone .hongmi .subTitle").html("已售罄")) }, getInfoError: function() { $("#NoteBtn").html("网络异常,请<a onclick='location.reload();' class='reloadLink'>刷新</a>重试!"), $("#HMBtn").html("网络异常,请<a onclick='location.reload();' class='reloadLink'>刷新</a>重试!") }, getDmSys: function() { var b = this, c = ""; c = "http://tp.hd.xiaomi.com/hdget/cn?product=" + b.phoneSku + "&addcart=1&qqcode=" + b.noteCode + "&m=1&_=" + (new Date).getTime(), $.ajax({ type: "GET", url: c, dataType: "jsonp", jsonp: "jsonpcallback", jsonpCallback: "hdcontrol", timeout: 3e4, success: function() { return b.inTheQueue ? (b.hideBox("Queue"), b.showBox("Error"), void 0) : !1 }, error: function(a) { var c = a.status, d = c[b.phoneSku].hdurl, e = c[b.phoneSku].hdstart === !1 && c[b.phoneSku].hdstop === !0 ? !0 : !1, f = a.d22a51 ? 1e3 * a.d22a51 : 5e3; if (!b.inTheQueue) return !1; if (e === !0) { b.hideBox("Queue"); for (k in b.phoneData) if (b.phoneData[k].sku === b.phoneSku) { b.setOverStatus(k), b.showBox("Over"), b.phoneType = null; break } return !1 } b.getDmTimer && clearInterval(b.getDmTimer), d ? b.getShopCart(d) : (b.inTheQueue || b.startQueue(), b.getDmTimer = setInterval(function() { b.getDmSys() }, f)) } }) }, setOverStatus: function(a) { if (!a) return !1; switch (a) { case "HM-note": $(".btn[data-type=" + a + "]").addClass("btn-over"), $(".phone .note").addClass("over"), $(".phone .note .subTitle").html("已售罄"), $("#overPhoneName").html("红米Note 移动版"); break; case "HM-td": $(".btn[data-type=" + a + "]").addClass("btn-over"), $("#overPhoneName").html("红米手机移动版"), this.hmOverCount += 1; break; case "HM-wcdma": $(".btn[data-type=" + a + "]").addClass("btn-over"), $("#overPhoneName").html("红米手机联通版"), this.hmOverCount += 1; break; case "HM-telcom": $(".btn[data-type=" + a + "]").addClass("btn-over"), $("#overPhoneName").html("红米手机电信版"), this.hmOverCount += 1 } this.hmOverCount >= 3 && ($(".phone .hongmi").addClass("over"), $(".phone .hongmi .subTitle").html("已售罄")) }, getShopCart: function(a) { if (!a) return !1; var b = this, c = "http://order.xiaomi.com/cart/add/" + b.phoneSku + "?token=" + a; $.ajax({ type: "GET", url: c, dataType: "jsonp", jsonp: "jsonpcallback", success: function(a) { b.hideBox("Queue"), 1 === a.code ? location.href = "http://order.xiaomi.com/event/selectPacketForPhone/goodsid/" + b.phoneSku : alert(a.message) } }) }, startQueue: function() { var a = this; a.hideBox("Error"), a.showBox("Queue"), a.queueAnimate(), a.inTheQueue = !0 }, stopQueue: function() { this.inTheQueue = !1, this.getDmTimer && clearInterval(this.getDmTimer), this.startQueueTimer && clearTimeout(this.startQueueTimer), window.queueAnimateTimer && clearInterval(queueAnimateTimer) }, queueAnimate: function() { var a = 0, b = 200, c = function() { a -= 90, -900 >= a && (a = 0), $("#mituWalking").css({ "background-position": a + "px 0" }) }; window.queueAnimateTimer = setInterval(c, b) }, showBox: function(a) { var b = $("#box" + a), c = $("body").outerWidth(), d = $("body").outerHeight(); $("#boxBg").css({ width: c, height: d }).show(), b.show() }, hideBox: function(a) { $("#boxBg").hide(), $("#box" + a).hide(), "Queue" === a && this.inTheQueue === !0 && this.stopQueue() }, winScroll: function() { var a = $("html,body").height() - $(window).height(); $("html,body").animate({ scrollTop: a }, 300) }, phone: function(a) { if (a = a || "http://m.xiaomi.com", "mapp" === xmCookie("orgin")) return xmCookie("orgin", null, { path: "/", domain: ".xiaomi.com" }), void 0; var b = navigator.userAgent; (b.indexOf("Android") > -1 || b.indexOf("iPhone") > -1 || b.indexOf("iPod") > -1 || b.indexOf("Symbian") > -1) && (location.href = a) } }; $(document).ready(function() { buyPhone.init() });
发现里面的抢购按钮的刷新还是js控制,虽然也是用ajax请求,但是我们可以强制执行显示按钮
看到第143行有该方法;
$(“#NoteBtn”).html(‘移动版 799元‘)
执行该方法{
浏览器控制台(火狐是ctrl+shift+k,chrome是ctrl+shift+j,其他浏览器自测)执行语句再回车
}
按钮可点击了,然后进入排队界面,可以通过浏览器控制台看到
ajax请求一个api,这个api返回500错误
也就是说,时间没到点,我们无法继续了,所以,在这个界面停留,等待12点整,多开几个这样的页面,方法都一样的
这样,你就比普通从空间跳转过来购买的人至少快了几秒,
但是终究也还是需要RP的,所以,慢慢等吧
博主在中午11:59:58的时候,逐个点击4个页面的下一步 购买
果然,时间也是宝贵的
点完第四个页面,跑回来看第一个页面,已经抢购成功,
下面的就是填写购买信息,不再赘述
哇靠,跟我抢的人就是你哈、
小米营销策略厉害呀,为了抢还得分析脚本
哈,凡事需要抢的,我都没参与过
好厉害啊。。能写这种技术出来应该可以上班了
下次如果我也要抢购小米,你就帮我抢一次吧??
竟然可以这样啊
还有更巧妙的办法··不过原理类似,忘了在哪里看到的了。。
帮我抢一个吧
技术帝就是不一样,哈哈。又藏姿势了。。还没抢过小米呢。
强悍,
如此强大的功能一定有太多人偷窥吧,真是佩服博主~~相信再遇到抢购活动时,很多人都愿意一试博主的分享吧。
天呐天呐!!!原来抢这个也是这么技术性的啊,,,难怪我都抢不到~
好吧好吧,,我是第一次戳进来,,涨姿势了!!!
我能转载一下分享给我的那些痴货朋友吗~~
活学活用的好典范。。
好厉害的样子ww
高端大气的技术,尔等只会点点点…..