-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdevtools.html
87 lines (82 loc) · 2.42 KB
/
devtools.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<html>
<!--
<script src="devtools.js"></script>
-->
<script src="lib/base64.js"></script>
<script src="lib/md5.js"></script>
<script src="lib/utf8.js"></script>
<script>
function toConsole(msg) {
chrome.extension.sendRequest({
command: "toConsole",
tabId: chrome.experimental.devtools.tabId,
args: msg
//args: escape(JSON.stringify(Array.prototype.slice.call(arguments, 0)))
});
}
ChromeLogger = {
handleFirePhpHeaders: function(har_entry) {
var pattern = /x-wf/i;
},
handleFireLoggerHeaders: function(har_entry) {
var response_headers = har_entry.response.headers;
var buffers = {};
var profiles = {};
var pattern = /^firelogger-([0-9a-f]+)-(\d+)/i;
var parseHeader = function(name, value) {
var res = pattern.exec(name);
if (!res) return;
buffers[res[1]] = buffers[res[1]] || [];
buffers[res[1]][res[2]] = value;
}
for (var key in response_headers) {
parseHeader(response_headers[key].name, response_headers[key].value);
}
var packets = [];
for (var bufferId in buffers) {
if (!buffers.hasOwnProperty(bufferId)) continue;
var buffer = buffers[bufferId].join('');
buffer = Base64.decode(buffer);
buffer = Utf8.decode(buffer);
var packet = JSON.parse(buffer);
packets.push(packet);
}
var logs = [];
for (var packet in packets) {
var packet = packets[packet];
for (i=0; i < packet.logs.length; i++) {
var log = packet.logs[i];
logs.push(log);
}
}
var final = [];
for (var log in logs) {
//final.push(JSON.stringify(logs[log].args));
toConsole(JSON.stringify(logs[log].args));
}
},
};
chrome.experimental.devtools.resources.getHAR(function(result) {
var entries = result.entries;
chrome.experimental.devtools.resources.onFinished.addListener(
ChromeLogger.handleFireLoggerHeaders.bind(ChromeLogger)
);
});
//prepare requestHeaders
var requestHeaders = {"X-FireLogger": "1.1"};
if (localStorage['password']) {
var password = localStorage.getItem('password');
var auth = "#FireLoggerPassword#" + password + "#";
requestHeaders["X-FireLoggerAuth"] = MD5(auth);
//requestHeaders["X-FireLoggerProfiler"] = 1;
//requestHeaders["X-FireLoggerAppstats"] = 1;
}
if (localStorage['remote']) {
requestHeaders["X-FirePHP-Version"] = "0.0.6";
}
//add requestHeaders
chrome.experimental.devtools.resources.addRequestHeaders(requestHeaders);
//add panel into devtools
chrome.experimental.devtools.panels.create("HeaderHelper", "icon32.png", "panel.html");
</script>
</html>