篡改任意对象方法,来监视方法被调用
function WatchMetod(obj, method, before, after) { obj['_' + method] = obj[method]; obj[method] = function () { var args = [], len = arguments.length; while (len--) args[len] = arguments[len]; before(args); var result = obj['_' + method].apply(this, args); after(args, result); return result; } }
监视任意想监视的方法,也许还能做到拦截等等,要是注入到网页,网页的数据是真的不保了,哈哈哈.