Nicolas Joseph
Nicolas Joseph

Reputation: 1724

How to get the AST of the current chrome tab from an extension?

I am trying to do some angular code analysis. In that way I need to get a list of all the declared modules in the webpage.

I could not find how to do it with the angular API (I believe that's not possible) but I stumbled on this. Using the AST to get modules looks interesting and promising. I could use Acorn or Esprima but I was wondering if chrome had an API to get the AST of current tab. (Possible with firefox)

EDITS:

Here is an example from wikipedia:

AST Wikipedia example

Upvotes: 2

Views: 689

Answers (1)

Xan
Xan

Reputation: 77541

No, Chrome's V8 does not expose any internals as part of Extension APIs, or, for that reason, remote debugger protocol.

What you see in Dev Tools is about the limit of what is exposed.

You'll need to re-parse it yourself or use a modified version of Chromium that exposes the information you need.

Upvotes: 3

Related Questions