window = new Proxy(window, {
get: function (target, key, receiver) {
// console.log(key, target[key]);
console.log("window.get", key);
if (target[key] instanceof Object){
return new Proxy(target[key], {
get: function (_target, _key, _receiver) {
// console.log("window.get", key, _key, _target[_key]);
console.log("window.get", key, _key);
return _target[_key];
},
set: function (_target, _key, _value, _receiver) {
// console.log("window.set", key, _key, _value);
console.log("window.set", key, _key);
_target[_key] = _value;
return true
}
})
}
return target[key];
},
set: function (target, key, value, receiver) {
console.log("window.set", key, value);
// console.log("window.set", key);
target[key] = value;
return true
}
});
|