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

Commit

Permalink
preparing for 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Dec 3, 2013
1 parent 8e99d42 commit de8574a
Show file tree
Hide file tree
Showing 23 changed files with 897 additions and 302 deletions.
6 changes: 6 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@
},


"settingsStrictBlockingInfo": {
"message": "<p><strong><a href=\"https://github.com/gorhill/httpswitchboard/wiki/%22Strict-blocking%22-illustrated\">Strict\nblocking</a></strong>,\nintroduced in <a href=\"https://github.com/gorhill/httpswitchboard/wiki/Change-log#036\">version 0.3.6</a>,\nmeans that even\nif you whitelist a specific hostname, blacklisted type of requests (<i>plugins</i>,\n<i>frames</i>, etc.) will remain blacklisted. For some users this maybe\ntoo bothersome, hence this switch.</p>\n<p><strong>Strict blocking on</strong>: blacklisted types of request (if any)\nfor a whitelisted hostname are blocked (unless you explicitly whitelist\nspecifically these types of request for the whitelisted hostname.)</p>\n<p><strong>Strict blocking off</strong>: blacklisted types of request (if any)\nfor a whitelisted hostname are allowed (unless you explicitly blacklist\nspecifically these types of request for the whitelisted hostname.)</p>",
"description": ""
},


"dummy": {
"message": "This entry must be the last one",
"description": "so we dont need to deal with comma for last entry"
Expand Down
8 changes: 7 additions & 1 deletion _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "extension name."
},
"extShortDesc": {
"message": "Simplement un clic pour interdire ou permettre n'importe quel types de requête faites par votre fureteur. Bloquez les scripts, iframes, pubs, facebook, etc.",
"message": "Un simple clic pour interdire ou permettre n'importe quel types de requête faites par votre fureteur. Bloquez les scripts, iframes, pubs, facebook, etc.",
"description": "this will in chrome web store"
},
"ruleManagerPageName": {
Expand Down Expand Up @@ -196,6 +196,12 @@
},


"settingsStrictBlockingInfo": {
"message": "<strong><a href=\"https://github.com/gorhill/httpswitchboard/wiki/%22Strict-blocking%22-illustrated\">Blocage strict</a></strong>, introduit dans la <a href=\"https://github.com/gorhill/httpswitchboard/wiki/Change-log#036\">version 0.3.6</a>, signifie que même si vous allouez un nom d'hôte spécifique, une requête restera bloquée si le type d'objet à requérir (plugins, iframes, etc) est lui-même bloqué. Pour certains utilisateurs, ce peut-être trop restrictif, d'où la possibilité de choisir la logique de blocage ici.\n<strong>Blocage strict</strong>: pour qu'une requête ne soit pas bloquée, le nom d'hôte ET le type de requête doivent être alloués.\n</strong>Blocage non strict</strong>: pour qu'une requête ne soit pas bloquée, seul le nom d'hôte doir être alloué.",
"description": ""
},


