Browse Source

bring back `doc` req type; many little fixes

pull/2/head 0.8.0.0-alpha.11
gorhill 10 years ago
parent
commit
49441de2b6
  1. 10
      src/info.html
  2. 1
      src/js/httpsb.js
  3. 29
      src/js/info.js
  4. 17
      src/js/matrix.js
  5. 16
      src/js/popup.js
  6. 10
      src/js/reqstats.js
  7. 6
      src/js/storage.js
  8. 4
      src/js/tab.js
  9. 4
      src/js/traffic.js
  10. 10
      src/js/types.js

10
src/info.html

@ -143,16 +143,16 @@ tr.unused {
<button class="whatisthis"></button>
<p class="whatisthis-expandable para" data-i18n="statsPageLogSizeHelp"></p>
<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-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-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-object" type="checkbox" checked value="1"><label for="show-object">Objects</label>
<input id="show-css" type="checkbox" checked value="1"><label for="show-css">CSS</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-xmlhttprequest" type="checkbox" checked value="1"><label for="show-xmlhttprequest">XHRs</label>
<input id="show-sub_frame" type="checkbox" checked value="1"><label for="show-sub_frame">Frames</label>
<input id="show-xhr" type="checkbox" checked value="1"><label for="show-xhr">XHRs</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>
</p>
</div>

1
src/js/httpsb.js

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

29
src/js/info.js

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

17
src/js/matrix.js

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

16
src/js/popup.js

@ -633,8 +633,9 @@ function makeMatrixMetaRow(totals) {
function computeMatrixGroupMetaStats(group) {
var headers = matrixSnapshot.headers;
var i = Object.keys(headers).length
var totals = new Array(i);
var n = Object.keys(headers).length
var totals = new Array(n);
var i = n;
while ( i-- ) {
totals[i] = 0;
}
@ -651,14 +652,9 @@ function computeMatrixGroupMetaStats(group) {
continue;
}
totals[0] += 1;
totals[1] += row.counts[headers.cookie];
totals[2] += row.counts[headers.css];
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];
for ( i = 1; i < n; i++ ) {
totals[i] += row.counts[i];
}
}
return totals;
}

10
src/js/reqstats.js

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

6
src/js/storage.js

@ -85,6 +85,12 @@
var onLoaded = function(bin) {
if ( bin.hasOwnProperty('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);
}
};

4
src/js/tab.js

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

4
src/js/traffic.js

@ -177,7 +177,7 @@ var onBeforeChromeExtensionRequestHandler = function(details) {
// Is the target page still blacklisted?
var pageURL = decodeURIComponent(matches[1]);
var hostname = decodeURIComponent(matches[2]);
if ( µm.mustBlock(µm.scopeFromURL(pageURL), hostname, '*') ) {
if ( µm.mustBlock(µm.scopeFromURL(pageURL), hostname, 'doc') ) {
return;
}
@ -216,7 +216,7 @@ var onBeforeRootFrameRequestHandler = function(details) {
var requestHostname = uri.hostname;
var pageStats = µm.pageStatsFromTabId(tabId);
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);

10
src/js/types.js

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

Loading…
Cancel
Save