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

Commit fc35e41

Browse files
committed
this fixes #234
1 parent c6c8007 commit fc35e41

File tree

14 files changed

+229
-197
lines changed

14 files changed

+229
-197
lines changed

_locales/de/messages.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,20 @@
184184
"message": "No net traffic seen for this tab so far.",
185185
"description": "..."
186186
},
187+
"matrixMtxButtonTip" : {
188+
"message": "Disable/enable matrix filtering \u000a for this scope. \u000aRequests blocked through \u000a matrix filtering on this page: {{count}}.",
189+
"description": "Tool tip for matrix button: {{}} is a placeholder for number of blocked requests."
190+
},
187191
"matrixABPButtonTip" : {
188-
"message": "Requests blocked through \u000a ABP filtering on this page: {{abpCount}}.\u000a Click to turn on/off ABP \u000a filtering for this scope.",
192+
"message": "Disable/enable ABP filtering \u000a for this scope. \u000aRequests blocked through \u000a ABP filtering on this page: {{count}}.",
189193
"description": "Tool tip for ABP button: {{}} is a placeholder for number of blocked requests."
190194
},
191195
"matrixPersistButtonTip" : {
192196
"message": "Save all temporary changes \u000a for this scope.",
193197
"description": "Tool tip for the persist button"
194198
},
195199
"matrixRevertButtonTip" : {
196-
"message": "Remove temporary \u000a changes for this \u000a scope.",
200+
"message": "Remove temporary changes \u000a for this scope.",
197201
"description": "Tool tip for the revert local permission button"
198202
},
199203
"matrixRevertButtonAllTip" : {
@@ -204,10 +208,6 @@
204208
"message": "Reload the page.",
205209
"description": "Tool tip for the reload button"
206210
},
207-
"matrixPowerButton" : {
208-
"message": "Disable/enable HTTP Switchboard.",
209-
"description": "Tool tip for the 'power' button"
210-
},
211211

212212

213213
"statsPageTitle" : {

_locales/en/messages.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,20 @@
184184
"message": "No net traffic seen for this tab so far.",
185185
"description": "..."
186186
},
187+
"matrixMtxButtonTip" : {
188+
"message": "Disable/enable matrix filtering \u000a for this scope. \u000aRequests blocked through \u000a matrix filtering on this page: {{count}}.",
189+
"description": "Tool tip for matrix button: {{}} is a placeholder for number of blocked requests."
190+
},
187191
"matrixABPButtonTip" : {
188-
"message": "Requests blocked through \u000a ABP filtering on this page: {{abpCount}}.\u000a Click to turn on/off ABP \u000a filtering for this scope.",
192+
"message": "Disable/enable ABP filtering \u000a for this scope. \u000aRequests blocked through \u000a ABP filtering on this page: {{count}}.",
189193
"description": "Tool tip for ABP button: {{}} is a placeholder for number of blocked requests."
190194
},
191195
"matrixPersistButtonTip" : {
192196
"message": "Save all temporary changes \u000a for this scope.",
193197
"description": "Tool tip for the persist button"
194198
},
195199
"matrixRevertButtonTip" : {
196-
"message": "Remove temporary \u000a changes for this \u000a scope.",
200+
"message": "Remove temporary changes \u000a for this scope.",
197201
"description": "Tool tip for the revert local permission button"
198202
},
199203
"matrixRevertButtonAllTip" : {
@@ -204,10 +208,6 @@
204208
"message": "Reload the page.",
205209
"description": "Tool tip for the reload button"
206210
},
207-
"matrixPowerButton" : {
208-
"message": "Disable/enable HTTP Switchboard.",
209-
"description": "Tool tip for the 'power' button"
210-
},
211211

212212

213213
"statsPageTitle" : {

_locales/fr/messages.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@
184184
"message": "Aucune activité réseau observée pour cet onglet jusqu'à présent.",
185185
"description": "..."
186186
},
187+
"matrixMtxButtonTip" : {
188+
"message": "Cliquez pour activer/désactiver \u000a les filtres matriciels pour le contexte actuel. \u000aNombre de requêtes bloquées via \u000a les filtres matriciels: {{count}}.",
189+
"description": "Tool tip for matrix button: {{}} is a placeholder for number of blocked requests."
190+
},
187191
"matrixABPButtonTip" : {
188-
"message": "Nombre de requêtes bloquées via \u000a les filtres Adblock Plus: {{abpCount}}. \u000a Cliquez pour activer/désactiver \u000a les filtres ABP pour le contexte actuel.",
192+
"message": "Cliquez pour activer/désactiver \u000a les filtres ABP pour le contexte actuel. \u000aNombre de requêtes bloquées via \u000a les filtres Adblock Plus: {{count}}.",
189193
"description": "Tool tip for ABP button: {{}} is a placeholder for number of blocked requests."
190194
},
191195
"matrixPersistButtonTip" : {
@@ -204,10 +208,6 @@
204208
"message": "Actualiser la page.",
205209
"description": "Tool tip for the reload button"
206210
},
207-
"matrixPowerButton" : {
208-
"message": "Activer / désactiver HTTP Switchboard.",
209-
"description": "Tool tip for the 'power' button"
210-
},
211211

