Javascript 我可以通过 Google Chrome 扩展程序以编程方式打开 devtools 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6801577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 23:15:02  来源:igfitidea点击:

Can I programmatically open the devtools from a Google Chrome extension?

javascriptgoogle-chrome-extensiongoogle-chrome-devtools

提问by Paul C Nichols

I have a chrome extension which hooks into the devtools. Ideally I want a badge that, when clicked, opens up the devtools on the new tab which I created. Is there any way to do this from the background page?

我有一个 chrome 扩展,它挂在 devtools 中。理想情况下,我想要一个徽章,单击时会在我创建的新选项卡上打开 devtools。有没有办法从后台页面做到这一点?

回答by lokeshsk

It seems unlikely that this is possible or will ever become possible,

这似乎不太可能或将永远成为可能,

check this: https://code.google.com/p/chromium/issues/detail?id=112277

检查这个:https: //code.google.com/p/chromium/issues/detail?id=112277

which says: "We only allow explicit devtools opening."

上面写着:“我们只允许显式的 devtools 打开。”

回答by u283863

Yes you can (or not) using the experimental APIs chrome.experimental.webInspector.
http://code.google.com/chrome/extensions/experimental.html
You can even change the content and panels of it.
Note that you will not able submit extensions that use experimental APIs.

是的,您可以(或不)使用实验性 API chrome.experimental.webInspector
http://code.google.com/chrome/extensions/experimental.html
您甚至可以更改它的内容和面板。
请注意,您将无法提交使用实验性 API 的扩展。

回答by ChristopheCVB

Unfortunately, There is no way to do that...

不幸的是,没有办法做到这一点......

The chrome://chromewebdata link only works if an instance of dev tools is already opened...

chrome://chromewebdata 链接仅在开发工具实例已打开时才有效...

回答by The Final Cut Cat

This is quite old but since I stumbled upon it now searching for a solution I figured others might have too. Since Chrome 28 you can use the devtools.*API. This allows you to open and manipulate DevTools panels. It is also notable no longer expirimental.

这已经很老了,但自从我偶然发现它现在正在寻找解决方案时,我认为其他人也可能有。从 Chrome 28 开始,您可以使用devtools.*API。这允许您打开和操作 DevTools 面板。值得注意的是,它不再是实验性的。