From 865340196186915a156811cab93a8fb0316b8e21 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sat, 25 Oct 2014 23:30:43 -0400 Subject: [PATCH] this fixes #10 --- src/background.html | 2 +- src/js/httpsb.js | 2 +- src/js/start.js | 33 ++++++------ src/js/traffic.js | 127 +++++++++++++++++++++++--------------------- 4 files changed, 84 insertions(+), 80 deletions(-) diff --git a/src/background.html b/src/background.html index e681360..cc02035 100644 --- a/src/background.html +++ b/src/background.html @@ -26,8 +26,8 @@ - + diff --git a/src/js/httpsb.js b/src/js/httpsb.js index 5ccd5d0..50179fd 100644 --- a/src/js/httpsb.js +++ b/src/js/httpsb.js @@ -73,7 +73,7 @@ if ( '.css.eot.ttf.otf.svg.woff.woff2.'.indexOf(ext) !== -1 ) { return 'css'; } - if ( '.ico.png.gif.jpg.jpeg.'.indexOf(ext) !== -1 ) { + if ( '.ico.png.gif.jpg.jpeg.bmp.'.indexOf(ext) !== -1 ) { return 'image'; } return type; diff --git a/src/js/start.js b/src/js/start.js index f0ca2cc..e06e693 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -23,6 +23,16 @@ /******************************************************************************/ +// rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the +// normal way forbid binding behind the scene tab. +// https://github.com/gorhill/httpswitchboard/issues/67 + +µMatrix.createPageStats(µMatrix.behindTheSceneURL); +µMatrix.pageUrlToTabId[µMatrix.behindTheSceneURL] = µMatrix.behindTheSceneTabId; +µMatrix.tabIdToPageUrl[µMatrix.behindTheSceneTabId] = µMatrix.behindTheSceneURL; + +/******************************************************************************/ + µMatrix.turnOn(); /******************************************************************************/ @@ -106,22 +116,6 @@ chrome.webNavigation.onBeforeNavigate.addListener(onBeforeNavigateCallback); /******************************************************************************/ -// Load everything - -µMatrix.load(); - -/******************************************************************************/ - -// rhill 2013-11-24: bind behind-the-scene virtual tab/url manually, since the -// normal way forbid binding behind the scene tab. -// https://github.com/gorhill/httpswitchboard/issues/67 - -µMatrix.createPageStats(µMatrix.behindTheSceneURL); -µMatrix.pageUrlToTabId[µMatrix.behindTheSceneURL] = µMatrix.behindTheSceneTabId; -µMatrix.tabIdToPageUrl[µMatrix.behindTheSceneTabId] = µMatrix.behindTheSceneURL; - -/******************************************************************************/ - // Initialize internal state with maybe already existing tabs chrome.tabs.query({ url: '' }, function(tabs) { @@ -178,3 +172,10 @@ chrome.tabs.query({ url: '' }, function(tabs) { })(); /******************************************************************************/ + +// Load everything + +µMatrix.load(); +µMatrix.webRequest.start(); + +/******************************************************************************/ diff --git a/src/js/traffic.js b/src/js/traffic.js index 2576788..ee1270a 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -854,72 +854,75 @@ var requestTypeNormalizer = { /******************************************************************************/ -chrome.webRequest.onBeforeRequest.addListener( - //function(details) { - // quickProfiler.start('onBeforeRequest'); - // var r = onBeforeRequestHandler(details); - // quickProfiler.stop(); - // return r; - //}, - onBeforeRequestHandler, - { - "urls": [ - "http://*/*", - "https://*/*", - "chrome-extension://*/*" - ], - "types": [ - "main_frame", - "sub_frame", - 'stylesheet', - "script", - "image", - "object", - "xmlhttprequest", - "other" - ] - }, - [ "blocking" ] -); - -//console.log('µMatrix > Beginning to intercept net requests at %s', (new Date()).toISOString()); - -chrome.webRequest.onBeforeSendHeaders.addListener( - onBeforeSendHeadersHandler, - { - 'urls': [ - "http://*/*", - "https://*/*" - ] - }, - ['blocking', 'requestHeaders'] -); - -chrome.webRequest.onHeadersReceived.addListener( - onHeadersReceived, - { - 'urls': [ - "http://*/*", - "https://*/*" - ] - }, - ['blocking', 'responseHeaders'] -); - -chrome.webRequest.onErrorOccurred.addListener( - onErrorOccurredHandler, - { - 'urls': [ - "http://*/*", - "https://*/*" - ] - } -); +var start = function() { + chrome.webRequest.onBeforeRequest.addListener( + //function(details) { + // quickProfiler.start('onBeforeRequest'); + // var r = onBeforeRequestHandler(details); + // quickProfiler.stop(); + // return r; + //}, + onBeforeRequestHandler, + { + "urls": [ + "http://*/*", + "https://*/*", + "chrome-extension://*/*" + ], + "types": [ + "main_frame", + "sub_frame", + 'stylesheet', + "script", + "image", + "object", + "xmlhttprequest", + "other" + ] + }, + [ "blocking" ] + ); + + //console.log('µMatrix > Beginning to intercept net requests at %s', (new Date()).toISOString()); + + chrome.webRequest.onBeforeSendHeaders.addListener( + onBeforeSendHeadersHandler, + { + 'urls': [ + "http://*/*", + "https://*/*" + ] + }, + ['blocking', 'requestHeaders'] + ); + + chrome.webRequest.onHeadersReceived.addListener( + onHeadersReceived, + { + 'urls': [ + "http://*/*", + "https://*/*" + ] + }, + ['blocking', 'responseHeaders'] + ); + + chrome.webRequest.onErrorOccurred.addListener( + onErrorOccurredHandler, + { + 'urls': [ + "http://*/*", + "https://*/*" + ] + } + ); +}; /******************************************************************************/ return { - blockedRootFramePrefix: 'data:text/html;base64,' + btoa(rootFrameReplacement).slice(0, 80) + blockedRootFramePrefix: 'data:text/html;base64,' + btoa(rootFrameReplacement).slice(0, 80), + start: start }; /******************************************************************************/