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

Commit

Permalink
fixes #349, #194, also code changes toward fixing #66
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jun 30, 2014
1 parent 75625a0 commit 93c8271
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 167 deletions.
8 changes: 8 additions & 0 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@
"message": "Immer wenn du Änderungen in der Matrix durchführst, die die Anzeige und /oder das Verhalten einer oder mehrerer Seiten beeinflusst, wird <i>HTTP Switchboard</i> die betroffenen Seiten automatisch neu laden, sobald du die Matrix schließt.",
"description": "..."
},
"settingsMatrixCopyGlobalRulesIntoNewScopePrompt" : {
"message": "Copy all rules from global scope into newly created local scopes.",
"description": "English: Auto delete unused temporary scopes."
},
"settingsMatrixCopyGlobalRulesIntoNewScopeHelp" : {
"message": "<p>Scopes are sandboxed, i.e. they do not share rules, and this also applies to the global scope: narrower scopes do not see rules in the global scope.</p> <p>Some users see this as an impediment, as they wish their global rules were seen by narrower scopes. This option allows to mitigate this &ldquo;shortcoming&rdquo; by forcing a copy of all global rules into a newly created narrower scope.</p> <p>Be mindful that <b>all</b> rules from the global scope are copied, including rules which could be irrelevant to the web site for which the scope was created. This could lead to &ldquo;rules bloat&rdquo; when there are many rules in the global scope.</p>",
"description": "English: ..."
},
"settingsMatrixDeleteUnusedTemporaryScopesPrompt1" : {
"message": "Automatisches Löschen unbenutzter temporärer Geltungsbereiche.",
"description": "English: Auto delete unused temporary scopes."
Expand Down
8 changes: 8 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@
"message": "Whenever you make changes in the matrix which can affect the display and/or behavior of one or more pages, <i>HTTP Switchboard</i> will reload affected pages automatically when you close the matrix.",
"description": "..."
},
"settingsMatrixCopyGlobalRulesIntoNewScopePrompt" : {
"message": "Copy all rules from global scope into newly created local scopes.",
"description": "English: Auto delete unused temporary scopes."
},
"settingsMatrixCopyGlobalRulesIntoNewScopeHelp" : {
"message": "<p>Scopes are sandboxed, i.e. they do not share rules, and this also applies to the global scope: narrower scopes do not see rules in the global scope.</p> <p>Some users see this as an impediment, as they wish their global rules were seen by narrower scopes. This option allows to mitigate this &ldquo;shortcoming&rdquo; by forcing a copy of all global rules into a newly created narrower scope.</p> <p>Be mindful that <b>all</b> rules from the global scope are copied, including rules which could be irrelevant to the web site for which the scope was created. This could lead to &ldquo;rules bloat&rdquo; when there are many rules in the global scope.</p>",
"description": "English: ..."
},
"settingsMatrixDeleteUnusedTemporaryScopesPrompt1" : {
"message": "Auto delete unused temporary scopes.",
"description": "English: Auto delete unused temporary scopes."
Expand Down
8 changes: 8 additions & 0 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@
"message": "Lorsque vous avez modifié des permissions susceptibles d'affecter l'apparence et/ou le comportement d'une page Web, cette dernière sera automatiquement rechargée par l'extension en fermant la matrice. Si l'option Aucune page est sélectionnée, vous devrez actualiser la page vous-même pour appliquer les modifications",
"description": "..."
},
"settingsMatrixCopyGlobalRulesIntoNewScopePrompt" : {
"message": "Copy all rules from global scope into newly created local scopes.",
"description": "English: Auto delete unused temporary scopes."
},
"settingsMatrixCopyGlobalRulesIntoNewScopeHelp" : {
"message": "<p>Scopes are sandboxed, i.e. they do not share rules, and this also applies to the global scope: narrower scopes do not see rules in the global scope.</p> <p>Some users see this as an impediment, as they wish their global rules were seen by narrower scopes. This option allows to mitigate this &ldquo;shortcoming&rdquo; by forcing a copy of all global rules into a newly created narrower scope.</p> <p>Be mindful that <b>all</b> rules from the global scope are copied, including rules which could be irrelevant to the web site for which the scope was created. This could lead to &ldquo;rules bloat&rdquo; when there are many rules in the global scope.</p>",
"description": "English: ..."
},
"settingsMatrixDeleteUnusedTemporaryScopesPrompt1" : {
"message": "Effacer automatiquement les règles à portée restreinte inutilisées",
"description": "English: Auto delete unused temporary scopes."
Expand Down
8 changes: 8 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@
"message": "Каждый раз, когда вы вносите изменения в матрицу, которые могут повлиять на отображение и/или поведение одной или нескольких страниц, <i>HTTP Switchboard</i> перезагрузит все затронутые страницы автоматически, после закрытия матрицы.",
"description": "..."
},
"settingsMatrixCopyGlobalRulesIntoNewScopePrompt" : {
"message": "Copy all rules from global scope into newly created local scopes.",
"description": "English: Auto delete unused temporary scopes."
},
"settingsMatrixCopyGlobalRulesIntoNewScopeHelp" : {
"message": "<p>Scopes are sandboxed, i.e. they do not share rules, and this also applies to the global scope: narrower scopes do not see rules in the global scope.</p> <p>Some users see this as an impediment, as they wish their global rules were seen by narrower scopes. This option allows to mitigate this &ldquo;shortcoming&rdquo; by forcing a copy of all global rules into a newly created narrower scope.</p> <p>Be mindful that <b>all</b> rules from the global scope are copied, including rules which could be irrelevant to the web site for which the scope was created. This could lead to &ldquo;rules bloat&rdquo; when there are many rules in the global scope.</p>",
"description": "English: ..."
},
"settingsMatrixDeleteUnusedTemporaryScopesPrompt1" : {
"message": "Автоматически удалять временные области.",
"description": "English: Auto delete unused temporary scopes."
Expand Down
8 changes: 8 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@
"message": "当您对过滤矩阵作出任何会影响一个或多个页面的显示或行为的变更时,<i>HTTP Switchboard</i> 会在您关闭过滤矩阵的显示后,自动重载受影响的页面。",
"description": "..."
},
"settingsMatrixCopyGlobalRulesIntoNewScopePrompt" : {
"message": "Copy all rules from global scope into newly created local scopes.",
"description": "English: Auto delete unused temporary scopes."
},
"settingsMatrixCopyGlobalRulesIntoNewScopeHelp" : {
"message": "<p>Scopes are sandboxed, i.e. they do not share rules, and this also applies to the global scope: narrower scopes do not see rules in the global scope.</p> <p>Some users see this as an impediment, as they wish their global rules were seen by narrower scopes. This option allows to mitigate this &ldquo;shortcoming&rdquo; by forcing a copy of all global rules into a newly created narrower scope.</p> <p>Be mindful that <b>all</b> rules from the global scope are copied, including rules which could be irrelevant to the web site for which the scope was created. This could lead to &ldquo;rules bloat&rdquo; when there are many rules in the global scope.</p>",
"description": "English: ..."
},
"settingsMatrixDeleteUnusedTemporaryScopesPrompt1" : {
"message": "自动删除未使用的临时作用域。",
"description": "English: Auto delete unused temporary scopes."
Expand Down
52 changes: 23 additions & 29 deletions css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ body.powerOff .matrix .g3Meta.g3Collapsed ~ .matRow.ro {
color: white;
background-color: #080;
}
.rpt {
.rit,.rgt {
color: black;
background-color: #f8d0d0;
}
.gpt {
.git,.ggt {
color: black;
background-color: #d0f0d0;
}
Expand All @@ -437,16 +437,6 @@ body.powerOff .matrix .g3Meta.g3Collapsed ~ .matRow.ro {
background-repeat: no-repeat;
background-position: -1px -1px;
}
.matCell.rpp {
background-image: url('/img/permanent-black-small.png');
background-repeat: no-repeat;
background-position: -1px -1px;
}
.matCell.gpp {
background-image: url('/img/permanent-white-small.png');
background-repeat: no-repeat;
background-position: -1px -1px;
}

/* Cell coloring for color blind-friendly (hopefully) */
body.colorblind .rdt {
Expand All @@ -457,11 +447,13 @@ body.colorblind .gdt {
color: black;
background-color: #fff;
}
body.colorblind .rpt {
body.colorblind .rit,
body.colorblind .rgt {
color: white;
background-color: #555;
}
body.colorblind .gpt {
body.colorblind .git,
body.colorblind .ggt {
color: black;
background-color: #ddd;
}
Expand All @@ -471,13 +463,7 @@ body.colorblind .matCell.rdp {
body.colorblind .matCell.gdp {
background-image: url('/img/permanent-white-small-cb.png');
}
body.colorblind .matCell.rpp {
background-image: url('/img/permanent-black-small-cb.png');
}
body.colorblind .matCell.gpp {
background-image: url('/img/permanent-white-small-cb.png');
}



.matRow.rw .matCell {
cursor: pointer;
Expand Down Expand Up @@ -521,19 +507,23 @@ body.powerOff .matRow.rw .matCell {
body.powerOff #whitelist, body.powerOff #blacklist {
display: none;
}
.rw .matCell.rpt #whitelist:hover {
.rw .matCell.rit #whitelist:hover,
.rw .matCell.rgt #whitelist:hover {
background-color: #080;
opacity: 0.25;
}
body.colorblind .rw .matCell.rpt #whitelist:hover {
body.colorblind .rw .matCell.rit #whitelist:hover,
body.colorblind .rw .matCell.rgt #whitelist:hover {
background-color: #fff;
opacity: 0.6;
}
.rw .matCell.gpt #whitelist:hover {
.rw .matCell.git #whitelist:hover,
.rw .matCell.ggt #whitelist:hover {
background-color: #080;
opacity: 0.25;
}
body.colorblind .rw .matCell.gpt #whitelist:hover {
body.colorblind .rw .matCell.git #whitelist:hover,
body.colorblind .rw .matCell.ggt #whitelist:hover {
background-color: #fff;
opacity: 0.6;
}
Expand All @@ -543,19 +533,23 @@ body.colorblind .rw .matCell.gpt #whitelist:hover {
.matCell.gdt #whitelist:hover {
background-color: transparent;
}
.rw .matCell.rpt #blacklist:hover {
.rw .matCell.rit #blacklist:hover,
.rw .matCell.rgt #blacklist:hover {
background-color: #c00;
opacity: 0.25;
}
body.colorblind .rw .matCell.rpt #blacklist:hover {
body.colorblind .rw .matCell.rit #blacklist:hover,
body.colorblind .rw .matCell.rgt #blacklist:hover {
background-color: #000;
opacity: 0.4;
}
.rw .matCell.gpt #blacklist:hover {
.rw .matCell.git #blacklist:hover,
.rw .matCell.ggt #blacklist:hover {
background-color: #c00;
opacity: 0.25;
}
body.colorblind .rw .matCell.gpt #blacklist:hover {
body.colorblind .rw .matCell.git #blacklist:hover,
body.colorblind .rw .matCell.ggt #blacklist:hover {
background-color: #000;
opacity: 0.4;
}
Expand Down
1 change: 1 addition & 0 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ return {
autoCreateScope: '',
clearBrowserCache: true,
clearBrowserCacheAfter: 60,
copyGlobalScopeIntoNewScope: false,
colorBlindFriendly: false,
deleteCookies: false,
deleteUnusedTemporaryScopes: false,
Expand Down
66 changes: 37 additions & 29 deletions js/httpsb.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,26 @@ HTTPSB.createPermanentGlobalScope = function(url) {

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

HTTPSB.createTemporaryDomainScope = function(url) {
HTTPSB.createTemporaryDomainScope = function(url, preserveRules) {
// Already created?
var scopeKey = this.domainScopeKeyFromURL(url);
var scope = this.temporaryScopes.scopes[scopeKey];
var copyRules = !scope || scope.off;
if ( !scope ) {
scope = new PermissionScope();
scope.whitelist('main_frame', '*');
this.temporaryScopes.scopes[scopeKey] = scope;
this.copyTemporaryRules(scopeKey, this.globalScopeKey(), url);
} else if ( scope.off ) {
if ( !preserveRules ) {
scope.removeAllRules();
}
scope.off = false;
}

if ( copyRules ) {
this.copyTemporaryRules(scopeKey, this.globalScopeKey());
}

// Remove potentially occulting site scope.
scopeKey = this.siteScopeKeyFromURL(url);
this.removeTemporaryScopeFromScopeKey(scopeKey, true);
Expand All @@ -276,19 +283,24 @@ HTTPSB.createPermanentDomainScope = function(url) {

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

HTTPSB.createTemporarySiteScope = function(url) {
// Already created?
HTTPSB.createTemporarySiteScope = function(url, preserveRules) {
var scopeKey = this.siteScopeKeyFromURL(url);
var scope = this.temporaryScopes.scopes[scopeKey];
var copyRules = !scope || scope.off;
if ( !scope ) {
scope = new PermissionScope();
scope.whitelist('main_frame', '*');
this.temporaryScopes.scopes[scopeKey] = scope;
this.copyTemporaryRules(scopeKey, this.globalScopeKey(), url);
this.copyTemporaryRules(scopeKey, this.domainScopeKeyFromURL(url), url);
} else {
} else if ( scope.off ) {
if ( !preserveRules ) {
scope.removeAllRules();
}
scope.off = false;
}
if ( copyRules ) {
this.copyTemporaryRules(scopeKey, this.globalScopeKey());
this.copyTemporaryRules(scopeKey, this.domainScopeKeyFromURL(url));
}
};

HTTPSB.createPermanentSiteScope = function(url) {
Expand Down Expand Up @@ -480,37 +492,32 @@ HTTPSB.autoCreateTemporaryScope = function(pageURL) {
// Copy rules from another scope. If a pageURL is provided,
// it will be used to filter the rules according to the hostname.

HTTPSB.copyTemporaryRules = function(toScopeKey, fromScopeKey, pageURL) {
HTTPSB.copyTemporaryRules = function(toScopeKey, fromScopeKey) {
var toScope = this.temporaryScopeFromScopeKey(toScopeKey);
var fromScope = this.temporaryScopeFromScopeKey(fromScopeKey);
if ( !toScope || !fromScope ) {
return;
}
var httpsburi = this.URI;
var pageStats = this.pageStatsFromPageUrl(pageURL);
var hostnames = pageStats ? pageStats.domains : {};
var domains = {};
for ( var hostname in hostnames ) {
if ( !hostnames.hasOwnProperty(hostname) ) {
continue;
}
domains[httpsburi.domainFromHostname(hostname)] = true;
// Copy all rules
if ( this.userSettings.copyGlobalScopeIntoNewScope ) {
toScope.white.add(fromScope.white);
toScope.black.add(fromScope.black);
toScope.gray.add(fromScope.gray);
return;
}
var listKeys = [ 'white', 'black', 'gray' ];
var listKey, list;
var pos, ruleHostname;
// Copy generic rules only
var listKeys = [ 'white', 'black' ];
var listKey, fromList, rules;
while ( listKey = listKeys.pop() ) {
list = fromScope[listKey].list;
for ( var ruleKey in list ) {
if ( list.hasOwnProperty(ruleKey) === false ) {
fromList = fromScope[listKey];
rules = fromList.list;
for ( var ruleKey in rules ) {
if ( rules.hasOwnProperty(ruleKey) === false ) {
continue;
}
pos = ruleKey.indexOf('|');
ruleHostname = ruleKey.slice(pos + 1);
if ( ruleHostname !== '*' && domains.hasOwnProperty(httpsburi.domainFromHostname(ruleHostname)) === false ) {
continue;
if ( fromList.hostnameFromRuleKey(ruleKey) === '*' ) {
toScope[listKey].addOne(ruleKey);
}
toScope[listKey].addOne(ruleKey);
}
}
};
Expand Down Expand Up @@ -539,7 +546,8 @@ HTTPSB.autoWhitelistTemporarilyPageDomain = function(pageURL) {
var domain = this.URI.domainFromURI(pageURL);
// 'rp' as in 'red pale', i.e. graylisted-blocked:
// Autowhitelist only if the domain is graylisted and blocked.
if ( this.evaluateFromScopeKey(scopeKey, '*', domain).slice(0, 2) === 'rp' ) {
var status = this.evaluateFromScopeKey(scopeKey, '*', domain).slice(0, 2);
if ( status === 'ri' || status === 'rg' ) {
// console.log('HTTPSB> autoWhitelistTemporarilyPageDomain("%s")', pageURL);
this.whitelistTemporarily(scopeKey, '*', domain);
return true;
Expand Down
Loading

0 comments on commit 93c8271

Please sign in to comment.