问题描述
我正在尝试创建一个简单的Chrome扩展,以获取在Chrome开发人员工具栏的网络选项卡中可见的http请求数。
我添加了manifest.json: $ b
首先,控制台不存在,请尝试控制台。
然而,更大的问题可能是您正在编写到错误的控制台,当这个答案结束时,这应该变得更容易理解。
要调试定制的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 pageI 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不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!