diff --git a/src/js/background.js b/src/js/background.js index e8fab0513..51f3212de 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -311,7 +311,6 @@ const µBlock = { // jshint ignore:line } this.fromTabId(tabId); // Must be called AFTER tab context management this.realm = ''; - this.id = details.requestId; this.setMethod(details.method); this.setURL(details.url); this.aliasURL = details.aliasURL || undefined; @@ -373,7 +372,6 @@ const µBlock = { // jshint ignore:line toLogger() { const details = { - id: this.id, tstamp: 0, realm: this.realm, method: this.getMethodName(), diff --git a/src/js/filtering-context.js b/src/js/filtering-context.js index 5bc9aa18f..664205071 100644 --- a/src/js/filtering-context.js +++ b/src/js/filtering-context.js @@ -135,7 +135,6 @@ export const FilteringContext = class { } this.tstamp = 0; this.realm = ''; - this.id = undefined; this.method = 0; this.itype = NO_TYPE; this.stype = undefined; @@ -175,7 +174,6 @@ export const FilteringContext = class { fromFilteringContext(other) { this.realm = other.realm; - this.id = other.id; this.type = other.type; this.method = other.method; this.url = other.url; diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 288789220..52cc67f92 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -36,6 +36,7 @@ const logger = self.logger = { ownerId: Date.now() }; const logDate = new Date(); const logDateTimezoneOffset = logDate.getTimezoneOffset() * 60; const loggerEntries = []; +let loggerEntryIdGenerator = 1; const COLUMN_TIMESTAMP = 0; const COLUMN_FILTER = 1; @@ -319,13 +320,11 @@ const LogEntry = function(details) { if ( details instanceof Object === false ) { return; } const receiver = LogEntry.prototype; for ( const prop in receiver ) { - if ( - details.hasOwnProperty(prop) && - details[prop] !== receiver[prop] - ) { - this[prop] = details[prop]; - } + if ( details.hasOwnProperty(prop) === false ) { continue; } + if ( details[prop] === receiver[prop] ) { continue; } + this[prop] = details[prop]; } + this.id = `${loggerEntryIdGenerator++}`; if ( details.aliasURL !== undefined ) { this.aliased = true; } @@ -346,7 +345,6 @@ LogEntry.prototype = { docHostname: '', domain: '', filter: undefined, - id: '', method: '', realm: '', tabDomain: '', @@ -1627,9 +1625,10 @@ dom.on(document, 'keydown', ev => { const aliasURLFromID = function(id) { if ( id === '' ) { return ''; } for ( const entry of loggerEntries ) { - if ( entry.id !== id || entry.aliased ) { continue; } - const fields = entry.textContent.split('\x1F'); - return fields[COLUMN_URL] || ''; + if ( entry.id !== id ) { continue; } + const match = /\baliasURL=([^\x1F]+)/.exec(entry.textContent); + if ( match === null ) { return ''; } + return match[1]; } return ''; }; diff --git a/src/js/logger.js b/src/js/logger.js index 2ff1d6705..766188e54 100644 --- a/src/js/logger.js +++ b/src/js/logger.js @@ -30,7 +30,6 @@ import { broadcast, broadcastToAll } from './broadcast.js'; let buffer = null; let lastReadTime = 0; let writePtr = 0; -let lastBoxedEntry = ''; // After 30 seconds without being read, the logger buffer will be considered // unused, and thus disabled. @@ -44,7 +43,6 @@ const janitorTimer = vAPI.defer.create(( ) => { logger.enabled = false; buffer = null; writePtr = 0; - lastBoxedEntry = ''; logger.ownerId = undefined; broadcastToAll({ what: 'loggerDisabled' }); }); @@ -55,6 +53,7 @@ const boxEntry = details => { }; const pushOne = box => { + if ( writePtr !== 0 && box === buffer[writePtr-1] ) { return; } if ( writePtr === buffer.length ) { buffer.push(box); } else { @@ -68,12 +67,7 @@ const logger = { ownerId: undefined, writeOne(details) { if ( buffer === null ) { return; } - const box = boxEntry(details); - if ( box === lastBoxedEntry ) { return; } - if ( lastBoxedEntry !== '' ) { - pushOne(lastBoxedEntry); - } - lastBoxedEntry = box; + pushOne(boxEntry(details)); }, readAll(ownerId) { this.ownerId = ownerId; @@ -83,11 +77,8 @@ const logger = { janitorTimer.on(logBufferObsoleteAfter); broadcast({ what: 'loggerEnabled' }); } - if ( lastBoxedEntry !== '' ) { - pushOne(lastBoxedEntry); - lastBoxedEntry = ''; - } const out = buffer.slice(0, writePtr); + buffer.fill('', 0, writePtr); writePtr = 0; lastReadTime = Date.now(); return out;