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

Commit 34a237d

Browse files
committed
preparing for v0.7.3.0
1 parent a67ae47 commit 34a237d

File tree

7 files changed

+210
-144
lines changed

7 files changed

+210
-144
lines changed

info.html

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,39 +65,22 @@ <h1 data-i18n="statsPageTitle"></h1>
6565
<ul>
6666
<li>Version: <span id="version"></span> (<a href="https://github.com/gorhill/httpswitchboard/wiki/Change-log">change log</a>)
6767
<li><a href="settings.html" target="httpsb">Settings</a>
68-
<li><a href="https://github.com/gorhill/httpswitchboard/wiki/Quick-tour-%231%3A-1-of-7">Quick tour</a>
68+
<li><a href="https://github.com/gorhill/httpswitchboard/wiki">Documentation</a>
6969
<li>About <a href="https://github.com/gorhill/httpswitchboard/wiki/Permissions">permissions</a>
7070
<li><a href="https://github.com/gorhill/httpswitchboard/wiki/Credits">Credits</a>
7171
</ul>
7272
</div>
7373

74-
75-
76-
<h2 data-i18n="statsPageWhitelistsBlacklists"></h2>
77-
<div id="lists">
78-
<div style="white-space:nowrap;"> <!-- begin template 'stats' -->
74+
<h2 id="generic-stats">Generic stats</h2>
7975
<div>
80-
<a href="rulemanager.html" target="httpsb">Whitelisted hostnames</a>:<br>
81-
<a href="rulemanager.html" target="httpsb">Blacklisted hostnames</a>:
82-
</div>
83-
<div>
84-
<span id="whitelistCount"></span><br>
85-
<span id="blacklistCount"></span>
86-
</div>
87-
<div style="margin:1em 0 0 0;display:block;text-align:left">
88-
<span id="blacklistReadonlyCount">?</span> preset blacklisted hostnames from (number of distinct entries in parentheses):
89-
<ul id="remoteBlacklistsTemplate" style="display:none">
90-
<li class="remoteBlacklistDetails"><input type="checkbox" value="">&thinsp;<a href="" type="text/plain"></a> (<span>?</span>)
91-
</ul>
92-
<ul id="remoteBlacklists" style="margin:0.5em 0 0 0;padding-left:1em;color:gray;list-style-type:none">
93-
<li style="margin-top:0.5em"><button id="reloadRemoteBlacklists" disabled="true">Apply changes</button>
94-
</ul>
95-
<p style="font-size:smaller;color:gray">Obviously, more blacklist entries enabled means larger memory footprint required by the extension.</p>
96-
</div>
97-
</div> <!-- end template 'stats' -->
76+
<ul>
77+
<li><a href="https://en.wikipedia.org/wiki/HTTP_cookie">HTTP cookie</a> headers foiled: <span id="cookieHeaderFoiledCounter"></span>
78+
<li><a href="https://en.wikipedia.org/wiki/HTTP_referer">HTTP referer</a> headers foiled: <span id="refererHeaderFoiledCounter"></span>
79+
<li>Local cookies removed: <span id="cookieRemovedCounter"></span>
80+
<li><a href="http://diveintohtml5.info/storage.html">Local storages</a> emptied: <span id="localStorageRemovedCounter"></span>
81+
</ul>
9882
</div>
9983

100-
10184
<h2 data-i18n="statsPageGeekyStats" id="geeky-stats"></h2>
10285
<div>For
10386
<select id="selectPageUrls">

