Browse Source

this fixes #10

pull/2/head
gorhill 10 years ago
parent
commit
8653401961
  1. 2
      src/background.html
  2. 2
      src/js/httpsb.js
  3. 33
      src/js/start.js
  4. 23
      src/js/traffic.js

2
src/background.html

@ -26,8 +26,8 @@
<script src="js/storage.js"></script> <script src="js/storage.js"></script>
<script src="js/pagestats.js"></script> <script src="js/pagestats.js"></script>
<script src="js/tab.js"></script> <script src="js/tab.js"></script>
<script src="js/traffic.js"></script>
<script src="js/uritools.js"></script> <script src="js/uritools.js"></script>
<script src="js/traffic.js"></script>
<script src="js/useragent.js"></script> <script src="js/useragent.js"></script>
<script src="js/messaging-handlers.js"></script> <script src="js/messaging-handlers.js"></script>
<script src="js/start.js"></script> <script src="js/start.js"></script>

2
src/js/httpsb.js

@ -73,7 +73,7 @@
if ( '.css.eot.ttf.otf.svg.woff.woff2.'.indexOf(ext) !== -1 ) { if ( '.css.eot.ttf.otf.svg.woff.woff2.'.indexOf(ext) !== -1 ) {
return 'css'; return 'css';
} }
if ( '.ico.png.gif.jpg.jpeg.'.indexOf(ext) !== -1 ) {
if ( '.ico.png.gif.jpg.jpeg.bmp.'.indexOf(ext) !== -1 ) {
return 'image'; return 'image';
} }
return type; return type;

33
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(); µ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 // Initialize internal state with maybe already existing tabs
chrome.tabs.query({ url: '<all_urls>' }, function(tabs) { chrome.tabs.query({ url: '<all_urls>' }, function(tabs) {
@ -178,3 +172,10 @@ chrome.tabs.query({ url: '<all_urls>' }, function(tabs) {
})(); })();
/******************************************************************************/ /******************************************************************************/
// Load everything
µMatrix.load();
µMatrix.webRequest.start();
/******************************************************************************/

23
src/js/traffic.js

@ -854,7 +854,8 @@ var requestTypeNormalizer = {
/******************************************************************************/ /******************************************************************************/
chrome.webRequest.onBeforeRequest.addListener(
var start = function() {
chrome.webRequest.onBeforeRequest.addListener(
//function(details) { //function(details) {
// quickProfiler.start('onBeforeRequest'); // quickProfiler.start('onBeforeRequest');
// var r = onBeforeRequestHandler(details); // var r = onBeforeRequestHandler(details);
@ -880,11 +881,11 @@ chrome.webRequest.onBeforeRequest.addListener(
] ]
}, },
[ "blocking" ] [ "blocking" ]
);
);
//console.log('µMatrix > Beginning to intercept net requests at %s', (new Date()).toISOString());
//console.log('µMatrix > Beginning to intercept net requests at %s', (new Date()).toISOString());
chrome.webRequest.onBeforeSendHeaders.addListener(
chrome.webRequest.onBeforeSendHeaders.addListener(
onBeforeSendHeadersHandler, onBeforeSendHeadersHandler,
{ {
'urls': [ 'urls': [
@ -893,9 +894,9 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
] ]
}, },
['blocking', 'requestHeaders'] ['blocking', 'requestHeaders']
);
);
chrome.webRequest.onHeadersReceived.addListener(
chrome.webRequest.onHeadersReceived.addListener(
onHeadersReceived, onHeadersReceived,
{ {
'urls': [ 'urls': [
@ -904,9 +905,9 @@ chrome.webRequest.onHeadersReceived.addListener(
] ]
}, },
['blocking', 'responseHeaders'] ['blocking', 'responseHeaders']
);
);
chrome.webRequest.onErrorOccurred.addListener(
chrome.webRequest.onErrorOccurred.addListener(
onErrorOccurredHandler, onErrorOccurredHandler,
{ {
'urls': [ 'urls': [
@ -914,12 +915,14 @@ chrome.webRequest.onErrorOccurred.addListener(
"https://*/*" "https://*/*"
] ]
} }
);
);
};
/******************************************************************************/ /******************************************************************************/
return { return {
blockedRootFramePrefix: 'data:text/html;base64,' + btoa(rootFrameReplacement).slice(0, 80)
blockedRootFramePrefix: 'data:text/html;base64,' + btoa(rootFrameReplacement).slice(0, 80),
start: start
}; };
/******************************************************************************/ /******************************************************************************/

Loading…
Cancel
Save