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

Commit

Permalink
#9
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 17, 2013
1 parent 397205f commit c7820f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
10 changes: 0 additions & 10 deletions js/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ function findAndRecordCookies(pageUrl) {
if ( block ) {
addStateFromPageStats(pageStats, 'cookie', domain);
}
chrome.contentSettings.cookies.set({
primaryPattern: '*://' + domain + '/*',
secondaryPattern: '<all_urls>',
setting: block ? 'block' : 'allow'
});
// console.debug('HTTP Switchboard > findAndRecordCookies: "%s" (cookie=%O)', cookieUrl, cookie);
}
});
Expand Down Expand Up @@ -180,11 +175,6 @@ chrome.cookies.onChanged.addListener(function(changeInfo) {
if ( block ) {
addStateFromPageStats(pageStats, 'cookie', domain);
}
chrome.contentSettings.cookies.set({
primaryPattern: '*://' + domain + '/*',
secondaryPattern: '<all_urls>',
setting: block ? 'block' : 'allow'
});
// console.debug('HTTP Switchboard > chrome.cookies.onChanged: "%s" (cookie=%O)', cookieUrl, cookie);
}
});
Expand Down
9 changes: 9 additions & 0 deletions js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@

/******************************************************************************/

// rhill 20131017 > https://github.com/gorhill/httpswitchboard/issues/9:
// HTTP Switchboard relinquishes all control of cookies settings (it will
// however keep removing outbound cookies from headers, so this is equivalent
// to a recording machine which can never be played back).

chrome.contentSettings.cookies.clear({});

/******************************************************************************/

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
// Can this happen?
if ( !tab.url || !tab.url.length ) {
Expand Down
14 changes: 6 additions & 8 deletions js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function webRequestHandler(details) {

// Ignore stylesheet requests
if ( type === 'stylesheet' ) {
// console.log("HTTPSB > %s @ url=%s", details.type, details.url);
return;
}

Expand Down Expand Up @@ -144,11 +145,6 @@ function webRequestHandler(details) {
primaryPattern: '*://' + domain + '/*',
setting: blacklisted('object', domain) ? 'block' : 'allow'
});
chrome.contentSettings.cookies.set({
primaryPattern: '*://' + domain + '/*',
secondaryPattern: '<all_urls>',
setting: blacklisted('cookie', domain) ? 'block' : 'allow'
});

// when the tab is updated, we will check if page has at least one
// script tag, this takes care of inline scripting, which doesn't
Expand All @@ -163,6 +159,7 @@ function webRequestHandler(details) {
HTTPSB.allowedRequestCounters.all += 1;
HTTPSB.allowedRequestCounters[type] += 1;

// console.log("HTTPSB > %s @ url=%s", details.type, details.url);
return;
}

Expand Down Expand Up @@ -204,9 +201,7 @@ function webRequestHandler(details) {

function webHeaderRequestHandler(details) {

// ignore traffic outside tabs
// TODO: when might this happen?
// Apparently from within extensions
// Ignore traffic outside tabs
if ( details.tabId < 0 ) {
return;
}
Expand Down Expand Up @@ -237,6 +232,9 @@ function webHeaderRequestHandler(details) {
// console.debug('HTTP Switchboard > foiled attempt to send %d cookies "%s..." to %s', cookieCount, cookieValue.slice(0,40), details.url);
headers.splice(i, 1);
}
// else {
// console.log('HTTPSB > %d cookies @ %s', cookieCount, details.url);
// }
}

if ( blacklistCookie ) {
Expand Down

0 comments on commit c7820f7

Please sign in to comment.