Reflection/introspection 在 Ember 应用程序上查找特定模型的实例

Reflection/introspection on an Ember application to find instances of a specific model

首先,我不想了解有关 Ember 的所有内容。我只想在现有 Ember 应用程序上使用它来提取有关应用程序状态的信息。

我正在开发 Chrome 扩展,让用户可以从 Vine 网站下载 "raw" Vine 视频。

Vine 基本上是一个 Ember 应用程序。您可以轻松地使用 Ember Inspector 扩展来检查应用程序并从应用程序状态的深处手动提取视频 URL。

似乎没有 可靠的 方法来仅使用 DOM 来提取这些 URL,因为 Vine 使用 "blob URLs"。所以我在想的是,我会做一些类似于 Ember Introspector 正在做的事情,在应用程序上使用 reflection/introspection。

如何从内容脚本访问 Ember 应用程序(及其状态)?

根据评论,您对 Chrome 扩展相当熟悉,您的问题归结为 "how Ember Inspector works on a high level"。

同样,从评论中可以清楚地看出 Ember Inspector 采用了一种有时称为 "injected scripts" 或 "page-level scripts" 的技术。

内容脚本可以将 <script> 标记插入页面,这将违反 isolated context that content scripts reside in, and will execute in a page's context. As such, you have access to all of Ember's "internals": you're in the same JS context now. You can look at this question 注入此类脚本的方法。

剩下的问题是如何在注入脚本和内容脚本之间进行通信,因为注入脚本无法再访问 Chrome API。例如,可以使用 custom events.

来完成