Test master

From , 5 Years ago, written in Java, viewed 171 times.
URL https://pastebin.vip/view/d240e3d3
  1. 小米的javascript除了数据部分,下面就只剩871行的javascript了。
  2.  
  3. 下面分模块进行分析。首先从简单的工具类入手。
  4.  
  5. 616行到最后。一共253行。
  6.  
  7. 小米由于采用了一个数组,存储所有的静态字符串。所以需要手动对代码进行翻译
  8.  
  9.     var Util = {
  10.         time: function() {
  11.             var a = m.$("reback");
  12.             if (count === 0x0) {//count应该是一个计数器,是倒计时使用的
  13.                 m.$("box-close").innerHTML = "X";//一个关闭的X
  14.                 a.innerHTML = "进入活动";
  15.                 a.className ="reback_btn_next";
  16.                 this.start();
  17.                 return false
  18.             };
  19.             count = count - 0x1;//倒计时减一
  20.             a.innerHTML = ”重新进入(<span id='initCount'>+ count +</span>)
  21.  
  22.    
  23.         },
  24.  
  25.   //以上的time函数,是显示您正在排队倒计时的那个窗口,count这个值,咱们先记住,看看是从何而来
  26.  
  27.         start: function() {
  28.             var b = this,
  29.             a = m.$(”reback“); //这里的m.$应该类似于jquery的选择符,选择的是对象的id
  30.             a.onclick = function() {
  31.                 getStatus.jsonInter(CONFIG.srcs.hdget, ”hdget“, true);//是抢购的关键函数,在这里触发抢购,如果抢购成功,页面会自动跳转,这里需要注意下:之前的抢购这个按钮是存在的,所以我点一下reback,就是稍后那个10秒到5秒的倒计时,请求真的会重新提交给服务器,而不用等30秒。18号的抢购中,却删除了这个按钮,导致我抢购失败。也让郁闷的我决定写这篇文章。
  32.                 b.retime();//下一个函数
  33.                 _gaq.push([”_trackEvent“, ”活动“, ”抢购“,”进入活动“);
  34.                 a.onclick = null;
  35.                 return false
  36.             }
  37.         },
  38.  
  39. //以上,点击开始抢购后的执行的代码,注意这里return false,你懂得。
  40.         retime: function() {
  41.             m.$(”box-close“).innerHTML =” “;
  42.             m.$(”reback“).className = ”reback_btn“;
  43.             count = CONFIG.count  //count是等待的秒数
  44.         },
  45.  
  46. //以上,进行重试的倒计时
  47.         changebg: function() {
  48.             stop = false;
  49.             setInterval(function() {
  50.                 if (!stop) {
  51.                     m.$("top").className = "topmitv";
  52.                     stop = true
  53.                 } else {
  54.                     m.$("top").className = "topmi3";
  55.                     stop = false
  56.                 }
  57.             },
  58.             0x1388) //5秒钟后自动换背景哦。
  59.         },
  60.  
  61. //以上,自动背景替换,5秒换一下
  62.  
  63.         showVideo: function(g) {
  64.             if (typeof document.body.style.maxHeight !== ”undefined“) {//只显示一个等待框。
  65.                 var a = document.body.scrollWidth;
  66.                 var e = document.body.scrollHeight;
  67.                 var b = m.$(”videoBoxMask“);
  68.                 b.style.width = a + ”px“;
  69.                 b.style.height = e + ”px“;
  70.                 b.style.display = ”block“;
  71.                 b.onclick = function() {
  72.                     Util.closeBox()
  73.                 };
  74.                 var c =<span class="close" onclick="Util.closeBox()" title="关闭">X“;
  75.                 var f = document.getElementById(”videoBox“);
  76.                 var d = g.getAttribute(”data-url“);
  77.                 f.innerHTML = c.replace({{videoUrl}}“, d);
  78.                 f.style.display =”block“;
  79.                 return false
  80.             }
  81.         },
  82.  
  83. //以上,显示风起云涌的人山人海的对话框,等吧,兄弟们。
  84.         closeBox: function() {
  85.             m.$(”videoBox“).style.display = ”none“;
  86.             m.$(”videoBox“).innerHTML =”“;
  87.             m.$(”videoBoxMask“).style.display =”none“;
  88.         },
  89.  
  90. //以上,关闭抢购排队对话框
  91.  
  92.         getBookInfo: function(c) { //传入一个c,c是什么呢?
  93.             var a = ”“,
  94.             e = ”“,
  95.             d = ”“,
  96.             b = function(g, f, h) {
  97.                 return<h3>很遗憾,您没有预约“ + g + ”喔</h3>参与开放购买需要提前预约,别灰心,你可返回首页尝试购买“ + f + ”, 也可立即预约1126日星期二开放购买</p>+ h + ”返回活动首页“
  98.             };
  99.             switch (c) {        //原来c是抢购的种类
  100.             case ”phone“:
  101.                 a = ”小米手机“;
  102.                 e = ”小米电视及小米盒子“;
  103.                 d = CONFIG.urls.bookPhone;
  104.                 break;
  105.             case ”tv“:
  106.                 a = ”小米电视“;
  107.                 e = ”小米手机及小米盒子“;
  108.                 d = CONFIG.urls.bookTv;
  109.                 break;
  110.             case ”box“:
  111.                 a = ”小米盒子“;
  112.                 e = ”小米手机及小米电视“;
  113.                 d = CONFIG.urls.bookBox;
  114.                 break
  115.             };
  116.             m.$(”box-reg-wrap“).innerHTML = b(a, e, d);
  117.             m.$(”box-reg-wrap“).style.background =”url(http://p.www.xiaomi.com/open/131101/images/mitu-1.png) no-repeat 5px 0“  //来张漂亮背景
  118.         },
  119.  
  120. //以上,只是用来通知哥们没有预约。。不能抢购。
  121.         pushGA: function(b) {
  122.             var a = ”“;
  123.             switch (b) {
  124.             case ”phone“:
  125.                 a = ”购买手机“;
  126.                 break;
  127.             case  ”tv“:
  128.                 a = ”购买电视“;
  129.                 break;
  130.             case ”box“:
  131.                 a = ”购买盒子“;
  132.                 break
  133.             };
  134.             _gaq.push([”_trackEvent“, ”活动“, ”抢购“, a])
  135.         },
  136.  
  137. //以上,是用来借用google的分析引擎,记录用户行为和流量
  138.         bookedPop: function(c, d) { //d很关键,d里面有预定的url
  139.             var b = CONFIG.isBook,
  140.             a = d.getAttribute(”href“);
  141.             if (m.cookie(CONFIG.cookies.userid)) { //采用cookie进行权限验证,降低服务器负载
  142.                 if ((c === ”phone“ && b.phone === false) || (c === ”tv“ && b.tv === false) || (c === ”box“ && b.box === false)) {//没预定的判断
  143.                     this.getBookInfo(c);//提示哥们没有预定
  144.                     getStatus.boxy(true, ”-reg“) //去预定吧
  145.                 } else {
  146.                     window.open(a) //打开支付的页面,
  147.                 }
  148.             } else {
  149.                 location.href = CONFIG.urls.login//悲催的没登陆。。。
  150.             };
  151.             return false
  152.         },
  153.  
  154.  //以上,是支付的代码
  155.  
  156.         showBox: function(b) {
  157.             var a = CONFIG.isBook;
  158.             this.pushGA(b);
  159.             if (m.cookie(CONFIG.cookies.userid)) {
  160.                 CONFIG.proType = b;
  161.                 if ((b === ”phone“ && a.phone === false) || (b === ”tv“ && a.tv === false) || (b === ”box“ && a.box === false)) {
  162.                     this.getBookInfo(b);
  163.                     getStatus.boxy(true, ” -reg“);
  164.                     return false
  165.                 };
  166.                 getStatus.jsonInter(CONFIG.srcs.hdget,”hdget“, true)
  167.             } else {
  168.                 location.href = CONFIG.urls.login
  169.             }
  170.         },
  171.         animate: function(e, b) {
  172.             var c = document.getElementById(e);
  173.             var d = b;
  174.             var a = function() {
  175.                 var i = d / 0xa;
  176.                 var g = 0x0;
  177.                 var f = function() {
  178.                     g++;
  179.                     if (g == 0xa) {
  180.                         clearInterval(h)
  181.                     };
  182.                     var j = 0x0 - 0x5a * g;
  183.                     c.style.backgroundPosition = j +”px 0
  184.                 };
  185.                 f();
  186.                 var h = setInterval(f, i)
  187.             };
  188.             a();
  189.             window.loadingAnimate = setInterval(a, d)
  190.         },
  191.         resetServertime: function() {
  192.             var a = 0x1e * 0xea60;
  193.             window.resetTime = setInterval(function() {
  194.                 getStatus.jsonInter(CONFIG.srcs.hdinfo, ”hdinfo“, false)
  195.             },
  196.             a)
  197.         }
  198.     };
  199.  
  200. //以上,是显示用的动画
  201.     var loginInfo = {
  202.         data: {
  203.             userId: 0x0,
  204.             userName: ”“ //用cookie存用户信息
  205.         },
  206.         init: function() {
  207.             this.data.userId = m.cookie(CONFIG.cookies.userid); //取出用户名
  208.             if (!this.data.userId) {
  209.                 return false
  210.             };
  211.             this.data.userName = (this.data.userId) ? m.cookie(”XM_“ + this.data.userId + ”_UN“) : ”“;//这里要hack的人要注意了,是cookie的格式,应该可以伪造
  212.             if (this.data.userName == null || this.data.userName == ”“) {
  213.                 var a = document.createElement(”script“);
  214.                 a.src = ”https://account.xiaomi.com/pass/userInfoJsonP?userId=“ + this.data.userId + _$[277];
  215.                 a.type =&callback=loginInfo.getAccountInfo;
  216.                 a.async = true;
  217.                 document.getElementsByTagName(”text/javascript“)[0x0].appendChild(a)
  218.             } else {
  219.                 this.upUserInfo()
  220.             }
  221.         },
  222.  
  223. //以上,是右上角登陆状态的显示
  224.         upUserInfo: function() {
  225.             var a = this.data.userName;
  226.             if ( !! m.$(”LoginArea“)) {
  227.                 m.$(”LoginArea“).innerHTML = ”欢迎您&nbsp;+ a + ”!<a href='http://order.xiaomi.com/site/logout'>退出“;
  228.                 m.$(”LoginArea“).style.paddingLeft = ”12px“
  229.             }
  230.         },
  231.  
  232. //以上,同上,写的好业余
  233.  
  234.         getAccountInfo: function(b) {
  235.             if (b.userId) {
  236.                 this.data.userName = (b.uniqName) ? b.uniqName: b.userId;
  237.                 var a = {
  238.                     path:/“,
  239.                     domain:”.xiaomi.com
  240.                 };
  241.                 m.cookie(”XM_“+ this.data.userId + ”_UN“, this.data.userName, a);//这算掩耳盗铃吗?
  242.                 this.upUserInfo()
  243.             }
  244.         }
  245.     };
  246.  
  247. //以上,用户信息
  248.  
  249. //下面是,网页进入完毕后自动执行的。参考 jquery的ready
  250.  
  251.     m.ready(function() { //越来越像改写的jquery了,为了防止冲突,加了个m
  252.         m.phone(CONFIG.mIndex);
  253.         getStatus.init();
  254.         loginInfo.init();
  255.         Util.changebg();
  256.         m.$(”box-cache-btn“).onclick = function() {
  257.             getStatus.jsonInter(CONFIG.srcs.hdget, ”hdget“, true) //按钮,触发抢购,然后开始等待30秒。。
  258.         };
  259.  
  260.        //以上是注册点击抢购按钮的事件,点击抢购按钮,就执行getStatus.jsonInter方法
  261.  
  262.  
  263.         m.addEvent(m.$(”linksCon“), ”mouseover“,
  264.         function() {
  265.             m.$(”hdLnks“).style.display = ”block“;
  266.             m.$(”linksCon-span“).style.cssText = ”background-color:#fff;color:#333
  267.         });
  268.         m.addEvent(m.$(“linksCon”),"mouseout",
  269.         function() {
  270.             m.$("hdLnks").style.display = "none";
  271.             m.$("linksCon-span").style.cssText = "background:none;border:0;"
  272.         })
  273.     });
  274.  
  275. //以上
  276.  
  277. //以下是自动执行代码,是给google用来做分析的
  278.     var _gaq = _gaq || [];
  279.     _gaq.push([“_setAccount”, “UA-24946561-1]);
  280.     _gaq.push([“_addOrganic”,“baidu”, “word”]);
  281.     _gaq.push([“_addOrganic”, “soso”, “w”]);
  282.     _gaq.push([“_addOrganic”, “vnet”, “kw”]);
  283.     _gaq.push([“_addOrganic”, “sogou”, “query”]);
  284.     _gaq.push([“_addOrganic”, “youdao”, “q”]);
  285.     _gaq.push([“_addOrganic”, “so”, “q”]);
  286.     _gaq.push(["_setDomainName", "xiaomi.com"]);
  287.     _gaq.push(["_setAllowLinker", true]);
  288.     _gaq.push(["_trackPageview"]); (function() {
  289.         var b = document.createElement("script");
  290.         b.type = "text/javascript";
  291.         b.async = true;
  292.         b.src = ("https:"== document.location.protocol ? " https://ssl" : "http://www") + ".google-analytics.com/ga.js";
  293.         var a = document.getElementsByTagName("script")[0x0];
  294.         a.parentNode.insertBefore(b, a)
  295.     })();
  296.     var _msq = _msq || [];
  297.     _msq.push(["setDomainId", 0x64]);
  298.     _msq.push(["trackPageView"]); (function() {
  299.         var a = document.createElement("script");
  300.         a.type = "text/javascript";
  301.         a.async = true;
  302.         a.src = " http://p.www.xiaomi.com/js/xmst.js";
  303.         var b = document.getElementsByTagName("script")[0x0];
  304.         b.parentNode.insertBefore(a, b)
  305.     })();
  306.  

Reply to "Test master"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website