212212

213213
"statsPageTitle" : {

background.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<script src="js/tab.js"></script>
2626
<script src="js/traffic.js"></script>
2727
<script src="js/uritools.js"></script>
28-
<script src="js/contextmenu.js"></script>
2928
<script src="js/contentscripthandlers.js"></script>
3029
<script src="js/start.js"></script>
3130
<script src="js/install.js"></script>

css/popup.css

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ body {
2626
}
2727

2828

29+
2930
.toolbar {
3031
margin: 0;
3132
border: 0;
@@ -45,12 +46,6 @@ body {
4546
}
4647

4748

48-
body.powerOff #toolbarLeft {
49-
visibility: hidden;
50-
}
51-
52-
53-
5449

5550
body .toolbar button {
5651
margin: 0;
@@ -85,9 +80,7 @@ body.tScopeDomain .toolbar button.scopeRel:not(.disabled) {
8580
body.tScopeSite .toolbar button.scopeRel:not(.disabled) {
8681
color: #48c;
8782
}
88-
body.powerOff #toolbarLeft {
89-
visibility: hidden;
90-
}
83+
9184

9285

9386
.dropdown-menu {
@@ -200,9 +193,6 @@ button.disabled > span.badge {
200193
left: 10vw;
201194
width: 80vw;
202195
}
203-
body.powerOff #buttonPresets {
204-
visibility: hidden;
205-
}
206196
.presetInfo {
207197
margin: 0.25em 0.5em;
208198
text-align: center;
@@ -227,12 +217,6 @@ body.powerOff #buttonPresets {
227217
padding: 0 6px;
228218
font-size: 1.2em;
229219
}
230-
body #buttonPower i {
231-
color: #080;
232-
}
233-
body.powerOff #buttonPower i {
234-
color: #c00;
235-
}
236220

237221
body .toolbar button#scopeCell {
238222
margin: 0;

