bring back `doc` req type; many little fixes

pull/2/head 0.8.0.0-alpha.11
gorhill 10 years ago
parent eab99cf26b
commit 49441de2b6

@ -143,16 +143,16 @@ tr.unused {
<button class="whatisthis"></button> <button class="whatisthis"></button>
<p class="whatisthis-expandable para" data-i18n="statsPageLogSizeHelp"></p> <p class="whatisthis-expandable para" data-i18n="statsPageLogSizeHelp"></p>
<p id="requests-filters"><button id="refresh-requests" data-i18n="statsPageRefresh"></button>&emsp;Show: <p id="requests-filters"><button id="refresh-requests" data-i18n="statsPageRefresh"></button>&emsp;Show:
<input id="show-main_frame" type="checkbox" checked value="1"><label for="show-main_frame">Pages</label> <input id="show-doc" type="checkbox" checked value="1"><label for="show-doc">Pages</label>
<input id="show-blocked" type="checkbox" checked value="1"><label for="show-blocked"><span style="color:#c00" data-i18n="statsPageBlocked">Blocked</span></label> <input id="show-blocked" type="checkbox" checked value="1"><label for="show-blocked"><span style="color:#c00" data-i18n="statsPageBlocked">Blocked</span></label>
<input id="show-allowed" type="checkbox" checked value="1"><label for="show-allowed"><span style="color:#070" data-i18n="statsPageAllowed">Allowed</span></label> <input id="show-allowed" type="checkbox" checked value="1"><label for="show-allowed"><span style="color:#070" data-i18n="statsPageAllowed">Allowed</span></label>
<input id="show-cookie" type="checkbox" checked value="1"><label for="show-cookie">Cookies</label> <input id="show-cookie" type="checkbox" checked value="1"><label for="show-cookie">Cookies</label>
<input id="show-image" type="checkbox" checked value="1"><label for="show-image">Images</label> <input id="show-image" type="checkbox" checked value="1"><label for="show-image">Images</label>
<input id="show-stylesheet" type="checkbox" checked value="1"><label for="show-stylesheet">CSS</label> <input id="show-css" type="checkbox" checked value="1"><label for="show-css">CSS</label>
<input id="show-object" type="checkbox" checked value="1"><label for="show-object">Objects</label> <input id="show-plugin" type="checkbox" checked value="1"><label for="show-plugin">Plugins</label>
<input id="show-script" type="checkbox" checked value="1"><label for="show-script">Scripts</label> <input id="show-script" type="checkbox" checked value="1"><label for="show-script">Scripts</label>
<input id="show-xmlhttprequest" type="checkbox" checked value="1"><label for="show-xmlhttprequest">XHRs</label> <input id="show-xhr" type="checkbox" checked value="1"><label for="show-xhr">XHRs</label>
<input id="show-sub_frame" type="checkbox" checked value="1"><label for="show-sub_frame">Frames</label> <input id="show-frame" type="checkbox" checked value="1"><label for="show-frame">Frames</label>
<input id="show-other" type="checkbox" checked value="1"><label for="show-other">Others</label> <input id="show-other" type="checkbox" checked value="1"><label for="show-other">Others</label>
</p> </p>
</div> </div>

@ -32,6 +32,7 @@
µm.pMatrix.setSwitch(µm.behindTheSceneScope, false); µm.pMatrix.setSwitch(µm.behindTheSceneScope, false);
µm.pMatrix.setSwitch('opera-scheme', false); µm.pMatrix.setSwitch('opera-scheme', false);
µm.pMatrix.setCell('*', '*', '*', µm.Matrix.Red); µm.pMatrix.setCell('*', '*', '*', µm.Matrix.Red);
µm.pMatrix.setCell('*', '*', 'doc', µm.Matrix.Green);
µm.pMatrix.setCell('*', '*', 'css', µm.Matrix.Green); µm.pMatrix.setCell('*', '*', 'css', µm.Matrix.Green);
µm.pMatrix.setCell('*', '*', 'image', µm.Matrix.Green); µm.pMatrix.setCell('*', '*', 'image', µm.Matrix.Green);
µm.pMatrix.setCell('*', '*', 'frame', µm.Matrix.Red); µm.pMatrix.setCell('*', '*', 'frame', µm.Matrix.Red);

@ -30,12 +30,6 @@ messaging.start('info.js');
var targetUrl = 'all'; var targetUrl = 'all';
var maxRequests = 500; var maxRequests = 500;
var cachedUserSettings = {}; var cachedUserSettings = {};
var tableFriendlyTypeNames = {
'main_frame': 'page',
'stylesheet': 'css',
'sub_frame': 'frame',
'xmlhttprequest': 'xhr'
};
/******************************************************************************/ /******************************************************************************/
@ -162,24 +156,24 @@ function renderStats() {
renderNumbers({ renderNumbers({
'#blockedAllCount': requestStats.blocked.all, '#blockedAllCount': requestStats.blocked.all,
'#blockedMainFrameCount': blockedStats.main_frame, '#blockedMainFrameCount': blockedStats.doc,
'#blockedCookieCount': blockedStats.cookie, '#blockedCookieCount': blockedStats.cookie,
'#blockedStylesheetCount': blockedStats.stylesheet, '#blockedStylesheetCount': blockedStats.css,
'#blockedImageCount': blockedStats.image, '#blockedImageCount': blockedStats.image,
'#blockedObjectCount': blockedStats.object, '#blockedObjectCount': blockedStats.plugin,
'#blockedScriptCount': blockedStats.script, '#blockedScriptCount': blockedStats.script,
'#blockedXHRCount': blockedStats.xmlhttprequest, '#blockedXHRCount': blockedStats.xhr,
'#blockedSubFrameCount': blockedStats.sub_frame, '#blockedSubFrameCount': blockedStats.frame,
'#blockedOtherCount': blockedStats.other, '#blockedOtherCount': blockedStats.other,
'#allowedAllCount': allowedStats.all, '#allowedAllCount': allowedStats.all,
'#allowedMainFrameCount': allowedStats.main_frame, '#allowedMainFrameCount': allowedStats.doc,
'#allowedCookieCount': allowedStats.cookie, '#allowedCookieCount': allowedStats.cookie,
'#allowedStylesheetCount': allowedStats.stylesheet, '#allowedStylesheetCount': allowedStats.css,
'#allowedImageCount': allowedStats.image, '#allowedImageCount': allowedStats.image,
'#allowedObjectCount': allowedStats.object, '#allowedObjectCount': allowedStats.plugin,
'#allowedScriptCount': allowedStats.script, '#allowedScriptCount': allowedStats.script,
'#allowedXHRCount': allowedStats.xmlhttprequest, '#allowedXHRCount': allowedStats.xhr,
'#allowedSubFrameCount': allowedStats.sub_frame, '#allowedSubFrameCount': allowedStats.frame,
'#allowedOtherCount': allowedStats.other '#allowedOtherCount': allowedStats.other
}); });
@ -216,8 +210,7 @@ function renderRequestRow(row, request) {
$(cells[0]).text(when.toLocaleTimeString()); $(cells[0]).text(when.toLocaleTimeString());
// request type // request type
var text = tableFriendlyTypeNames[request.type] || request.type; $(cells[1]).text(request.type);
$(cells[1]).text(text);
// Well I got back full control since not using Tempo.js, I can now // Well I got back full control since not using Tempo.js, I can now
// generate smarter hyperlinks, that is, not hyperlinking fake // generate smarter hyperlinks, that is, not hyperlinking fake

@ -58,14 +58,15 @@ Matrix.GrayIndirect = Matrix.Gray | Matrix.Indirect;
var typeBitOffsets = { var typeBitOffsets = {
'*': 0, '*': 0,
'cookie': 2, 'doc': 2,
'css': 4, 'cookie': 4,
'image': 6, 'css': 6,
'plugin': 8, 'image': 8,
'script': 10, 'plugin': 10,
'xhr': 12, 'script': 12,
'frame': 14, 'xhr': 14,
'other': 16 'frame': 16,
'other': 18
}; };
var stateToNameMap = { var stateToNameMap = {

@ -633,8 +633,9 @@ function makeMatrixMetaRow(totals) {
function computeMatrixGroupMetaStats(group) { function computeMatrixGroupMetaStats(group) {
var headers = matrixSnapshot.headers; var headers = matrixSnapshot.headers;
var i = Object.keys(headers).length var n = Object.keys(headers).length
var totals = new Array(i); var totals = new Array(n);
var i = n;
while ( i-- ) { while ( i-- ) {
totals[i] = 0; totals[i] = 0;
} }
@ -651,14 +652,9 @@ function computeMatrixGroupMetaStats(group) {
continue; continue;
} }
totals[0] += 1; totals[0] += 1;
totals[1] += row.counts[headers.cookie]; for ( i = 1; i < n; i++ ) {
totals[2] += row.counts[headers.css]; totals[i] += row.counts[i];
totals[3] += row.counts[headers.image]; }
totals[4] += row.counts[headers.plugin];
totals[5] += row.counts[headers.script];
totals[6] += row.counts[headers.xhr];
totals[7] += row.counts[headers.frame];
totals[8] += row.counts[headers.other];
} }
return totals; return totals;
} }

@ -23,13 +23,13 @@
_WebRequestStats.prototype.reset = function() { _WebRequestStats.prototype.reset = function() {
this.all = this.all =
this.main_frame = this.doc =
this.sub_frame = this.frame =
this.script = this.script =
this.stylesheet = this.css =
this.image = this.image =
this.object = this.plugin =
this.xmlhttprequest = this.xhr =
this.other = this.other =
this.cookie = 0; this.cookie = 0;
}; };

@ -85,6 +85,12 @@
var onLoaded = function(bin) { var onLoaded = function(bin) {
if ( bin.hasOwnProperty('userMatrix') ) { if ( bin.hasOwnProperty('userMatrix') ) {
µm.pMatrix.fromString(bin.userMatrix); µm.pMatrix.fromString(bin.userMatrix);
// Bring back the `doc` type, should not have removed it, it is
// quite useful.
// TODO: remove this before offical release, as everybody
// should have it in their rules at this point.
µm.pMatrix.setCell('*', '*', 'doc', µm.Matrix.Green);
µm.saveMatrix();
µm.tMatrix.assign(µm.pMatrix); µm.tMatrix.assign(µm.pMatrix);
} }
}; };

@ -249,9 +249,9 @@
// https://github.com/gorhill/httpswitchboard/issues/141 // https://github.com/gorhill/httpswitchboard/issues/141
if ( !mustReload ) { if ( !mustReload ) {
var reloadNewlyBlockedTypes = { var reloadNewlyBlockedTypes = {
'main_frame': true, 'doc': true,
'script' : true, 'script' : true,
'sub_frame': true 'frame': true
}; };
var blockRuleType; var blockRuleType;
for ( blockRule in newState ) { for ( blockRule in newState ) {

@ -177,7 +177,7 @@ var onBeforeChromeExtensionRequestHandler = function(details) {
// Is the target page still blacklisted? // Is the target page still blacklisted?
var pageURL = decodeURIComponent(matches[1]); var pageURL = decodeURIComponent(matches[1]);
var hostname = decodeURIComponent(matches[2]); var hostname = decodeURIComponent(matches[2]);
if ( µm.mustBlock(µm.scopeFromURL(pageURL), hostname, '*') ) { if ( µm.mustBlock(µm.scopeFromURL(pageURL), hostname, 'doc') ) {
return; return;
} }
@ -216,7 +216,7 @@ var onBeforeRootFrameRequestHandler = function(details) {
var requestHostname = uri.hostname; var requestHostname = uri.hostname;
var pageStats = µm.pageStatsFromTabId(tabId); var pageStats = µm.pageStatsFromTabId(tabId);
var pageURL = µm.pageUrlFromPageStats(pageStats); var pageURL = µm.pageUrlFromPageStats(pageStats);
var block = µm.evaluateURL(pageURL, requestHostname, '*') === µm.Matrix.RedDirect; var block = µm.mustBlock(pageStats.pageHostname, requestHostname, 'doc');
// console.debug('onBeforeRequestHandler()> block=%s "%s": %o', block, details.url, details); // console.debug('onBeforeRequestHandler()> block=%s "%s": %o', block, details.url, details);

@ -23,13 +23,13 @@
function _WebRequestStats() { function _WebRequestStats() {
this.all = this.all =
this.main_frame = this.doc =
this.stylesheet = this.css =
this.sub_frame = this.frame =
this.script = this.script =
this.image = this.image =
this.object = this.plugin =
this.xmlhttprequest = this.xhr =
this.other = this.other =
this.cookie = 0; this.cookie = 0;
} }

Loading…
Cancel
Save