'Custom window object property with reference to original

I am trying to develop an extension in Chrome that will allow me to intercept access to the window object. Lets say I want to return double window.innerHeight, I tried setting it as follows:

Object.defineProperty(window, 'innerHeight', {
  get : () => window.innerHeight * 2,
});

But this obviously leads into infinite recursion. How can I redefine a window property while maintaining a reference to the original property? Doing something like let windowOld = Object.assign({}, window); will just capture the window properties at that static moment, and not actually maintain a reference to the original properties.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source