How to execute Javascript in Chrome in the context of the current website

This is an XY question. I am trying to execute javascript using chrome-cli on mac in a particular tab. Simple javascript like alert(0) executes as expected. However, if referencing object properties of the website in question I get the error 'name not defined'. The same javascript that doesn't work from chrome-cli works perfectly from the javascript console.

i.e. I can access window.potato from the console but chrome-cli gives me potato is not defined at anonymous.

Listing the sub-properties of window from both the chrome console and chrome-cli with the following javascript shows that some properties are missing.

for(var b in document.defaultView){ if (window.hasOwnProperty(b))console.log(b);}

What can I do?