js/background.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var HTTPSB = {
3131
deleteUnusedSessionCookiesAfter: 60,
3232
deleteLocalStorage: false,
3333
processBehindTheSceneRequests: false,
34+
processReferer: false,
3435
strictBlocking: true,
3536
displayTextSize: '13px',
3637
popupHideBlacklisted: false,
@@ -87,6 +88,8 @@ var HTTPSB = {
8788
requestStats: new WebRequestStats(),
8889
cookieRemovedCounter: 0,
8990
localStorageRemovedCounter: 0,
91+
cookieHeaderFoiledCounter: 0,
92+
refererHeaderFoiledCounter: 0,
9093

9194
// internal state
9295
webRequestHandler: false,

js/info.js

Lines changed: 5 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -126,36 +126,6 @@ function renderNumbers(set) {
126126

127127
/******************************************************************************/
128128

129-
function renderBlacklistDetails() {
130-
// empty list first
131-
$('#remoteBlacklists .remoteBlacklistDetails').remove();
132-
133-
// then fill it
134-
var httpsb = gethttpsb();
135-
var blacklists = httpsb.remoteBlacklists;
136-
var ul = $('#remoteBlacklists');
137-
var keys = Object.keys(blacklists);
138-
var i = keys.length;
139-
var blacklist;
140-
var liTemplate = $('#remoteBlacklistsTemplate .remoteBlacklistDetails').first();
141-
var li, child;
142-
while ( i-- ) {
143-
blacklist = blacklists[keys[i]];
144-
li = liTemplate.clone();
145-
child = $('input', li);
146-
child.prop('checked', !blacklist.off);
147-
child = $('a', li);
148-
child.attr('href', keys[i]);
149-
child.text(keys[i]);
150-
child = $('span', li);
151-
child.text(!isNaN(+blacklist.entryCount) ? renderNumber(blacklist.entryCount) : '?');
152-
ul.prepend(li);
153-
}
154-
selectedRemoteBlacklistsHash = getSelectedRemoteBlacklistsHash();
155-
}
156-
157-
/******************************************************************************/
158-
159129
function renderPageUrls() {
160130
var httpsb = gethttpsb();
161131
var select = $('#selectPageUrls');
@@ -200,9 +170,10 @@ function renderStats() {
200170
var blockedStats = requestStats.blocked;
201171
var allowedStats = requestStats.allowed;
202172
renderNumbers({
203-
'#whitelistCount': httpsb.temporaryScopes.scopes['*'].white.count,
204-
'#blacklistCount': httpsb.temporaryScopes.scopes['*'].black.count,
205-
'#blacklistReadonlyCount': httpsb.blacklistReadonlyCount,
173+
'#cookieRemovedCounter': httpsb.cookieRemovedCounter,
174+
'#localStorageRemovedCounter': httpsb.localStorageRemovedCounter,
175+
'#cookieHeaderFoiledCounter': httpsb.cookieHeaderFoiledCounter,
176+
'#refererHeaderFoiledCounter': httpsb.refererHeaderFoiledCounter,
206177
'#blockedAllCount': requestStats.blocked.all,
207178
'#blockedMainFrameCount': blockedStats.main_frame,
208179
'#blockedCookieCount': blockedStats.cookie,
@@ -318,7 +289,7 @@ function changeFilterHandler() {
318289

319290
function syncWithFilters() {
320291
var blocked = ['blocked','allowed'];
321-
var type = ['main_frame','cookie','image','object','script','xmlhttprequest','sub_frame','other'];
292+
var type = ['main_frame','cookie','stylesheet','image','object','script','xmlhttprequest','sub_frame','other'];
322293
var i = blocked.length;
323294
var j;
324295
var display, selector;
@@ -357,72 +328,10 @@ function targetUrlChangeHandler() {
357328

358329
/******************************************************************************/
359330

360-
function reloadRemoteBlacklistsHandler() {
361-
var newHash = getSelectedRemoteBlacklistsHash();
362-
if ( newHash === selectedRemoteBlacklistsHash ) {
363-
return;
364-
}
365-
// Reload blacklists
366-
var switches = [];
367-
var lis = $('#remoteBlacklists .remoteBlacklistDetails');
368-
var i = lis.length;
369-
while ( i-- ) {
370-
switches.push({
371-
location: $(lis[i]).children('a').attr('href'),
372-
off: $(lis[i]).children('input').prop('checked') === false
373-
});
374-
}
375-
chrome.runtime.sendMessage({
376-
what: 'reloadPresetBlacklists',
377-
switches: switches
378-
});
379-
$('#reloadRemoteBlacklists').attr('disabled', true );
380-
}
381-
382-
/******************************************************************************/
383-
384-
// Create a hash so that we know whether the selection of preset blacklists
385-
// has changed.
386-
387-
function getSelectedRemoteBlacklistsHash() {
388-
var hash = '';
389-
var inputs = $('#remoteBlacklists .remoteBlacklistDetails > input');
390-
var i = inputs.length;
391-
while ( i-- ) {
392-
hash += $(inputs[i]).prop('checked').toString();
393-
}
394-
return hash;
395-
}
396-
397-
// This is to give a visual hint that the selection of preset blacklists has
398-
// changed and thus user needs to explicitly click the reload button.
399-
400-
function remoteBlacklistDetailsChangeHandler() {
401-
$('#reloadRemoteBlacklists').attr('disabled', getSelectedRemoteBlacklistsHash() === selectedRemoteBlacklistsHash);
402-
}
403-
404-
/******************************************************************************/
405-
406-
function onMessageHandler(request, sender) {
407-
if ( request && request.what ) {
408-
switch ( request.what ) {
409-
case 'presetBlacklistsLoaded':
410-
renderBlacklistDetails();
411-
remoteBlacklistDetailsChangeHandler();
412-
break;
413-
}
414-
}
415-
}
416-
417-
/******************************************************************************/
418-
419331
function initAll() {
420332
$('#version').html(gethttpsb().manifest.version);
421333
$('a:not([target])').prop('target', '_blank');
422334

423-
$('#reloadRemoteBlacklists').on('click', reloadRemoteBlacklistsHandler);
424-
$('#remoteBlacklists').on('change', '.remoteBlacklistDetails', remoteBlacklistDetailsChangeHandler);
425-
426335
// Initialize request filters as per user settings:
427336
// https://github.com/gorhill/httpswitchboard/issues/49
428337
$('input[id^="show-"][type="checkbox"]').each(function() {
@@ -437,12 +346,8 @@ function initAll() {
437346
$('input[id^="show-"][type="checkbox"]').on('change', changeFilterHandler);
438347
$('#selectPageUrls').on('change', targetUrlChangeHandler);
439348

440-
// To know when the preset blacklist stats change
441-
chrome.runtime.onMessage.addListener(onMessageHandler);
442-
443349
renderTransientData(true);
444350
renderRequests();
445-
renderBlacklistDetails();
446351
}
447352

448353
/******************************************************************************/

js/settings.js

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,31 @@
2525

2626
/******************************************************************************/
2727

28+
var selectedRemoteBlacklistsHash = '';
29+
30+
/******************************************************************************/
31+
2832
function gethttpsb() {
2933
return chrome.extension.getBackgroundPage().HTTPSB;
3034
}
3135

3236
/******************************************************************************/
3337

38+
function renderNumber(value) {
39+
// TODO: localization
40+
if ( +value > 1000 ) {
41+
value = value.toString();
42+
var i = value.length - 3;
43+
while ( i > 0 ) {
44+
value = value.slice(0, i) + ',' + value.slice(i);
45+
i -= 3;
46+
}
47+
}
48+
return value;
49+
}
50+
51+
/******************************************************************************/
52+
3453
function changeUserSettings(name, value) {
3554
chrome.runtime.sendMessage({
3655
what: 'userSettings',
@@ -58,6 +77,98 @@ function onChangeValueHandler(elem, setting, min, max) {
5877

5978
/******************************************************************************/
6079

80+
function renderBlacklistDetails() {
81+
// empty list first
82+
$('#remoteBlacklists .remoteBlacklistDetails').remove();
83+
84+
// then fill it
85+
var httpsb = gethttpsb();
86+
87+
$('#blacklistReadonlyCount').text(renderNumber(httpsb.blacklistReadonlyCount));
88+
89+
var blacklists = httpsb.remoteBlacklists;
90+
var ul = $('#remoteBlacklists');
91+
var keys = Object.keys(blacklists);
92+
var i = keys.length;
93+
var blacklist;
94+
var liTemplate = $('#remoteBlacklistsTemplate .remoteBlacklistDetails').first();
95+
var li, child;
96+
while ( i-- ) {
97+
blacklist = blacklists[keys[i]];
98+
li = liTemplate.clone();
99+
child = $('input', li);
100+
child.prop('checked', !blacklist.off);
101+
child = $('a', li);
102+
child.attr('href', keys[i]);
103+
child.text(keys[i]);
104+
child = $('span', li);
105+
child.text(!isNaN(+blacklist.entryCount) ? renderNumber(blacklist.entryCount) : '?');
106+
ul.prepend(li);
107+
}
108+
selectedRemoteBlacklistsHash = getSelectedRemoteBlacklistsHash();
109+
}
110+
111+
/******************************************************************************/
112+
113+
function reloadRemoteBlacklistsHandler() {
114+
var newHash = getSelectedRemoteBlacklistsHash();
115+
if ( newHash === selectedRemoteBlacklistsHash ) {
116+
return;
117+
}
118+
// Reload blacklists
119+
var switches = [];
120+
var lis = $('#remoteBlacklists .remoteBlacklistDetails');
121+
var i = lis.length;
122+
while ( i-- ) {
123+
switches.push({
124+
location: $(lis[i]).children('a').attr('href'),
125+
off: $(lis[i]).children('input').prop('checked') === false
126+
});
127+
}
128+
chrome.runtime.sendMessage({
129+
what: 'reloadPresetBlacklists',
130+
switches: switches
131+
});
132+
$('#reloadRemoteBlacklists').attr('disabled', true );
133+
}
134+
135+
/******************************************************************************/
136+
137+
// Create a hash so that we know whether the selection of preset blacklists
138+
// has changed.
139+
140+
function getSelectedRemoteBlacklistsHash() {
141+
var hash = '';
142+
var inputs = $('#remoteBlacklists .remoteBlacklistDetails > input');
143+
var i = inputs.length;
144+
while ( i-- ) {
145+
hash += $(inputs[i]).prop('checked').toString();
146+
}
147+
return hash;
148+
}
149+
150+
// This is to give a visual hint that the selection of preset blacklists has
151+
// changed and thus user needs to explicitly click the reload button.
152+
153+
function remoteBlacklistDetailsChangeHandler() {
154+
$('#reloadRemoteBlacklists').attr('disabled', getSelectedRemoteBlacklistsHash() === selectedRemoteBlacklistsHash);
155+
}
156+
157+
/******************************************************************************/
158+
159+
function onMessageHandler(request, sender) {
160+
if ( request && request.what ) {
161+
switch ( request.what ) {
162+
case 'presetBlacklistsLoaded':
163+
renderBlacklistDetails();
164+
remoteBlacklistDetailsChangeHandler();
165+
break;
166+
}
167+
}
168+
}
169+
170+
/******************************************************************************/
171+
61172
function initAll() {
62173
var httpsb = gethttpsb();
63174
var userSettings = httpsb.userSettings;
@@ -71,8 +182,7 @@ function initAll() {
71182
$('#delete-unused-session-cookies-after').val(userSettings.deleteUnusedSessionCookiesAfter);
72183
$('#delete-blacklisted-cookies').attr('checked', userSettings.deleteCookies === true);
73184
$('#delete-blacklisted-localstorage').attr('checked', userSettings.deleteLocalStorage);
74-
$('#cookie-removed-counter').html(httpsb.cookieRemovedCounter);
75-
$('#localstorage-removed-counter').html(httpsb.localStorageRemovedCounter);
185+
$('#process-referer').attr('checked', userSettings.processReferer);
76186
$('#process-behind-the-scene').attr('checked', userSettings.processBehindTheSceneRequests);
77187
$('#max-logged-requests').val(userSettings.maxLoggedRequests);
78188

@@ -87,6 +197,8 @@ function initAll() {
87197
$('#auto-whitelist-page-domain').on('change', function(){
88198
changeUserSettings('autoWhitelistPageDomain', $(this).is(':checked'));
89199
});
200+
$('#reloadRemoteBlacklists').on('click', reloadRemoteBlacklistsHandler);
201+
$('#remoteBlacklists').on('change', '.remoteBlacklistDetails', remoteBlacklistDetailsChangeHandler);
90202
$('#delete-unused-session-cookies').on('change', function(){
91203
changeUserSettings('deleteUnusedSessionCookies', $(this).is(':checked'));
92204
});
@@ -99,6 +211,9 @@ function initAll() {
99211
$('#delete-blacklisted-localstorage').on('change', function(){
100212
changeUserSettings('deleteLocalStorage', $(this).is(':checked'));
101213
});
214+
$('#process-referer').on('change', function(){
215+
changeUserSettings('processReferer', $(this).is(':checked'));
216+
});
102217
$('#process-behind-the-scene').on('change', function(){
103218
changeUserSettings('processBehindTheSceneRequests', $(this).is(':checked'));
104219
});
@@ -118,6 +233,11 @@ function initAll() {
118233
onChangeValueHandler($('#max-logged-requests'), 'maxLoggedRequests', 0, 999);
119234
window.open('','_self').close();
120235
});
236+
237+
// To know when the preset blacklist stats change
238+
chrome.runtime.onMessage.addListener(onMessageHandler);
239+
240+
renderBlacklistDetails();
121241
}
122242

123243
/******************************************************************************/

0 commit comments

Comments
 (0)