From 1d3dd12fab5323627747ddf8100278b380425dd7 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 15 Mar 2015 13:59:17 -0400 Subject: [PATCH 1/3] this fixes #1025 --- platform/chromium/manifest.json | 2 +- src/js/traffic.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index 3d18ee6ba..6f6ac6090 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock", - "version": "0.9.1.0", + "version": "0.9.1.1", "default_locale": "en", "description": "__MSG_extShortDesc__", diff --git a/src/js/traffic.js b/src/js/traffic.js index 7fbc606c8..5549d5b8d 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -35,6 +35,7 @@ // This is to be used as last-resort fallback in case a tab is found to not // be bound while network requests are fired for the tab. +var mostRecentRootDocURLTimestamp = 0; var mostRecentRootDocURL = ''; /******************************************************************************/ @@ -63,6 +64,7 @@ var onBeforeRequest = function(details) { pageStore.logRequest(pageStore, ''); } mostRecentRootDocURL = requestURL; + mostRecentRootDocURLTimestamp = Date.now(); return; } @@ -76,6 +78,13 @@ var onBeforeRequest = function(details) { // Lookup the page store associated with this tab id. pageStore = µb.pageStoreFromTabId(tabId); if ( !pageStore ) { + // https://github.com/gorhill/uBlock/issues/1025 + // Google Hangout popup opens without a root frame. So for now we will + // just discard that best-guess root frame if it is too far in the + // future, at which point it ceases to be a "best guess". + if ( (Date.now() - mostRecentRootDocURLTimestamp) >= 500 ) { + mostRecentRootDocURL = ''; + } // https://github.com/gorhill/uBlock/issues/1001 // Not a behind-the-scene request, yet no page store found for the // tab id: we will thus bind the last-seen root document to the @@ -147,7 +156,7 @@ var onBeforeRequest = function(details) { } // Blocked - //console.debug('traffic.js > onBeforeRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); + console.debug('traffic.js > onBeforeRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); pageStore.logRequest(requestContext, result); @@ -199,7 +208,7 @@ var onBeforeBehindTheSceneRequest = function(details) { } // Blocked - //console.debug('traffic.js > onBeforeBehindTheSceneRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); + console.debug('traffic.js > onBeforeBehindTheSceneRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); return { 'cancel': true }; }; From f6487270428570f5603f0559f574efef5ab4a060 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 15 Mar 2015 14:04:07 -0400 Subject: [PATCH 2/3] forgot to comment out logging.. --- src/js/traffic.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/traffic.js b/src/js/traffic.js index 5549d5b8d..06f5aae16 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -156,7 +156,7 @@ var onBeforeRequest = function(details) { } // Blocked - console.debug('traffic.js > onBeforeRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); + //console.debug('traffic.js > onBeforeRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); pageStore.logRequest(requestContext, result); @@ -208,7 +208,7 @@ var onBeforeBehindTheSceneRequest = function(details) { } // Blocked - console.debug('traffic.js > onBeforeBehindTheSceneRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); + //console.debug('traffic.js > onBeforeBehindTheSceneRequest(): BLOCK "%s" (%o) because "%s"', details.url, details, result); return { 'cancel': true }; }; From a3abf7aa2b1167968c98ca72fa73701f9df64101 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 15 Mar 2015 14:07:30 -0400 Subject: [PATCH 3/3] ship this with 0.9.1.1 --- src/js/1p-filters.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/js/1p-filters.js b/src/js/1p-filters.js index c22e72900..24709a0d0 100644 --- a/src/js/1p-filters.js +++ b/src/js/1p-filters.js @@ -69,9 +69,30 @@ function allFiltersApplyHandler() { /******************************************************************************/ var handleImportFilePicker = function() { + // https://github.com/gorhill/uBlock/issues/1004 + // Support extraction of filters from ABP backup file + var abpImporter = function(s) { + var reAbpExtractor = /\n\[Subscription\]\n+url=~[\x08-\x7E]+?\[Subscription filters\]([\x08-\x7E]*?)(?:\[Subscription\]|$)/ig; + var matches = reAbpExtractor.exec(s); + // Not an ABP backup file + if ( matches === null ) { + return s; + } + var out = []; + while ( matches !== null ) { + if ( matches.length !== 2 ) { + continue; + } + out.push(matches[1].trim().replace(/\\\[/g, '[')); + matches = reAbpExtractor.exec(s); + } + return out.join('\n'); + }; + var fileReaderOnLoadHandler = function() { + var sanitized = abpImporter(this.result); var textarea = uDom('#userFilters'); - textarea.val([textarea.val(), this.result].join('\n').trim()); + textarea.val(textarea.val().trim() + '\n' + sanitized); userFiltersChanged(); }; var file = this.files[0]; @@ -150,4 +171,3 @@ uDom.onLoad(function() { // https://www.youtube.com/watch?v=UNilsLf6eW4 })(); -