前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >JavaScript的Hook

JavaScript的Hook

作者头像
meteoric
发布2018-11-16 17:19:23
6930
发布2018-11-16 17:19:23
举报
文章被收录于专栏:游戏杂谈游戏杂谈
代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
<title>hook</title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
</head>

<body>
  

<input type='button' value='fuck' onclick='fuck()' />
<input type='button' value='hook' onclick='hook()' id='hookBtn' />


<script type='text/javascript'>   1:     2:        3: function fuck() {   4:     alert('hook');   5: }   6:     7: var isHook = false;   8: var isReset = false;   9:    10: function getEl(id) {  11:     return typeof id === 'string' ? document.getElementById(id) : null;  12: }  13:    14: function hook() {  15:       16:     if (isHook)    {          17:         isReset = true;      18:         getEl('hookBtn').value = 'hook';  19:     } else {  20:         fuck = function(fn) {  21:             return function() {  22:                 if (isReset) {  23:                     isReset = false;  24:                     fuck = fn;  25:                     fn.apply(fn, arguments);  26:                     return ;  27:                 }  28:    29:                 alert('hook it~');  30:                 fn.apply(fn, arguments);  31:    32:                 return fn;  33:             }  34:         }(fuck);  35:    36:         getEl('hookBtn').value = 'unHook';  37:     }  38:    39:     isHook = !isHook;  40: }  41:  </script>

</body>
</html>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2012-05-06 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档