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. 127
      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();
/******************************************************************************/

127
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 { 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