mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-06-01 18:10:17 +12:00
this fixes #205
This commit is contained in:
parent
9aebda7913
commit
05d8c51580
|
@ -1086,9 +1086,14 @@ var httpObserver = {
|
|||
11: 'xmlhttprequest',
|
||||
12: 'object',
|
||||
14: 'font',
|
||||
15: 'media',
|
||||
16: 'websocket',
|
||||
21: 'image'
|
||||
},
|
||||
mimeTypeMap: {
|
||||
'audio': 15,
|
||||
'video': 15
|
||||
},
|
||||
|
||||
get componentRegistrar() {
|
||||
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
|
@ -1260,6 +1265,18 @@ var httpObserver = {
|
|||
return vAPI.noTabId;
|
||||
},
|
||||
|
||||
rawtypeFromContentType: function(channel) {
|
||||
var mime = channel.contentType;
|
||||
if ( !mime ) {
|
||||
return 0;
|
||||
}
|
||||
var pos = mime.indexOf('/');
|
||||
if ( pos === -1 ) {
|
||||
pos = mime.length;
|
||||
}
|
||||
return this.mimeTypeMap[mime.slice(0, pos)] || 0;
|
||||
},
|
||||
|
||||
observe: function(channel, topic) {
|
||||
if ( channel instanceof Ci.nsIHttpChannel === false ) {
|
||||
return;
|
||||
|
|
|
@ -452,17 +452,25 @@ var evaluateURLs = function(tabId, requests) {
|
|||
|
||||
//console.debug('messaging.js/contentscript-end.js: processing %d requests', requests.length);
|
||||
|
||||
var pageStore = µm.pageStoreFromTabId(tabId);
|
||||
var µmuri = µm.URI;
|
||||
var typeMap = tagNameToRequestTypeMap;
|
||||
var request;
|
||||
var request, type;
|
||||
var i = requests.length;
|
||||
while ( i-- ) {
|
||||
request = requests[i];
|
||||
type = typeMap[request.tagName];
|
||||
request.blocked = µm.mustBlock(
|
||||
rootHostname,
|
||||
µmuri.hostnameFromURI(request.url),
|
||||
typeMap[request.tagName]
|
||||
type
|
||||
);
|
||||
// https://github.com/gorhill/uMatrix/issues/205
|
||||
// If blocked, the URL must be recorded by the page store, so as to ensure
|
||||
// they are properly reflected in the matrix.
|
||||
if ( request.blocked && pageStore ) {
|
||||
pageStore.recordRequest(type, request.url, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ( collapse ) {
|
||||
|
|
|
@ -373,6 +373,10 @@ PageStore.prototype.dispose = function() {
|
|||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.recordRequest = function(type, url, block) {
|
||||
if ( !this.requests.createEntryIfNotExists(url, type, block) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Count blocked/allowed requests
|
||||
this.requestStats.record(type, block);
|
||||
|
||||
|
@ -387,10 +391,6 @@ PageStore.prototype.recordRequest = function(type, url, block) {
|
|||
this.perLoadAllowedRequestCount++;
|
||||
}
|
||||
|
||||
if ( !this.requests.createEntryIfNotExists(url, type, block) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var hostname = µm.URI.hostnameFromURI(url);
|
||||
|
||||
this.distinctRequestCount++;
|
||||
|
|
Loading…
Reference in a new issue