如何从扩展中获取当前 chrome 选项卡的 AST?
How to get the AST of the current chrome tab from an extension?
我正在尝试做一些 angular 代码分析。这样我就需要得到网页中所有已声明模块的列表。
我找不到如何使用 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 但我想知道 chrome 是否有 API当前选项卡的 AST。(可以使用 firefox)
编辑:
- AST,我的意思是抽象语法树。它是由解析器从脚本生成的数据结构,可以轻松解释它。所有的浏览器都用它来解释js。可以在 here
上找到更多信息
这是来自维基百科的示例:
不,Chrome 的 V8 不公开任何内部结构作为 Extension APIs, or, for that reason, remote debugger protocol 的一部分。
你在 Dev Tools 中看到的是关于暴露的限制。
您需要自己重新解析它或使用公开您需要的信息的修改版 Chromium。
我正在尝试做一些 angular 代码分析。这样我就需要得到网页中所有已声明模块的列表。
我找不到如何使用 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 但我想知道 chrome 是否有 API当前选项卡的 AST。(可以使用 firefox)
编辑:
- AST,我的意思是抽象语法树。它是由解析器从脚本生成的数据结构,可以轻松解释它。所有的浏览器都用它来解释js。可以在 here 上找到更多信息
这是来自维基百科的示例:
不,Chrome 的 V8 不公开任何内部结构作为 Extension APIs, or, for that reason, remote debugger protocol 的一部分。
你在 Dev Tools 中看到的是关于暴露的限制。
您需要自己重新解析它或使用公开您需要的信息的修改版 Chromium。