任务:目标是获取所有由安装的扩展程序触发的功能。
预期输出:Javascript 函数调用,类似于时间轴面板中显示的内容。
描述: 如上所述,我想从 chrome 获取时间线数据。为此,我正在使用 chrome remote debugging protocol 的时间轴功能使用 chrome javascript debugger API 获取时间线数据.我正在使用以下代码启动调试器:
chrome.debugger.attach({ tabId: tabid }, version, onAttach.bind(null,tabid);
chrome.debugger.sendCommand({ tabId: tabid }, "Tracing.start");
然而,当我运行这段代码时,我收到一条错误消息,指出时间轴已被弃用,请使用跟踪。尽管官方文档没有提到时间轴已被弃用。我也尝试过跟踪以消除错误,但仍然没有捕获到任何事件。是否有标志问题?
阅读 Chrome Apps & Extensions Developer Tool 的代码后,我发现 chrome.activityLogPrivate API 可以通过不同的扩展记录所有事件。但是,我无法通过在我的扩展中调用来运行它,它仍然未定义。我也找不到此扩展的文档。
最佳答案
稳定 1.1 Debugging protocol没有“跟踪”,但是,"tip of the tree" docs准确地说:
Timeline domain is deprecated. Please use Tracing instead.
它应该只是一个警告,因为:
As of Google Chrome 31, we commit to supporting v1.1. All subsequent 1.* versions of the protocol are going to be backwards compatible with 1.1. Our protocol backwards compatibility commitment is:
- No commands or events are removed from the protocol.
- No required parameters are added to the commands.
- No required parameters are removed from command responses or events.
因此您的命令应该正常工作。
chrome.activityLogPrivate
API 就是它在 jar 头上所说的 - private。它仅针对 Chrome 代码中列入白名单的特定扩展程序启用,并且未公开记录。
所以不,除非你使用 hack,否则你不能使用它 like this one ,不能保证有效。
关于javascript - 如何从 chrome 调试 API 中捕获时间线数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31108164/