Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
this fixes #306
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed May 26, 2014
1 parent e8e91db commit 42e81a1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
38 changes: 23 additions & 15 deletions js/contentscripthandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var contentScriptSummaryHandler = function(details, sender) {
}
var httpsb = HTTPSB;
var pageURL = httpsb.pageUrlFromTabId(sender.tab.id);
var pageStats = httpsb.pageStatsFromPageUrl(pageURL);
var httpsburi = httpsb.URI.set(details.locationURL);
var frameURL = httpsburi.normalizedURI();
var urls, url, r;
Expand All @@ -45,27 +46,34 @@ var contentScriptSummaryHandler = function(details, sender) {

// scripts
// https://github.com/gorhill/httpswitchboard/issues/25
urls = details.scriptSources;
for ( url in urls ) {
if ( !urls.hasOwnProperty(url) ) {
continue;
if ( pageStats && pageStats.pageScriptBlocked ) {
urls = details.scriptSources;
for ( url in urls ) {
if ( !urls.hasOwnProperty(url) ) {
continue;
}
if ( url === '{inline_script}' ) {
url = frameURL + '{inline_script}';
}
r = httpsb.filterRequest(pageURL, 'script', url);
pageStats.recordRequest('script', url, r !== false, r);
}
if ( url === '{inline_script}' ) {
url = frameURL + '{inline_script}';
}
r = httpsb.filterRequest(pageURL, 'script', url);
httpsb.recordFromPageUrl(pageURL, 'script', url, r !== false, r);
}

// TODO: as of 2014-05-26, not sure this is needed anymore, since HTTPSB
// no longer uses chrome.contentSettings API (I think that was the reason
// this code was put in).
// plugins
// https://github.com/gorhill/httpswitchboard/issues/25
urls = details.pluginSources;
for ( url in urls ) {
if ( !urls.hasOwnProperty(url) ) {
continue;
if ( pageStats ) {
urls = details.pluginSources;
for ( url in urls ) {
if ( !urls.hasOwnProperty(url) ) {
continue;
}
r = httpsb.filterRequest(pageURL, 'object', url);
pageStats.recordRequest('object', url, r !== false, r);
}
r = httpsb.filterRequest(pageURL, 'object', url);
httpsb.recordFromPageUrl(pageURL, 'object', url, r !== false, r);
}

// https://github.com/gorhill/httpswitchboard/issues/181
Expand Down
1 change: 0 additions & 1 deletion js/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ var recordPageCookie = function(pageStats, cookieKey) {
cookieLogEntryBuilder.join(''),
block
);
httpsb.requestStats.record('cookie', block);

// rhill 2013-11-21:
// https://github.com/gorhill/httpswitchboard/issues/65
Expand Down
4 changes: 4 additions & 0 deletions js/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ PageStatsEntry.prototype.recordRequest = function(type, url, block, reason) {
// Count blocked/allowed requests
this.requestStats.record(type, block);

// https://github.com/gorhill/httpswitchboard/issues/306
// If it is recorded locally, record globally
httpsb.requestStats.record(type, block);

if ( block !== false ) {
this.perLoadBlockedRequestCount++;
} else {
Expand Down
6 changes: 0 additions & 6 deletions js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ var onBeforeRootFrameRequestHandler = function(details) {

// console.debug('onBeforeRequestHandler()> block=%s "%s": %o', block, details.url, details);

// Collect global stats
httpsb.requestStats.record('main_frame', block);

// whitelisted?
if ( !block ) {
// rhill 2013-11-07: Senseless to do this for behind-the-scene requests.
Expand Down Expand Up @@ -358,9 +355,6 @@ var onBeforeRequestHandler = function(details) {
// Page stats
pageStats.recordRequest(requestType, requestURL, block, reason);

// Global stats
httpsb.requestStats.record(requestType, block);

// whitelisted?
if ( !block ) {
// console.debug('onBeforeRequestHandler()> ALLOW "%s": %o', details.url, details);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_extName__",
"short_name": "HTTPSB",
"version": "0.9.5.3",
"version": "0.9.5.4",
"description": "__MSG_extShortDesc__",
"icons": {
"16": "icon_16.png",
Expand Down

0 comments on commit 42e81a1

Please sign in to comment.