"dummy": {
"message": "This entry must be the last one",
"description": "so we dont need to deal with comma for last entry"
Expand Down
3 changes: 3 additions & 0 deletions assets/httpsb-blacklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ adgear.com # "AdGear is an online advertising technologies company base
adnxs.com # "Adnxs.com is run by AppNexus, a company that provides technology, data and analytics to help companies buy and sell online display advertising" (Ref.: http://www.theguardian.com/technology/2012/apr/23/adnxs-tracking-trackers-cookies-web-monitoring)
adobetag.com # "Adobe Announces Adobe Tag Manager for the Online Marketing Suite"
aimatch.com # "Ad Server, SAS® Intelligent Advertising for Publishers"
analytics.edgesuite.net
atedra.com # "Atedra est un réseau de publicité Internet francophone au Canada"
axf8.net # https://www.eff.org/deeplinks/2013/06/third-party-resources-nsa-leaks
betrad.com # "Evidon: Home | Online Marketing Intelligence, Web Analytics, Privacy" (which also publishes "Ghostery" add-on..)
Expand All @@ -24,6 +25,8 @@ crsspxl.com # Related to crosspixel.net
displaymarketplace.com
erovinmo.com # No info whatsoever from site itself can be found = naughty corner. Ironically spotted at "http://www.technologyreview.com/news/519336/bruce-schneier-nsa-spying-is-making-us-less-safe/" (also: http://www.mywot.com/en/scorecard/erovinmo.com)
exelator.com # "domain used by eXelate Media which is an advertising company that is part of a network of sites, cookies, and other technologies used to track you" (Ref.: http://www.donottrackplus.com/trackers/exelator.com.php)
everestjs.net # related to `everesttech.net`
everesttech.net # "search engine marketing (SEM) solutions", pixel image on the page, looks like tracking to me. Spotted @ `http://www.homedepot.ca/` (search worked fine when blocking this hostname)
eyereturn.com # "eyeReturn Marketing is the only end-to-end digital advertising platform in the market"
gigya.com # "The tools you need to connect with consumers, harness rich data, and make marketing relevant"
krxd.net # https://www.eff.org/deeplinks/2013/06/third-party-resources-nsa-leaks
Expand Down
2 changes: 2 additions & 0 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<script src="lib/publicsuffixlist.min.js"></script>

<script src="js/types.js"></script>
<script src="js/strpacker.js"></script>
<script src="js/uritools.js"></script>
<script src="js/usersettings.js"></script>
<script src="js/async.js"></script>
<script src="js/lists.js"></script>
<script src="js/background.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion info.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h2 data-i18n="statsPageWhitelistsBlacklists"></h2>
</div>


<h2 data-i18n="statsPageGeekyStats"></h2>
<h2 data-i18n="statsPageGeekyStats" id="geeky-stats"></h2>
<div>For
<select id="selectPageUrls">
<option value="All">All</option>
Expand Down Expand Up @@ -148,6 +148,7 @@ <h3 data-i18n="statsPageOverview"></h3>

<h3 data-i18n="statsPageDetailed"></h3>
<div id="requests">
<p style="font-size:small">You can change the maximum number of most recent HTTP requests to log (currently set at <span id="maxLoggedRequests"></span> per page) on the <a href="settings.html">Settings</a> page.</p>
<p><button id="refresh-requests" data-i18n="statsPageRefresh"></button></p>
<p>
Show: <input id="show-main_frame" type="checkbox" checked value="1">Pages&emsp;
Expand Down
8 changes: 2 additions & 6 deletions js/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,7 @@ function onMessageHandler(request, sender, callback) {

case 'userSettings':
if ( typeof request.name === 'string' && request.name !== '' ) {
if ( HTTPSB.userSettings[request.name] !== undefined && request.value !== undefined ) {
HTTPSB.userSettings[request.name] = request.value;
}
response = HTTPSB.userSettings[request.name];
saveUserSettings();
response = changeUserSettings(request.name, request.value);
}
break;

Expand All @@ -212,7 +208,7 @@ function onMessageHandler(request, sender, callback) {
}
}

if ( callback ) {
if ( response && callback ) {
callback(response);
}
}
Expand Down
14 changes: 10 additions & 4 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ var HTTPSB = {
displayTextSize: '13px',
popupHideBlacklisted: false,
popupCollapseDomains: false,
popupCollapseSpecificDomains: {}
popupCollapseSpecificDomains: {},
maxLoggedRequests: 250,
statsFilters: {
}
},

runtimeId: 1,
Expand Down Expand Up @@ -60,16 +63,19 @@ var HTTPSB = {

// tabs are used to redirect stats collection to a specific url stats
// structure.
pageUrlToTabId: { },
tabIdToPageUrl: { },
pageUrlToTabId: {},
tabIdToPageUrl: {},

// Power switch to disengage HTTPSB
off: false,

// page url => permission scope
temporaryScopes: null,
permanentScopes: null,

// Current entries from remote blacklists --
// just hostnames, '*/' is implied, this saves significantly on memory.
blacklistReadonly: { },
blacklistReadonly: {},

// https://github.com/gorhill/httpswitchboard/issues/19
excludeRegex: /^https?:\/\/chrome\.google\.com\/(extensions|webstore)/,
Expand Down
41 changes: 20 additions & 21 deletions js/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ var cookieHunter = {
// rhill 2013-10-19: pageStats could be nil, for example, this can
// happens if a file:// ... makes an xmlHttpRequest
if ( pageStats ) {
this.queuePageRecord[pageUrlFromPageStats(pageStats)] = pageStats;
var pageURL = pageUrlFromPageStats(pageStats);
cookieHunter.queuePageRecord[pageURL] = pageStats;
asyncJobQueue.add(
'cookieHunterPageRecord',
null,
function() { cookieHunter.processPageRecord(); },
500,
1000,
false);
}
},
Expand All @@ -51,7 +52,8 @@ var cookieHunter = {
// rhill 2013-10-19: pageStats could be nil, for example, this can
// happens if a file:// ... makes an xmlHttpRequest
if ( pageStats ) {
this.queuePageRemove[pageUrlFromPageStats(pageStats)] = pageStats;
var pageURL = pageUrlFromPageStats(pageStats);
cookieHunter.queuePageRemove[pageURL] = pageStats;
asyncJobQueue.add(
'cookieHunterPageRemove',
null,
Expand All @@ -63,40 +65,38 @@ var cookieHunter = {

// Candidate for removal
remove: function(cookie) {
this.queueRemove[cookie.url + '|' + cookie.name] = cookie;
cookieHunter.queueRemove[cookie.url + '|' + cookie.name] = cookie;
},

processPageRecord: function() {
// record cookies from a specific page
var pageUrls = Object.keys(this.queuePageRecord);
var pageUrls = Object.keys(cookieHunter.queuePageRecord);
var i = pageUrls.length;
while ( i-- ) {
this._processPageRecord(pageUrls[i]);
cookieHunter._processPageRecord(pageUrls[i]);
}
},

_processPageRecord: function(pageUrl) {
var me = this;
chrome.cookies.getAll({}, function(cookies) {
me._hunt(me.queuePageRecord[pageUrl], cookies, true);
delete me.queuePageRecord[pageUrl];
cookieHunter._hunt(cookieHunter.queuePageRecord[pageUrl], cookies, true);
delete cookieHunter.queuePageRecord[pageUrl];
});
},

processPageRemove: function() {
// erase cookies from a specific page
var pageUrls = Object.keys(this.queuePageRemove);
var pageUrls = Object.keys(cookieHunter.queuePageRemove);
var i = pageUrls.length;
while ( i-- ) {
this._processPageRemove(pageUrls[i]);
cookieHunter._processPageRemove(pageUrls[i]);
}
},

_processPageRemove: function(pageUrl) {
var me = this;
chrome.cookies.getAll({}, function(cookies) {
me._hunt(me.queuePageRemove[pageUrl], cookies, false);
delete me.queuePageRemove[pageUrl];
cookieHunter._hunt(cookieHunter.queuePageRemove[pageUrl], cookies, false);
delete cookieHunter.queuePageRemove[pageUrl];
});
},

Expand All @@ -108,7 +108,6 @@ var cookieHunter = {
if ( !httpsb.userSettings.deleteCookies ) {
return;
}
var me = this;
chrome.cookies.getAll({}, function(cookies) {
// quickProfiler.start();
var i = cookies.length;
Expand All @@ -121,7 +120,7 @@ var cookieHunter = {
cookieUrl = (cookie.secure ? 'https://' : 'http://') + domain + cookie.path;
// be mindful of https://github.com/gorhill/httpswitchboard/issues/19
if ( !httpsb.excludeRegex.test(cookieUrl) ) {
me.remove({
cookieHunter.remove({
url: cookieUrl,
domain: cookie.domain,
name: cookie.name
Expand All @@ -139,22 +138,22 @@ var cookieHunter = {
// Remove only some of the cookies which are candidate for removal:
// who knows, maybe a user has 1000s of cookies sitting in his
// browser...
var cookieKeys = Object.keys(this.queueRemove);
var cookieKeys = Object.keys(cookieHunter.queueRemove);
if ( cookieKeys.length > 50 ) {
cookieKeys = cookieKeys.sort(function(){return Math.random() < Math.random();}).splice(0, 50);
}
var cookieKey, cookie;
while ( cookieKey = cookieKeys.pop() ) {
cookie = this.queueRemove[cookieKey];
delete this.queueRemove[cookieKey];
cookie = cookieHunter.queueRemove[cookieKey];
delete cookieHunter.queueRemove[cookieKey];
// Just in case setting was changed after cookie was put in queue.
if ( !httpsb.userSettings.deleteCookies ) {
continue;
}
// Ensure cookie is not allowed on ALL current web pages: It can
// happen that a cookie is blacklisted on one web page while
// being whitelisted on another (because of per-page permissions).
if ( this._dontRemoveCookie(cookie) ) {
if ( cookieHunter._dontRemoveCookie(cookie) ) {
// console.debug('HTTP Switchboard > cookieHunter.processRemove(): Will NOT remove cookie %s/{%s}', cookie.url, cookie.name);
continue;
}
Expand Down Expand Up @@ -204,7 +203,7 @@ var cookieHunter = {
// Leave alone cookies from behind-the-scene requests if
// behind-the-scene processing is disabled.
if ( block && deleteCookies && (pageUrl !== httpsb.behindTheSceneURL || httpsb.userSettings.processBehindTheSceneRequests) ) {
this.remove({
cookieHunter.remove({
url: rootUrl + cookie.path,
domain: cookie.domain,
name: cookie.name
Expand Down
3 changes: 3 additions & 0 deletions js/httpsb.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ HTTPSB.scopePageExists = function(url) {
/******************************************************************************/

HTTPSB.evaluate = function(src, type, hostname) {
if ( this.off ) {
return 'gpt';
}
return this.temporaryScopes.evaluate(src, type, hostname);
};

Expand Down
63 changes: 50 additions & 13 deletions js/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ function requestDetails(url, type, when, blocked) {
function updateRequestData() {
var requests = [];
var pageUrls = targetUrl === 'All' ?
Object.keys(gethttpsb().pageStats) :
[targetUrl];
Object.keys(gethttpsb().pageStats) :
[targetUrl];
var iPageUrl, nPageUrls, pageUrl;
var reqKeys, iReqKey, nReqKeys, reqKey;
var pageStats, pageRequests;
var i, entry;
var pos, reqURL, reqType, entry;

nPageUrls = pageUrls.length;
for ( iPageUrl = 0; iPageUrl < nPageUrls; iPageUrl++ ) {
Expand All @@ -68,18 +68,24 @@ function updateRequestData() {
continue;
}
pageRequests = pageStats.requests;
reqKeys = Object.keys(pageRequests);
reqKeys = pageRequests.getLoggedRequests();
nReqKeys = reqKeys.length;
for ( iReqKey = 0; iReqKey < nReqKeys; iReqKey++ ) {
reqKey = reqKeys[iReqKey];
entry = pageRequests[reqKey];
i = reqKey.indexOf('#');
// Using parseFloat because of
// http://jsperf.com/performance-of-parseint
if ( !reqKey ) {
continue;
}
pos = reqKey.indexOf('#');
reqURL = reqKey.slice(0, pos);
reqType = reqKey.slice(pos + 1);
entry = pageRequests.getLoggedRequestEntry(reqURL, reqType);
if ( !entry ) {
continue;
}
requests.push(new requestDetails(
reqKey.slice(0, i),
reqURL,
entry.when,
reqKey.slice(i+1),
reqType,
entry.blocked
));
}
Expand Down Expand Up @@ -205,7 +211,8 @@ function renderStats() {
'#allowedScriptCount': allowedStats.script,
'#allowedXHRCount': allowedStats.xmlhttprequest,
'#allowedSubFrameCount': allowedStats.sub_frame,
'#allowedOtherCount': allowedStats.other
'#allowedOtherCount': allowedStats.other,
'#maxLoggedRequests': httpsb.userSettings.maxLoggedRequests
});
}

Expand Down Expand Up @@ -240,7 +247,7 @@ function renderRequestRow(row, request) {
$(cells[3]).text(request.url);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*----------------------------------------------------------------------------*/

function renderRequests() {
var table = $('#requestsTable tbody');
Expand Down Expand Up @@ -275,6 +282,27 @@ function renderRequests() {

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

function changeFilterHandler() {
// Save new state of filters in user settings
// Initialize request filters as per user settings:
// https://github.com/gorhill/httpswitchboard/issues/49
var statsFilters = gethttpsb().userSettings.statsFilters;
$('input[id^="show-"][type="checkbox"]').each(function() {
var input = $(this);
statsFilters[input.attr('id')] = !!input.prop('checked');
});

chrome.runtime.sendMessage({
what: 'userSettings',
name: 'statsFilters',
value: statsFilters
});

syncWithFilters();
}

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

// Synchronize list of net requests with filter states

function syncWithFilters() {
Expand Down Expand Up @@ -322,9 +350,18 @@ function initAll() {
$('#version').html(gethttpsb().manifest.version);
$('a:not([target])').prop('target', '_blank');

// Initialize request filters as per user settings:
// https://github.com/gorhill/httpswitchboard/issues/49
$('input[id^="show-"][type="checkbox"]').each(function() {
var statsFilters = gethttpsb().userSettings.statsFilters;
var input = $(this);
var filter = statsFilters[input.attr('id')];
input.prop('checked', filter === undefined || filter === true);
});

// Event handlers
$('#refresh-requests').on('click', renderRequests);
$('input[id^="show-"][type="checkbox"]').on('change', syncWithFilters);
$('input[id^="show-"][type="checkbox"]').on('change', changeFilterHandler);
$('#selectPageUrls').on('change', targetUrlChangeHandler);

renderTransientData(true);
Expand Down
Loading

0 comments on commit de8574a

Please sign in to comment.