Skip to content

Instantly share code, notes, and snippets.

@codesorter2015
Created August 12, 2019 11:46
Show Gist options
  • Save codesorter2015/ea2a41bd03e6d090c817dafad5f1f328 to your computer and use it in GitHub Desktop.
Save codesorter2015/ea2a41bd03e6d090c817dafad5f1f328 to your computer and use it in GitHub Desktop.
Create a proxy window object using javascript
handler = {
get: function(target, property, receiver) {
let targetObj = target[property];
if(typeof targetObj == "function") {
return (...args) => target[property].apply(target,args)
} else {
return targetObj;
}
}
}
windowProxyObject = new Proxy(window, handler);
Example:
windowProxyObject.document.getElementsByTagName('HTML');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment