forked from duckzhao/myspider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path浏览器环境监控_node用.js
37 lines (33 loc) · 853 Bytes
/
浏览器环境监控_node用.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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("111")
}
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.b = {a:2};
window.b.a;
输出
window.set a {}
window.get a {}
window.set b { a: 2 }
window.get b { a: 2 }
*/