From ae2eb25e25fb242d4428029a4d7e34d491e6a28f Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 7 Jan 2015 18:56:03 -0500 Subject: [PATCH] also log root document for convenience --- src/css/devtool-log.css | 3 +++ src/js/devtool-log.js | 3 +++ src/js/traffic.js | 13 +++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/css/devtool-log.css b/src/css/devtool-log.css index 1e4d13c2f..29482cfc2 100644 --- a/src/css/devtool-log.css +++ b/src/css/devtool-log.css @@ -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; diff --git a/src/js/devtool-log.js b/src/js/devtool-log.js index 44a28c052..c572eec0a 100644 --- a/src/js/devtool-log.js +++ b/src/js/devtool-log.js @@ -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); diff --git a/src/js/traffic.js b/src/js/traffic.js index 785becd14..c0e00eb11 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -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; }