js/abp-filters.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,6 @@ var matchStringToFilterCollection = function(filterCollection, url, tokenBeg, to
598598
/******************************************************************************/
599599

600600
var matchString = function(url, srcDomain, dstHostname) {
601-
// rhill 2014-03-12: need to skip ABP filtering if HTTP is turned off.
602-
// https://github.com/gorhill/httpswitchboard/issues/208
603-
if ( HTTPSB.off ) {
604-
return false;
605-
}
606-
607601
//adbProfiler.countUrl();
608602
//adbProfiler.testCounter(true);
609603

js/httpsb.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -302,23 +302,13 @@ HTTPSB.permanentScopeKeyFromPageURL = function(url) {
302302
/******************************************************************************/
303303

304304
HTTPSB.evaluate = function(src, type, hostname) {
305-
// rhill 2013-12-03: When HTTPSB is disengaged, all requests are
306-
// considered being "allowed temporarily".
307-
if ( this.off ) {
308-
return 'gpt';
309-
}
310305
return this.temporaryScopes.evaluate(
311306
this.temporaryScopes.scopeKeyFromPageURL(src),
312307
type,
313308
hostname);
314309
};
315310

316311
HTTPSB.evaluateFromScopeKey = function(scopeKey, type, hostname) {
317-
// rhill 2013-12-03: When HTTPSB is disengaged, all requests are
318-
// considered being "allowed temporarily".
319-
if ( this.off ) {
320-
return 'gpt';
321-
}
322312
return this.temporaryScopes.evaluate(scopeKey, type, hostname);
323313
};
324314

@@ -386,12 +376,6 @@ HTTPSB.autoCreateTemporarySiteScope = function(pageURL) {
386376
// it will be used to filter the rules according to the hostname.
387377

388378
HTTPSB.copyTemporaryRules = function(toScopeKey, fromScopeKey, pageURL) {
389-
this.copyTemporaryWhiteRules(toScopeKey, fromScopeKey, pageURL);
390-
this.copyTemporaryGrayRules(toScopeKey, fromScopeKey);
391-
this.copyTemporaryBlackRules(toScopeKey, fromScopeKey);
392-
};
393-
394-
HTTPSB.copyTemporaryWhiteRules = function(toScopeKey, fromScopeKey, pageURL) {
395379
var toScope = this.temporaryScopeFromScopeKey(toScopeKey);
396380
var fromScope = this.temporaryScopeFromScopeKey(fromScopeKey);
397381
if ( !toScope || !fromScope ) {
@@ -407,37 +391,23 @@ HTTPSB.copyTemporaryWhiteRules = function(toScopeKey, fromScopeKey, pageURL) {
407391
}
408392
domains[httpsburi.domainFromHostname(hostname)] = true;
409393
}
410-
var whitelist = fromScope.white.list;
394+
var listKeys = [ 'white', 'black', 'gray' ];
395+
var listKey, list;
411396
var pos, ruleHostname;
412-
for ( var ruleKey in whitelist ) {
413-
if ( !whitelist.hasOwnProperty(ruleKey) ) {
414-
continue;
415-
}
416-
pos = ruleKey.indexOf('|');
417-
ruleHostname = ruleKey.slice(pos + 1);
418-
if ( ruleHostname !== '*' && !domains[httpsburi.domainFromHostname(ruleHostname)] ) {
419-
continue;
397+
while ( listKey = listKeys.pop() ) {
398+
list = fromScope[listKey].list;
399+
for ( var ruleKey in list ) {
400+
if ( list.hasOwnProperty(ruleKey) === false ) {
401+
continue;
402+
}
403+
pos = ruleKey.indexOf('|');
404+
ruleHostname = ruleKey.slice(pos + 1);
405+
if ( ruleHostname !== '*' && domains.hasOwnProperty(httpsburi.domainFromHostname(ruleHostname)) === false ) {
406+
continue;
407+
}
408+
toScope[listKey].addOne(ruleKey);
420409
}
421-
toScope.white.addOne(ruleKey);
422-
}
423-
};
424-
425-
HTTPSB.copyTemporaryGrayRules = function(toScopeKey, fromScopeKey) {
426-
var toScope = this.temporaryScopeFromScopeKey(toScopeKey);
427-
var fromScope = this.temporaryScopeFromScopeKey(fromScopeKey);
428-
if ( !toScope || !fromScope ) {
429-
return;
430-
}
431-
toScope.gray.fromList(fromScope.gray);
432-
};
433-
434-
HTTPSB.copyTemporaryBlackRules = function(toScopeKey, fromScopeKey) {
435-
var toScope = this.temporaryScopeFromScopeKey(toScopeKey);
436-
var fromScope = this.temporaryScopeFromScopeKey(fromScopeKey);
437-
if ( !toScope || !fromScope ) {
438-
return;
439410
}
440-
toScope.black.fromList(fromScope.black);
441411
};
442412

443413
/******************************************************************************/
@@ -533,11 +503,6 @@ HTTPSB.whitelistedFromScopeKey = function(scopeKey, type, hostname) {
533503

534504
HTTPSB.getTemporaryColor = function(scopeKey, type, hostname) {
535505
// console.debug('HTTP Switchboard > getTemporaryColor(%s, %s, %s) = %s', src, type, hostname, evaluate(src, type, hostname));
536-
// rhill 2013-12-03: When HTTPSB is disengaged, all requests are
537-
// considered being "allowed temporarily".
538-
if ( this.off ) {
539-
return 'gpt';
540-
}
541506
return this.temporaryScopes.evaluate(scopeKey, type, hostname);
542507
};
543508

@@ -568,10 +533,21 @@ HTTPSB.getPermanentColor = function(scopeKey, type, hostname) {
568533

569534
/******************************************************************************/
570535

536+
HTTPSB.getTemporaryMtxFiltering = function(scopeKey) {
537+
return this.temporaryScopes.getMtxFiltering(scopeKey);
538+
};
539+
540+
HTTPSB.getPermanentMtxFiltering = function(scopeKey) {
541+
return this.permanentScopes.getMtxFiltering(scopeKey);
542+
};
543+
544+
HTTPSB.toggleTemporaryMtxFiltering = function(scopeKey, state) {
545+
return this.temporaryScopes.toggleMtxFiltering(scopeKey, state);
546+
};
547+
548+
/******************************************************************************/
549+
571550
HTTPSB.getTemporaryABPFiltering = function(scopeKey) {
572-
if ( this.off ) {
573-
return false;
574-
}
575551
return this.temporaryScopes.getABPFiltering(scopeKey);
576552
};
577553

@@ -635,10 +611,10 @@ HTTPSB.getTemporaryScopeDirtyCount = function(pageURL) {
635611
return tscope.white.count +
636612
tscope.black.count +
637613
tscope.gray.count +
638-
2; // for new temporary scope and abpFiltering
614+
3; // for new temporary scope, abpFiltering, mtxFiltering
639615
}
640616
// If there is a matching scope, return difference between both
641-
return tscope.diff(pscope);
617+
return tscope.diffCount(pscope);
642618
};
643619

644620
/******************************************************************************/
@@ -705,3 +681,27 @@ HTTPSB.turnOn = function() {
705681
HTTPSB.isOpera = function() {
706682
return navigator.userAgent.indexOf(' OPR/') > 0;
707683
};
684+
685+
/******************************************************************************/
686+
687+
HTTPSB.formatCount = function(count) {
688+
if ( typeof count !== 'number' ) {
689+
return '';
690+
}
691+
var s = count.toFixed(0);
692+
if ( count >= 1000 ) {
693+
if ( count < 10000 ) {
694+
s = '>' + s.slice(0,1) + 'K';
695+
} else if ( count < 100000 ) {
696+
s = s.slice(0,2) + 'K';
697+
} else if ( count < 1000000 ) {
698+
s = s.slice(0,3) + 'K';
699+
} else if ( count < 10000000 ) {
700+
s = s.slice(0,1) + 'M';
701+
} else {
702+
s = s.slice(0,-6) + 'M';
703+
}
704+
}
705+
return s;
706+
};
707+

0 commit comments

Comments
 (0)