Uncaught TypeError: Cannot read property 'network' of undefined in Chrome Extension

Uncaught TypeError: Cannot read property 'network' of undefined in Chrome Extension

我正在开发一个 chrome 扩展来捕获 chrome 开发工具中与网络选项卡相关的数据。 我的代码如下

manifest.js

{
  "name": "Entries",
  "version": "1.0",
  "description": "Give me entries",
  "devtools_page": "devtools.html",
  "manifest_version": 2
}

devtools.js

chrome.devtools.network.getHAR(function(result) {
  var entries = result.entries; 
  Console.warn("entries : " + entries.length);          
});

在控制台选项卡中出现以下错误

Uncaught TypeError: Cannot read property 'network' of undefined

Chrome 不允许用户从开发工具中读取网络日志,这意味着除非您 运行 在开发工具中编写脚本,否则您无法访问网络 information.To 实现这一点,您在面板的 devtools 帮助中创建一个新选项卡,运行 面板中的脚本。