also log root document for convenience

This commit is contained in:
gorhill 2015-01-07 18:56:03 -05:00
parent 3e084455a7
commit ae2eb25e25
3 changed files with 17 additions and 2 deletions

View file

@ -42,6 +42,9 @@ body {
#content table tr.allowed {
background-color: rgba(0, 160, 0, 0.1)
}
#content table tr.maindoc {
background-color: #eee;
}
#content table tr td {
border: 1px solid #ccc;
padding: 3px;

View file

@ -99,6 +99,9 @@ var renderLogEntry = function(entry) {
} else if ( entry.result.charAt(1) === 'a' ) {
tr.classList.add('allowed');
}
if ( entry.type === 'main_frame' ) {
tr.classList.add('maindoc');
}
tr.cells[0].textContent = entry.result.slice(3);
tr.cells[1].textContent = entry.type;
tr.cells[2].innerHTML = renderURL(entry.url, entry.result);

View file

@ -39,16 +39,25 @@ var onBeforeRequest = function(details) {
// Do not block behind the scene requests.
var tabId = details.tabId;
if ( tabId < 0 ) {
// TODO: logging behind-the-scene requests could be nice..
return;
}
var µb = µBlock;
var requestURL = details.url;
var requestType = details.type;
var pageStore;
// Special handling for root document.
if ( requestType === 'main_frame' && details.parentFrameId === -1 ) {
µb.bindTabToPageStats(tabId, requestURL, 'beforeRequest');
pageStore = µb.bindTabToPageStats(tabId, requestURL, 'beforeRequest');
// Log for convenience
if ( pageStore !== null ) {
pageStore.requestURL = requestURL;
pageStore.requestHostname = pageStore.pageHostname;
pageStore.requestType = 'main_frame';
pageStore.logBuffer.writeOne(pageStore, '');
}
return;
}
@ -73,7 +82,7 @@ var onBeforeRequest = function(details) {
}
// Lookup the page store associated with this tab id.
var pageStore = µb.pageStoreFromTabId(tabId);
pageStore = µb.pageStoreFromTabId(tabId);
if ( !pageStore ) {
return;
}