(function() { let shistory = gBrowser.selectedBrowser.browsingContext.sessionHistory; let index = shistory.index; let requestedIndex = shistory.requestedIndex; let count = shistory.count; function encode(uri) { if (!uri) { return null; } let u = encodeURIComponent(uri); if (u.length > 100) { u = u.substr(0, 100) + "..."; } return u; } function entryToString(entry, i) { return "Entry[" + i + "], originalURI: " + encode(entry.originalURI?.spec) + ", uri: " + encode(entry.URI?.spec) + ", ID: " + entry.ID + "
"; } function childToString(entry, index, nested) { let out = ""; for (let n = 0; n < nested; ++n) { out += "  "; } if (!entry) { return out + "Entry[" + index + "](null entry)"; } out = out + entryToString(entry, index); for (let i = 0; i < entry.childCount; ++i) { out += childToString(entry.GetChildAt(i), i, nested + 1); } return out; } let entries = ""; for (let i = 0; i < count; ++i) { let entry = shistory.getEntryAtIndex(i); entries += entryToString(entry, i); for (let j = 0; j < entry.childCount; ++j) { entries += childToString(entry.GetChildAt(j), j, 1); } } let uri = "data:text/html," + "index: " + index + "
" + "requestedIndex: " + requestedIndex + "
" + "count: " + count + "
" + entries; gBrowser.addAdjacentNewTab("about:blank"); gBrowser.selectedBrowser.loadURI(uri, {triggeringPrincipal: document.nodePrincipal}); } )();