js 破解之补浏览器环境的两种监控方式
本文由 简悦
SimpRead 转码, 原文地址 mp.weixin.qq.com
1,首先要说的肯定是
window = new Proxy(global, {
get: function (target, key, receiver) {
console.log("window.get", key, target[key]);
if (key=="location"){
location = new Proxy(target[key], {
get: function (_target, _key, _receiver) {
console.log("window.get", key, _key, _target[_key]);
if (_key=="port"){console.log("关注公众号【妄为写代码】")}
return _target[_key];
}
})
}
return target[key];
},
set: function (target, key, value, receiver) {
console.log("window.set", key, value);
target[key] = value;
}
});
window.a = {};
window.a;
window.location = {a: 2};
window.location.a;
window.b = {a: 2};
window.b.a;
location.port;
console.log("--------------");
window.location.port;
重点关注【嵌套
2,对象属性的
在浏览器中执行:
重点关注【未在固定范围的新增属性】和【对比两种方式的
3,这个监控的作用就不用说了吧,就是大家常说的缺哪补哪需要用到的,现在补环境的场景越来越多了,一些知名
嗯,我也准备学大家开始【佛系】社群运营了,大家可以扫码进群一起交流技术,nice to meet you.