chrome.devtools.network.getHAR不起作用 [英] chrome.devtools.network.getHAR does not work
问题描述
我正在尝试创建一个简单的Chrome扩展,以获取在Chrome开发人员工具栏的网络选项卡中可见的http请求数。
我添加了manifest.json: $ b
{
name: 条目,
version:1.0,
description:给我条目,
devtools_page:devtools.html,
manifest_version :2
}
devtools.html:
< html>
< body>
< script src =devtools.js>< / script>
< / body>
< / html>
devtools.js:
chrome.devtools.network.getHAR(function(result){
var entries = result.entries;
Console.warn(entries: + entries.length);
});
但是当我添加这个扩展时 - >打开开发工具栏 - >加载页面
我没有看到任何结果:(
这是一个非常简单的例子..任何人都可以请帮我指出,如果我在这里丢失任何输入?
有没有什么办法可以调试?
控制台
不存在,请尝试控制台
。 然而,更大的问题可能是您正在编写到错误的控制台,当这个答案结束时,这应该变得更容易理解。
要调试定制的devtools扩展,你必须调试devtools devtools。如果这听起来像是一个疯狂的,然后按照这些简单的步骤:
- 打开devtools A / li>
- 拆开devtools窗口(使用左下角的按钮)
- 打开另一个devtools B (在第一个d evtools)使用可用的键盘快捷键之一
- 可以享受带devtools B
的调试开发工具 A ul>
所有从devtools A 的扩展程序输出到控制台
的内容都会显示在开发工具的控制台 B 。
I am trying create a simple chrome extension to get number of http requests visible in network tab of chrome developer toolbar. I added manifest.json:
{
"name": "Entries",
"version": "1.0",
"description": "Give me entries",
"devtools_page": "devtools.html",
"manifest_version": 2
}
devtools.html :
<html>
<body>
<script src="devtools.js"></script>
</body>
</html>
devtools.js:
chrome.devtools.network.getHAR(function(result) {
var entries = result.entries;
Console.warn("entries : " + entries.length);
});
But when I add this extension --> open developer toolbar --> load a page I don't see any result :( This is a very simple example.. can anyone please help me point if I am missing any inputs here ?
Is there any way I can debug ?
First of all, Console
doesn't exist, try console
.
However, the bigger issue here may be that you are writing to the wrong console. This should became a bit more understandable when you'll get to the end of this answer.
To debug custom devtools extensions you have to debug devtools with devtools. If this sounds like a madness then follow these simple steps:
- open devtools A for any website
- detach devtools window (using button in the lower left corner)
- open another devtools B (while in the first devtools) using one of available keyboard shortcuts
- enjoy debugging devtools A with devtools B
Everything that you output to the console
from your extension in the devtools A will appear in the console of the devtools B.
这篇关于chrome.devtools.network.getHAR不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!