Last active
July 24, 2018 07:32
-
-
Save ourai/6239347 to your computer and use it in GitHub Desktop.
Revisions
-
ourai revised this gist
Sep 6, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # 智勇大闯关第三季 > 8月20日,阿里校园招聘前端岗位的在线笔试将统一开始。在这之前,我们先玩一下热身赛吧! <http://ued.taobao.com/quiz3/> 截至8月18日11:00之前成功通关并且表现优异的同学,将有机会收到我们的惊喜邮件! 以上是阿里巴巴集团校园招聘的某一条[微博](http://e.weibo.com/2724465062/A4Pzho3k9 "查看该条微博")的内容。 -
Ourai Lin revised this gist
Aug 16, 2013 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -219,7 +219,7 @@  把 URI 中的房间号 `room` 替换成页面上“NEXT ROOM”中显示的。每页都会给出一点点文字提示信息,总共四十多页,如果完全靠人工获取的话,估计你要成鼠标手啦!为了预防疾病,请用下面的代码: (function( $ ) { @@ -300,7 +300,14 @@ msg = "你从房间 " + room + " 破门而入,找到了第 " + count + " 条获得真经的线索,居然是块白纸!!!"; } if ( !!nextRoom ) { msg += "并且发现旁边有个标记提示到房间 " + nextRoom + " 去..."; } else { msg += "并且这回连房间提示都没有了?!?!?!"; } console.log( msg ); } })(jQuery); -
Ourai Lin revised this gist
Aug 16, 2013 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -217,6 +217,10 @@ ## 寻找,无尽的房间  把 URI 中的房间号 `room` 替换成页面上“NEXT ROOM”中显示的,每页都会给出一点点文字提示信息,总共四十多页,如果完全靠人工获取的话,估计你要成鼠标手啦!为了防止疾病,请用下面的代码: (function( $ ) { var stack = [ $("#message").text() ]; -
Ourai Lin revised this gist
Aug 16, 2013 . 1 changed file with 80 additions and 44 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -218,51 +218,87 @@ ## 寻找,无尽的房间 (function( $ ) { var stack = [ $("#message").text() ]; var pathname = location.pathname; (function trace( room ) { if ( !!room ) { var search = location.search; var count = stack.length; if ( count === 1 ) { enterlLog( search.match(/room\=(\d+)/)[1], count, room ); } $.ajax({ url: pathname + search.replace(/room\=\d+/, function() { return "room=" + room; }), dataType: "html", success: function( res ) { var nextRoom = $("#next-room", $(res)).text(); stack.push( $("#message", $(res)).text() ); enterlLog( room, stack.length, nextRoom ); delay(function() { trace( nextRoom ); }, 500); } }); } else { console.log( "经过重重困难险阻终于把所有线索收集齐了,将它们放到一起之后,原本上面空无一物的白纸突然发光,好像有什么要显现出来一样..." ); delay(function() { var q = quiz( stack.join("") ); console.log( "“" + q.msg + "”——如来" ); delay(function() { console.log( "“......”" ); delay(function() { console.log( "“尼玛,你耍我?!”取经人赞美道。" ); delay(function() { console.log( "“5 秒后会将你传送到 " + q.url + " 接受最后一次试炼,通过之后便得真经...”在白纸上方的空中显示道。" ) delay(function() { location = q.url; }, 5000); }, 3000); }, 3000); }, 5000); }, 5000); } })( $("#next-room").text() ); function quiz( str ) { return { msg: str.substring( 0, str.indexOf("好吧") ), url: str.substring( str.indexOf( pathname ) ) }; } function delay() { setTimeout.apply( window, [].slice.call( arguments, 0 ) ); } function enterlLog( room, count, nextRoom ) { var msg; if ( count === 1 ) { msg = "你在房间 " + room + " 中找到了第 1 条获得真经的线索,上面写着“" + stack[0] + "”。"; } else { msg = "你从房间 " + room + " 破门而入,找到了第 " + count + " 条获得真经的线索,居然是块白纸!!!"; } console.log( msg + "并且发现旁边有个标记提示到房间 " + nextRoom + " 去..." ); } })(jQuery); ## 消除!最后的任务 -
Ourai Lin revised this gist
Aug 16, 2013 . 1 changed file with 133 additions and 132 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,101 +32,101 @@ (function() { var pharaoh = getNode("pharaoh"); var sacrifice = getNode("sacrifice"); var sacrificeCoord = getDotCoord( sacrifice ); ejaculate(); // 射出 function ejaculate() { var mirrors = document.getElementsByClassName( "mirror" ); [].forEach.call( mirrors, magicMirror ); } // 镜子魔法 function magicMirror( mirror ) { setCssStyle( mirror, mirrorStyles( mirror ) ); } // 镜子样式 function mirrorStyles( mirror ) { var id = mirror.id; var position = mirrorPosition( id ); return { "webkitTransformOrigin": "50% 0 0", "webkitTransform": "rotate(" + (id === "ma" ? -67.5 : 180) + "deg)", "left": position.left, "top": position.top } } // 镜子位置 function mirrorPosition( id ) { var position; if ( id === "ma" ) { position = getMaCoord(); } else { position = getMbCoord(); } return position; } // 通过 id 获取节点 function getNode( id ) { return document.getElementById( id ); } // 获取样式 function getCssStyle( node, ruleKey ) { return getComputedStyle(node, null)[ruleKey]; } // 设置样式 function setCssStyle( node, rules ) { for ( var key in rules ) { node.style[ key ] = rules[key]; } } // 获取黑点坐标 function getDotCoord( node ) { return { x: parseFloat( getCssStyle(node, "left") ) + parseFloat( getCssStyle(node, "width") )/2, y: parseFloat( getCssStyle(node, "top") ) + parseFloat( getCssStyle(node, "height") )/2 }; } // 计算 ma 镜子的图形中心坐标 function getMaCoord() { var mirror = getNode("ma"); var light = getNode("source"); var coord_y = parseFloat( getCssStyle(light, "top") ) + parseFloat( getCssStyle(light, "height") )/2; var dot2ray = coord_y - sacrificeCoord.y; return { left: sacrificeCoord.x + dot2ray - parseFloat( getCssStyle(mirror, "width") )/2 + "px", top: coord_y + "px" }; } // 计算 mb 镜子的图形中心坐标 function getMbCoord() { var pharaohCoord = getDotCoord( pharaoh ); var mirror = getNode( "mb" ); var dot2dot = (sacrificeCoord.x - pharaohCoord.x)/2; var coor_x = pharaohCoord.x + dot2dot - parseFloat(getCssStyle(mirror, "width"))/2; return { left: coor_x + "px", top: pharaohCoord.y - dot2dot + "px" }; } })(); @@ -164,53 +164,54 @@ 将随机的几个图片是什么全部猜对即过关。 (function() { var map = { "T1eaRYFftbXXcuU8sK-225-225.jpg": "ubuntu", "T1ifFNFklcXXbMbfEI-194-279.png": "sprites", "T1hspWFgxbXXbufJvw-466-303.jpg": "wordpress", "T15vVUFgNcXXX.oZHL-401-270.png": "grunt", "T1FPXRFn8fXXcHpdDI-474-246.png": "less", "T1e9FHFkhgXXbwWSnH-578-406.jpg": "php", "T1J0JVFi4aXXXoqkr9-518-202.png": "npm", "T1UB4UFg8dXXb1KC.o-586-89.jpg": "stackoverflow", "T1JGxUFkJeXXbxRAc_-557-264.jpg": "w3", "T16whWFdBXXXcpN87C-71-212.png": "v", "T11_JTFa8gXXX5c4Pp-356-192.png": "github", "T13ghQFdtgXXaaz0ft-569-116.png": "underscore", "T1VcpUFaFeXXb0Z3E6-448-391.png": "sublime", "T1ZRhTFfdeXXcRZNZO-441-244.png": "jade" }; var img = node("J_pic"); var btn = node("J_btn"); img.onload = function() { findAnswer(); }; btn.addEventListener( "mouseover", handler, false ); function handler( e ) { var answer = map[ img.src.split("\/").pop() ]; if ( answer === undefined ) { console.log( "data map 中没有该图片对应的答案,请自行查找答案。" ); } else { node("J_text").value = answer; } } function node( id ) { return document.getElementById( id ); } function findAnswer() { handler.call(img); btn.click(); } findAnswer(); })(); @@ -225,7 +226,7 @@ function trace( room ) { $.ajax({ url: location.pathname + location.search.replace(/room\=\d+/, function() { return "room=" + room; }), dataType: "html", -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -291,7 +291,7 @@ location.href = atob( document.getElementById("page").getAttribute("data-p") ); ## X,新的任务...  -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ 进入每个关卡后,按 F12 打开开发者工具,在控制台中粘贴脚本代码并执行就可以。 ## 突破,带锁的门  @@ -24,7 +24,7 @@ location.href = atob( document.getElementById("page").getAttribute("data-t") ); ## 激光,前进的方向  @@ -130,7 +130,7 @@ })(); ## 坐标,隐藏的线索  @@ -157,7 +157,7 @@ } })(); ## 图案,疯狂的猜测  @@ -214,7 +214,7 @@ })(); ## 寻找,无尽的房间 (function( $ ) { @@ -264,7 +264,7 @@ })(jQuery); ## 消除!最后的任务  @@ -291,7 +291,7 @@ location.href = atob( document.getElementById("page").getAttribute("data-p") ); ## 新的任务...  -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ # 智勇大闯关第三季 > 8月20日,阿里校园招聘前端岗位的在线笔试将统一开始。在这之前,我们先玩一下热身赛吧! <http://t.cn/zQRFjtd> 截至8月18日11:00之前成功通关并且表现优异的同学,将有机会收到我们的惊喜邮件! 以上是阿里巴巴集团校园招聘的某一条[微博](http://e.weibo.com/2724465062/A4Pzho3k9 "查看该条微博")的内容。 虽然我早已不是学生,本着好奇心也要玩一玩此游戏!经过几个小时的奋斗,我看到了美女,但不知道那是不是 True Ending。也许很多人把游戏通关之后就不玩不去探索了,可我不一样!我玩游戏向来都是要尽量把所有隐藏要素都挖掘出来才算结束。 正是因为知道结果,才有可能去优化过程,一个工程师的职责难道不正是这个么?“如何自动化、智能地去过每一关”的想法让我的血液稍微沸腾了起来。又经过几个小时的编码及测试,自我感觉已经把“隐藏要素”挖得差不多了。现将各个关卡的过关要点及自动获取过关条件的 JavaScript 脚本放出来。 进入每个关卡后,按 F12 打开开发者工具,在控制台中粘贴脚本代码并执行就可以。 ## STAGE.1 突破,带锁的门 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,11 +20,7 @@ 从代码的命名不难理解:撒粉。现实中提取指纹也是通过一种化学药剂。 这个方法需要执行多次才能够看清数字上的指纹,这时就需要把那几个数字排列组合一下挨个试了。不过这是一般人的做法,其实想进屋不止输入密码这一条路: location.href = atob( document.getElementById("page").getAttribute("data-t") ); @@ -278,7 +274,7 @@ 看到这个之后,一般都会立刻到 DOM 树中查找 `id` 或者 `class` 为 `cover` 的节点,并且理解到也许是利用 cover 让指纹的图片无法被看到,正常人都是这么想的。 在页面上除了指纹图片,还有更为明显的控件——文本框和提交按钮!这时大家都会明白是需要通过提交什么东西来达到目的。这时就要用到“伪·跨站攻击(XSS)”的技术手段了。 <style> .cover { @@ -294,3 +290,9 @@ 其实还有个不按正常套路过关的方法,这个方法跟最开始开密码锁时的非主流方法是一样的: location.href = atob( document.getElementById("page").getAttribute("data-p") ); ## FINAL X,新的任务...  经过长期奋战,千辛万苦之后只换得一个美女的背影,是不是很想上去拍她屁股一下啊?没关系,尽情地去实践你的想法吧! -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 88 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # 智勇大闯关第三季 此为 **阿里巴巴集团 2014 校园招聘解题攻略** 。 > 8月20日,阿里校园招聘前端岗位的在线笔试将统一开始。在这之前,我们先玩一下热身赛吧! <http://t.cn/zQRFjtd> 截至8月18日11:00之前成功通关并且表现优异的同学,将有机会收到我们的惊喜邮件! @@ -14,7 +14,7 @@  打开控制台,在 DOM 树中就已经给出提示了—— > 调用 `powder.blow()` 显示指纹痕迹! @@ -30,10 +30,10 @@ ## STAGE.2 激光,前进的方向  通关的方法就是翻转镜子,让折射光线照到黑点。当光线照射到第一个黑点后,第二个黑点就显示出来了。 (function() { var pharaoh = getNode("pharaoh"); @@ -164,7 +164,60 @@ ## STAGE.4 图案,疯狂的猜测  将随机的几个图片是什么全部猜对即过关。 (function() { var map = { "http://img03.taobaocdn.com/tps/i3/T1eaRYFftbXXcuU8sK-225-225.jpg": "ubuntu", "http://img01.taobaocdn.com/tps/i1/T1ifFNFklcXXbMbfEI-194-279.png": "sprites", "http://img01.taobaocdn.com/tps/i1/T1hspWFgxbXXbufJvw-466-303.jpg": "wordpress", "http://img03.taobaocdn.com/tps/i3/T15vVUFgNcXXX.oZHL-401-270.png": "grunt", "http://img04.taobaocdn.com/tps/i4/T1FPXRFn8fXXcHpdDI-474-246.png": "less", "http://img03.taobaocdn.com/tps/i3/T1e9FHFkhgXXbwWSnH-578-406.jpg": "php", "http://img02.taobaocdn.com/tps/i2/T1J0JVFi4aXXXoqkr9-518-202.png": "npm", "http://img02.taobaocdn.com/tps/i2/T1UB4UFg8dXXb1KC.o-586-89.jpg": "stackoverflow", "http://img03.taobaocdn.com/tps/i3/T1JGxUFkJeXXbxRAc_-557-264.jpg": "w3", "http://img02.taobaocdn.com/tps/i2/T16whWFdBXXXcpN87C-71-212.png": "v", "http://img03.taobaocdn.com/tps/i3/T11_JTFa8gXXX5c4Pp-356-192.png": "github", "http://img03.taobaocdn.com/tps/i3/T13ghQFdtgXXaaz0ft-569-116.png": "underscore", "http://img03.taobaocdn.com/tps/i3/T1VcpUFaFeXXb0Z3E6-448-391.png": "sublime" }; var img = node("J_pic"); var btn = node("J_btn"); img.onload = function() { findAnswer(); }; btn.addEventListener( "mouseover", handler, false ); function handler( e ) { var answer = map[ img.src ]; if ( answer === undefined ) { console.log( "data map 中没有该图片对应的答案,请自行查找答案。" ); } else { node("J_text").value = answer; } } function node( id ) { return document.getElementById( id ); } function findAnswer() { handler.call(img); btn.click(); } findAnswer(); })(); ## STAGE.5 寻找,无尽的房间 (function( $ ) { @@ -184,18 +237,20 @@ var nextRoom = $("#next-room", $(res)).text(); if ( nextRoom !== "" ) { var msg = $("#message", $(res)).text(); stack.push( msg ); console.log( "恭喜你,在第 " + room + " 号房间中找到了<" + msg + ">!正在前往第 " + nextRoom + " 号房间..." ); setTimeout(function() { trace( nextRoom ); }, 1500); } else { var url = quizUrl(); console.log( "经过层层劫难,已取得真经 " + url + "!" ); setTimeout(function() { location.href = url; @@ -213,5 +268,29 @@ })(jQuery); ## STAGE.6 消除!最后的任务  控制台中的提示—— > 注意 cover 看到这个之后,一般都会立刻到 DOM 树中查找 `id` 或者 `class` 为 `cover` 的节点,并且理解到也许是利用 cover 让指纹的图片无法被看到,正常人都是这么想的。 在页面上除了指纹图片,还有更为明显的控件——文本框和提交按钮!这时大家都会明白是需要通过提交什么东西来达到目的。这时就要用到跨站攻击(XSS)的技术手段了。 <style> .cover { position: absolute; left: 588px !important; top: 340px !important; z-index: 9999999999999999; background: wheat; opacity: 1 !important; } </style> 其实还有个不按正常套路过关的方法,这个方法跟最开始开密码锁时的非主流方法是一样的: location.href = atob( document.getElementById("page").getAttribute("data-p") ); -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 21 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ # 智勇大闯关第三季 此为**阿里巴巴集团 2014 校园招聘解题攻略** > 8月20日,阿里校园招聘前端岗位的在线笔试将统一开始。在这之前,我们先玩一下热身赛吧! <http://t.cn/zQRFjtd> 截至8月18日11:00之前成功通关并且表现优异的同学,将有机会收到我们的惊喜邮件! @@ -8,7 +10,7 @@ 其实每题都可以在 console 中用 JavaScript 代码来解决,下面就是除了猜图之外的执行代码。 ## STAGE.1 突破,带锁的门  @@ -24,9 +26,13 @@ 其实想进屋,不止输入密码这一条路: location.href = atob( document.getElementById("page").getAttribute("data-t") ); ## STAGE.2 激光,前进的方向 通关的方法就是要翻转镜子,让折射光线照到黑点。当光线照射到第一个黑点后,第二个黑点就显示出来了  (function() { @@ -128,7 +134,11 @@ })(); ## STAGE.3 坐标,隐藏的线索  本关要点就是运用 HTML 源码注释中的那一大段数字字符串通过 `canvas` 完成二维码。 (function() { var qrdata = getQrData().split(" "); @@ -150,8 +160,12 @@ return data; } })(); ## STAGE.4 图案,疯狂的猜测  ## STAGE.5 寻找,无尽的房间 (function( $ ) { @@ -200,4 +214,4 @@ })(jQuery); ## STAGE.6 消指纹 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,9 @@ 其实每题都可以在 console 中用 JavaScript 代码来解决,下面就是除了猜图之外的执行代码。 ## STAGE.1 解密码 - 突破,带锁的门  打开控制台,在 DOM 树中就已经给出提示了 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 39 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,11 +8,25 @@ 其实每题都可以在 console 中用 JavaScript 代码来解决,下面就是除了猜图之外的执行代码。 ## STAGE.1 解密码 > 门锁住了,我得想办法找到密码才行 打开控制台,在 DOM 树中就已经给出提示了 > 调用 `powder.blow()` 显示指纹痕迹! 从代码的命名不难理解:撒粉。现实中提取指纹也是通过一种化学药剂。 这个方法需要执行多次才能够看清数字上的指纹,这时就需要把那几个数字排列组合一下挨个试了。不过这是一般人的做法,下面的代码可以帮你开锁! // 代码正在书写 其实想进屋,不止输入密码这一条路: location.href = Base64.decode( document.getElementById("page").getAttribute("data-t") ); ## STAGE.2 翻镜子 (function() { @@ -114,30 +128,30 @@ })(); ## STAGE.3 二维码 (function() { var qrdata = getQrData().split(" "); var ctx = document.getElementById("qr-canvas").getContext("2d"); qrdata.forEach(function( code ) { ctx.fillRect.apply( ctx, code.split( "," ) ); }); function getQrData() { var data; [].forEach.call(document.body.childNodes, function( node ) { if ( node.nodeType === document.COMMENT_NODE ) { data = node.data.replace(/\r|\n/g, ""); } }); return data; } })(); ## STAGE.4 闯房间 (function( $ ) { @@ -147,7 +161,7 @@ trace( currentRoom ); function trace( room ) { $.ajax({ url: location.pathname + location.search.replace(/room\=\d+/, function() { return "room=" + room; }), @@ -184,3 +198,6 @@ } })(jQuery); ## STAGE.5 消指纹 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,9 +6,7 @@ 我虽然看到了美女,但不知道那是不是 true ending。即使如此,我也将我的解题方法公布出来。 其实每题都可以在 console 中用 JavaScript 代码来解决,下面就是除了猜图之外的执行代码。 ## 解密码 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -119,12 +119,24 @@ ## 二维码 (function() { var qrdata = getQrData().split(" "); var ctx = document.getElementById("qr-canvas").getContext("2d"); qrdata.forEach(function( code ) { ctx.fillRect.apply( ctx, code.split( "," ) ); }); function getQrData() { var data; [].forEach.call(document.body.childNodes, function( node ) { if ( node.nodeType === document.COMMENT_NODE ) { data = node.data.replace(/\r|\n/g, ""); } }); return data; } })(); ## 闯房间 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -148,12 +148,20 @@ if ( nextRoom !== "" ) { stack.push( $("#message", $(res)).text() ); console.log( "正在进入第 " + nextRoom + " 号房间..." ); setTimeout(function() { trace( nextRoom ); }, 3000); } else { var url = quizUrl(); console.log( "已经取得通往西天的地址 " + url + ",5 秒后前往西天!" ); setTimeout(function() { location.href = url; }, 5000); } } }); @@ -165,4 +173,4 @@ return str.substring( str.indexOf("/quiz") ); } })(jQuery); -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 37 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,11 +10,11 @@ 下面就是其他题的执行代码。 ## 解密码 location.href = Base64.decode( document.getElementById("page").getAttribute("data-t") ); ## 翻镜子 (function() { @@ -129,10 +129,40 @@ ## 闯房间 (function( $ ) { var currentRoom = $("#next-room").text(); var stack = [currentRoom]; trace( currentRoom ); function trace( room ) { $.ajax({ url: location.pathname + location.search.replace(/room\=\d+/, function() { return "room=" + room; }), dataType: "html", success: function( res ) { var nextRoom = $("#next-room", $(res)).text(); if ( nextRoom !== "" ) { stack.push( $("#message", $(res)).text() ); setTimeout(function() { trace( nextRoom ); }, 3000); } else { location.href = quizUrl(); } } }); } function quizUrl() { var str = stack.join(""); return str.substring( str.indexOf("/quiz") ); } })(jQuery); -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 62 additions and 54 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,93 +17,101 @@ ## 旋转镜子 (function() { var pharaoh = getNode("pharaoh"); var sacrifice = getNode("sacrifice"); var sacrificeCoord = getDotCoord( sacrifice ); ejaculate(); // 射出 function ejaculate() { var mirrors = document.getElementsByClassName( "mirror" ); [].forEach.call( mirrors, magicMirror ); } // 镜子魔法 function magicMirror( mirror ) { setCssStyle( mirror, mirrorStyles( mirror ) ); } // 镜子样式 function mirrorStyles( mirror ) { var id = mirror.id; var position = mirrorPosition( id ); return { "webkitTransformOrigin": "50% 0 0", "webkitTransform": "rotate(" + (id === "ma" ? -67.5 : 180) + "deg)", "left": position.left, "top": position.top } } // 镜子位置 function mirrorPosition( id ) { var position; if ( id === "ma" ) { position = getMaCoord(); } else { position = getMbCoord(); } return position; } // 通过 id 获取节点 function getNode( id ) { return document.getElementById( id ); } // 获取样式 function getCssStyle( node, ruleKey ) { return getComputedStyle(node, null)[ruleKey]; } // 设置样式 function setCssStyle( node, rules ) { for ( var key in rules ) { node.style[ key ] = rules[key]; } } // 获取黑点坐标 function getDotCoord( node ) { return { x: parseFloat( getCssStyle(node, "left") ) + parseFloat( getCssStyle(node, "width") )/2, y: parseFloat( getCssStyle(node, "top") ) + parseFloat( getCssStyle(node, "height") )/2 }; } // 计算 ma 镜子的图形中心坐标 function getMaCoord() { var mirror = getNode("ma"); var light = getNode("source"); var coord_y = parseFloat( getCssStyle(light, "top") ) + parseFloat( getCssStyle(light, "height") )/2; var dot2ray = coord_y - sacrificeCoord.y; return { left: sacrificeCoord.x + dot2ray - parseFloat( getCssStyle(mirror, "width") )/2 + "px", top: coord_y + "px" }; } // 计算 mb 镜子的图形中心坐标 function getMbCoord() { var pharaohCoord = getDotCoord( pharaoh ); var mirror = getNode( "mb" ); var dot2dot = (sacrificeCoord.x - pharaohCoord.x)/2; var coor_x = pharaohCoord.x + dot2dot - parseFloat(getCssStyle(mirror, "width"))/2; return { left: coor_x + "px", top: pharaohCoord.y - dot2dot + "px" }; } })(); -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -117,4 +117,14 @@ qrdata.forEach(function( code ) { ctx.fillRect.apply( ctx, code.split( "," ) ); }); })(); ## 闯房间 (function() { location.search = location.search.replace(/room\=\d*/, function() { return "room=" + jQuery("#next-room").text(); }); })(); -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 94 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,100 @@ ## 进门 location.href = Base64.decode( document.getElementById("page").getAttribute("data-t") ); ## 旋转镜子 (function() { var sacrifice = getNode("sacrifice"); // 显示的点 var pharaoh = getNode("pharaoh"); var ma = getNode("ma"); var mb = getNode("mb"); var maCoord = {}; var mbCoord = {}; rotateMirror(); moveMirror(); // 旋转镜子 function rotateMirror() { setCssStyle( ma, { "webkitTransform": "rotate(-75deg)" }); setCssStyle( mb, { "webkitTransform": "rotate(180deg)" }); } // 移动镜子 function moveMirror() { var maCoord = getMaCoord(); var mbCoord = getMbCoord(); setCssStyle( ma, { "left": maCoord.x + "px", "top": maCoord.y + "px" }); setCssStyle( mb, { "left": mbCoord.x + "px" }); } // 通过 id 获取节点 function getNode( id ) { return document.getElementById( id ); } // 获取样式 function getCssStyle( node, ruleKey ) { return getComputedStyle(node, null)[ruleKey]; } // 设置样式 function setCssStyle( node, rules ) { for ( var key in rules ) { node.style[ key ] = rules[key]; } } // 获取黑点坐标 function getDotCoord( node ) { return { x: parseFloat( getCssStyle(node, "left") ), y: parseFloat( getCssStyle(node, "top") ) }; } // 计算 ma 镜子的图形中心坐标 function getMaCoord() { var light = getNode("source"); var sacrificeCoord = getDotCoord( sacrifice ); var coord_y = parseFloat( getCssStyle(light, "top") ) + parseFloat( getCssStyle(light, "height") )/2; var heightLineDot = coord_y - sacrificeCoord.y; return { x: sacrificeCoord.x + heightLineDot + parseFloat( getCssStyle(ma, "height") )/2, y: coord_y }; } // 计算 mb 镜子的图形中心坐标 function getMbCoord() { var sacrificeCoord = getDotCoord( sacrifice ); var pharaohCoord = getDotCoord( pharaoh ); var mb = document.getElementById("mb"); var mbCoord = getDotCoord( mb ); return { x: pharaohCoord.x + (sacrificeCoord.x - pharaohCoord.x)/2 }; } })(); ## 二维码 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ ## 二维码 (function() { var qrdata = "请自行复制源码中一大段注释中的数字字符串".split(" "); var ctx = document.getElementById("qr-canvas").getContext("2d"); qrdata.forEach(function( code ) { -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ var qrdata = "请自行复制源码中一大段注释中的数字字符串"..split(" "); var ctx = document.getElementById("qr-canvas").getContext("2d"); qrdata.forEach(function( code ) { ctx.fillRect.apply( ctx, code.split( "," ) ); }); })(); -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ ## 进门 location.href = Base64.decode( document.getElementById("page").getAttribute("data-t") ); ## 二维码 -
Ourai Lin revised this gist
Aug 15, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ ## 进门 location.href = Base64.decode(document.getElementById("page").getAttribute("data-t")); ## 二维码 -
Ourai Lin created this gist
Aug 15, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ # 阿里巴巴集团 2014 校园招聘解题攻略 > 8月20日,阿里校园招聘前端岗位的在线笔试将统一开始。在这之前,我们先玩一下热身赛吧! <http://t.cn/zQRFjtd> 截至8月18日11:00之前成功通关并且表现优异的同学,将有机会收到我们的惊喜邮件! 以上是阿里巴巴集团校园招聘的某一条[微博](http://e.weibo.com/2724465062/A4Pzho3k9 "查看该条微博")的内容。 我虽然看到了美女,但不知道那是不是 true ending。即使如此,我也将我的解题方法公布出来。 其实每题都可以在 console 中用 JavaScript 代码来解决,但由于射线那道题计算公式太复杂,所以还是请各位手动调整吧~ 下面就是其他题的执行代码。 ## 进门 location.href=Base64.decode(document.getElementById("page").getAttribute("data-t")); ## 二维码 (function() { var qrdata = "请自行复制源码中一大段注释中的数字字符串"..split(" "); var ctx = document.getElementById("qr-canvas").getContext("2d"); for ( var i = 0; i < qrdata.length; i++ ) { ctx.fillRect.apply( ctx, qrdata[i].split( "," ) ); } })();