Search code examples
javascriptweb-inspector

Getting to the origin of data in HTML/JavaScript


What's a consistent way to find the origin of data from a certain web app?

Context: I'm working on a native app, and am trying to capture data from a publicly hosted JavaScript app. But I can't figure out where exactly the data I'm looking for originates from. The Document Object Model is quite chaotic.

Consider:

<html>
<body>
    <script src="app.js"></script>
</body>
</html>

and consider app.js:

// super complex app starts here
var hello = "hello world";
document.write(hello);
// super complex app ends here

Let's say app.js is a super complex compressed JS app, that somehow writes "hello world" to the document but we have no immediate idea where it's coming from...

What's a definitive way to figure out where "hello world" first gets mentioned to the DOM?

Web inspector seems unable to search all downloaded files for "hello world"...


Solution

  • It is possible to search in the browser console in all scripts.

    Under the corresponding tab (firefox: debugger, chrome: sources) the search field opens with the shortcut:

    CTRL+SHIFT+F