-
Notifications
You must be signed in to change notification settings - Fork 11
/
devtools.js
41 lines (30 loc) · 1.09 KB
/
devtools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Can use
// chrome.devtools.*
// chrome.extension.*
// most likely this will run when devtools opens
var backgroundPageConnection = chrome.runtime.connect({
name: "devtools-page"
});
(function createChannel() {
//Create a port with background page for continous message communication
var port = chrome.extension.connect({
name: "Another Communication" //Given a Name
});
// Listen to messages from the background page
port.onMessage.addListener(function (message) {
if (message.action === "downloadHARlog") {
chrome.devtools.network.getHAR(
(harLog) => {
let updatedHarLog = {};
// this makes it readable by Chrome Dev Tools
updatedHarLog.log = harLog;
let harBLOB = new Blob([JSON.stringify(updatedHarLog)]);
let url = URL.createObjectURL(harBLOB);
chrome.downloads.download({
url: url
});
}
);
}
});
}());