Extending Chrome with devtool to save a Har file

So here is what I am trying to do. I want to save all HTTP (content + request + response) while I use google chrome. I found a way to use this with a network tool (in a developer tool) where I can download everything manually.

Now I want to automate this whole process, so I don’t need to do any manual thing. I thought we could do this by writing a simple Chrome extension using the API devtools.network.

chrome.devtools.network.onRequestFinished.addListener(
    function(request) {
    //dosomething
});

But I'm kind, lost here, I have not done development of Chrome Extension before. I made a simple file manifest.json:

{
     "manifest_version": 2,
     "name": "My extension",
     "version" : "1.0",
     "background": {
         "scripts": ["devtools.js"],
         "persistent": true
     },
     "devtools_page": "devtools.html",
     "browser_action": {
         "default_title": "Get it",
         "default_icon" : "icon.png"
     }
}

and pasted the first code snippet in devtools.js, but it gave me an error:

network not defined

Am I on the right track? If so, what am I doing wrong with my code?

+5
1

" DevTools":

API chrome.devtools.* , DevTools. API. , API DevTools.

, devtools.html , .


, API chrome.debugger, , Dev Tools. , , API .

, , , - , (, , ). API debugger , Dev Tools, - debugger , Dev Tools ,

: Chrome 63 -, Chrome Dev Tools chrome.debugger .

+4

Source: https://habr.com/ru/post/1584462/


All Articles