Skip to content

Commit f6dd26f

Browse files
committed
Show navigation info
1 parent f27eb7f commit f6dd26f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

background.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var css, next, opts
2626
error: "#f12",
2727
wrap: true,
2828
menus: true,
29+
navInfo: true,
2930
unescape: false,
3031
sizeLimit: 10485760,
3132
indent: " ",
@@ -80,6 +81,7 @@ function readConf() {
8081
'div.r' + rand + '{margin-left:8px}'
8182
) +
8283
'i.c', '+.d', '+[data-l]:before{display:none}' +
84+
'.p', '{color:' + opts.info + ';margin:0 0 5px 0}' +
8385
'.x', '{border:1px solid ' + opts.info + ';padding:1em}' +
8486
'a.l', '{text-decoration:none}' +
8587
'a.l', ':hover,a.l', ':focus{text-decoration:underline}' +
@@ -393,6 +395,13 @@ function func(rand, opts, op, msg) {
393395
link.target = "_blank"
394396
}
395397

398+
if (to === body && opts.navInfo) try {
399+
var nav = performance.getEntriesByType("navigation")[0]
400+
, endNames = { request: "responseStart" }
401+
, t = "domainLookup,connect,request,response".split(",").map(function(n) { return (nav[endNames[n] || n + "End"] - nav[n + "Start"]) + "ms" })
402+
el("div", node, "p").textContent = `// Status ${nav.responseStatus} (dns:${t[0]},tcp:${t[1]},req:${t[2]},res:${t[3]})`
403+
if (nav.serverTiming && nav.serverTiming.length) el("div", node, "p").textContent = "// serverTiming: " + JSON.stringify(nav.serverTiming)
404+
} catch(e) {}
396405
try {
397406
window.data = str ? JSON.parse(str) : Error("Empty JSON")
398407
} catch(e) {

options.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<option value="format">Format escaped JSON</option>
104104
<option value="atob">Base64 decode</option>
105105
</select></label>
106+
<label>Show navigation info<input type="checkbox" id="navInfo"></label>
106107
<label>Auto-unescape strings<input type="checkbox" id="unescape"></label>
107108
<label>Open links in new tab<input type="checkbox" id="newtab"></label>
108109
<label>Show line numbers<input type="checkbox" id="lineNo"></label>

0 commit comments

Comments
 (0)