Sitemap

Member-only story

Find a nested object with needed values from the global scope of a web page

Frameworks expose objects defined in closures by assigning them to DOM elements. How to check if an object containing a needed value is accessible from the global window object?

--

Press enter or click to view image in full size

Why look up objects with specific properties from the console?

When enhancing a web application, it is often easier to find the object where some particular values are stored by using the console, than to figure it out by exploring complex or poorly written code. That is the primary use case.

A more complicated example is automating web sites using Puppeteer or browser extensions. Automating a web page by calling its functions or accessing data in its objects can be an option that is much easier than mimicking user interaction through the user interface or extracting the needed data from the DOM or intercepted HTTP requests.

Even if an object is defined in a closure it might be accessed from the global scope

However, scripts can search only in the objects that are accessible from the global scope, that is, that are nested objects…

--

--

Marian C.
Marian C.

Written by Marian C.

Java, JavaScript and SQL developer. Interested in data collection and visualization.