From 53a78ceb39e5417f7ed2d82db526b580f2c1839a Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 4 Jun 2015 19:27:03 -0400 Subject: [PATCH] context provided in title attr of URL in logger (until I figure a better way) --- src/js/logger-ui.js | 7 ++++- src/js/logger.js | 3 ++- src/js/tab.js | 1 + src/js/traffic.js | 65 +++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index ff661a519..124a46d29 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -181,6 +181,7 @@ var createCellAt = function(tr, index) { } if ( td ) { td.removeAttribute('colspan'); + td.removeAttribute('title'); td.textContent = ''; } else { td = document.createElement('td'); @@ -299,7 +300,11 @@ var renderNetLogEntry = function(tr, entry) { } tr.cells[4].textContent = (prettyRequestTypes[type] || type); - tr.cells[5].appendChild(nodeFromURL(url, filter)); + td = tr.cells[5]; + td.appendChild(nodeFromURL(url, filter)); + if ( entry.d4 ) { + td.setAttribute('title', entry.d4); + } }; /******************************************************************************/ diff --git a/src/js/logger.js b/src/js/logger.js index 91bc04fba..1a4692322 100644 --- a/src/js/logger.js +++ b/src/js/logger.js @@ -58,6 +58,7 @@ LogEntry.prototype.init = function(args) { this.d1 = args[3]; this.d2 = args[4]; this.d3 = args[5]; + this.d4 = args[6]; return this; }; @@ -66,7 +67,7 @@ LogEntry.prototype.init = function(args) { LogEntry.prototype.dispose = function() { this.tstamp = 0; this.tab = this.cat = ''; - this.d0 = this.d1 = this.d2 = this.d3 = undefined; + this.d0 = this.d1 = this.d2 = this.d3 = this.d4 = undefined; if ( logEntryJunkyard.length < logEntryJunkyardMax ) { logEntryJunkyard.push(this); } diff --git a/src/js/tab.js b/src/js/tab.js index b095d267b..6560d447c 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -513,6 +513,7 @@ vAPI.tabs.onPopup = function(details) { result, 'popup', targetURL, + openerHostname, openerHostname ); diff --git a/src/js/traffic.js b/src/js/traffic.js index 4293c3578..340c1014a 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -92,7 +92,18 @@ var onBeforeRequest = function(details) { // Possible outcomes: blocked, allowed-passthru, allowed-mirror pageStore.logRequest(requestContext, result); - µb.logger.writeOne(tabId, 'net', result, requestType, requestURL, requestContext.rootHostname); + + if ( µb.logger.isEnabled() ) { + µb.logger.writeOne( + tabId, + 'net', + result, + requestType, + requestURL, + requestContext.rootHostname, + requestContext.pageHostname + ); + } // Not blocked if ( µb.isAllowResult(result) ) { @@ -187,7 +198,18 @@ var onBeforeRootFrameRequest = function(details) { if ( pageStore ) { pageStore.logRequest(context, result); } - µb.logger.writeOne(tabId, 'net', result, 'main_frame', requestURL, context.rootHostname); + + if ( µb.logger.isEnabled() ) { + µb.logger.writeOne( + tabId, + 'net', + result, + 'main_frame', + requestURL, + requestHostname, + requestHostname + ); + } // Not blocked if ( µb.isAllowResult(result) ) { @@ -279,7 +301,18 @@ var onBeforeBehindTheSceneRequest = function(details) { } pageStore.logRequest(context, result); - µb.logger.writeOne(vAPI.noTabId, 'net', result, details.type, details.url, context.rootHostname); + + if ( µb.logger.isEnabled() ) { + µb.logger.writeOne( + vAPI.noTabId, + 'net', + result, + details.type, + details.url, + context.rootHostname, + context.rootHostname + ); + } // Not blocked if ( µb.isAllowResult(result) ) { @@ -328,7 +361,18 @@ var onHeadersReceived = function(details) { var result = pageStore.filterRequestNoCache(context); pageStore.logRequest(context, result); - µb.logger.writeOne(tabId, 'net', result, 'inline-script', details.url, context.rootHostname); + + if ( µb.logger.isEnabled() ) { + µb.logger.writeOne( + tabId, + 'net', + result, + 'inline-script', + details.url, + context.rootHostname, + context.pageHostname + ); + } // Don't block if ( µb.isAllowResult(result) ) { @@ -368,7 +412,18 @@ var onRootFrameHeadersReceived = function(details) { var result = pageStore.filterRequestNoCache(context); pageStore.logRequest(context, result); - µb.logger.writeOne(tabId, 'net', result, 'inline-script', details.url, context.rootHostname); + + if ( µb.logger.isEnabled() ) { + µb.logger.writeOne( + tabId, + 'net', + result, + 'inline-script', + details.url, + context.rootHostname, + context.pageHostname + ); + } // Don't block if ( µb.isAllowResult(result) ) {