Why is chrome.devtools.network “undefined”?

前端 未结 1 1642
无人及你
无人及你 2021-02-07 15:48

I\'m trying to create an extension that logs all network events. This is the code:

Manifest.json:

{
  \"name\": \"My extension\",
  \"version\" : \"1.0\"         


        
相关标签:
1条回答
  • 2021-02-07 15:59

    chrome.devtools.network is only available within a devtools page. From the documentation of the devtools API (third list item):

    The chrome.devtools.* API modules are available only to the pages loaded within the Developer Tools window. Content scripts and other extension pages do not have these APIs. Thus, the APIs are available only through the lifetime of the Developer Tools window.

    If you need the information in the background page, have a look at this answer (full code included) for setting up a communication channel: Chrome Devpanel Extension Communicating with Background Page.

    0 讨论(0)
提交回复
热议问题