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

Commit

Permalink
this fixes #115: ability to create ubiquitous whitelist rules
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 4, 2014
1 parent 56721ab commit 1c9eadb
Show file tree
Hide file tree
Showing 11 changed files with 616 additions and 301 deletions.
58 changes: 53 additions & 5 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
"description": ""
},
"settingsStrictBlockingInfo": {
"message": "<p><strong><a href=\"https://github.com/gorhill/httpswitchboard/wiki/%22Strict-blocking%22-illustrated\">Striktes\nBlockieren</a></strong>,\neingeführt in <a href=\"https://github.com/gorhill/httpswitchboard/wiki/Change-log#036\">version 0.3.6</a>,\nbedeutet: Selbst\nwenn du einen spezifischen Hostnamen auf die Whitelist setzt, bleiben die Arten von Anfragen, die standardmäßig blockiert sind (<i>Plugins</i>,\n<i>Frames</i>, etc.), weiterhin auf der Blacklist. Für einige Benutzer ist das möglicherweise\nzu lästig, daher dieser Schalter.</p>\n<p><strong>Striktes Blockieren an</strong>: blockierte Arten von Anfragen (falls vorhanden)\nfür einen Hostnamen auf der Whitelist bleiben weiterhin auf der Blacklist (sofern du diese Arten von Anfragen für diesen Hostnamen nicht ausdrücklich erlaubst.)</p>\n<p><strong>Striktes Blockieren aus</strong>: blockierte Arten von Anfragen (falls vorhanden)\nfür einen Hostnamen auf der Whitelist sind erlaubt (sofern du diese Arten von Anfragen für diesen Hostnamen nicht ausdrücklich verbietest.)</p>",
"message": "<p><strong><a href=\"https://github.com/gorhill/httpswitchboard/wiki/%22Strict-blocking%22-illustrated\">Striktes\nBlockieren</a></strong>,\neingeführt in <a href=\"https://github.com/gorhill/httpswitchboard/wiki/Change-log-0.0-to-0.5#036\">version 0.3.6</a>,\nbedeutet: Selbst\nwenn du einen spezifischen Hostnamen auf die Whitelist setzt, bleiben die Arten von Anfragen, die standardmäßig blockiert sind (<i>Plugins</i>,\n<i>Frames</i>, etc.), weiterhin auf der Blacklist. Für einige Benutzer ist das möglicherweise\nzu lästig, daher dieser Schalter.</p>\n<p><strong>Striktes Blockieren an</strong>: blockierte Arten von Anfragen (falls vorhanden)\nfür einen Hostnamen auf der Whitelist bleiben weiterhin auf der Blacklist (sofern du diese Arten von Anfragen für diesen Hostnamen nicht ausdrücklich erlaubst.)</p>\n<p><strong>Striktes Blockieren aus</strong>: blockierte Arten von Anfragen (falls vorhanden)\nfür einen Hostnamen auf der Whitelist sind erlaubt (sofern du diese Arten von Anfragen für diesen Hostnamen nicht ausdrücklich verbietest.)</p>",
"description": "To help user understand the purpose of strict blocking"
},
"settingsAutoCreateSiteScopePrompt": {
Expand Down Expand Up @@ -386,13 +386,61 @@
},


"ubiquitousWhatIsThisHeader" : {
"message": "What is this?",
"description": "English: What is this?"
},
"ubiquitousWhatIsThisPrompt" : {
"message": "&ldquo;Ubiquitous rules&rdquo; are rules which applies everywhere, i.e. in all scopes.",
"description": "English: &ldquo;Ubiquitous rules&rdquo; are rules which applies everywhere, i.e. in all scopes."
},
"ubiquitousListsOfBlockedHostsPrompt1" : {
"message": "All lists of blocked hosts are loaded as ubiquitous rules, hence these hosts are blacklisted in all scopes.",
"description": "English: All lists of blocked hosts are loaded as ubiquitous rules, hence these hosts are blacklisted in all scopes."
},
"ubiquitousListsOfBlockedHostsPrompt2" : {
"message": "{{ubiquitousBlacklistCount}} distinct blocked hostnames from:",
"description": "English: {{ubiquitousBlacklistCount}} distinct blocked hostnames from:"
},
"ubiquitousParseAllABPFiltersPrompt1" : {
"message": "Parse and enforce Adblock+ complex filters (beta).",
"description": "English: Parse and enforce Adblock+ complex filters (beta)."
},
"ubiquitousParseAllABPFiltersPrompt2" : {
"message": "{{abpFilterCount}} complex filters used.",
"description": "English: Parse and enforce Adblock+ complex filters (beta)."
},
"ubiquitousParseAllABPFiltersInfo" : {
"message": "<p>Normally, <i>HTTP Switchboard</i> will extract from <i>Adblock Plus</i>-compatible filter lists <b>only</b> those filters which are used to block an entire domain (example: &ldquo;<b>||a.ucoz.net^</b>&rdquo;).</p><p>This option enables the parsing and enforcing of finer-grained <i>Adblock Plus</i> filters (example: &ldquo;<b>/adwords-conversion-tracking.</b>&rdquo;). These complex filters are incompatible with the matrix, and thus are only used internally to evaluate whether a net request should be blocked: they have no user interface counterpart.</p><p>Even if this option is enabled, <i>Adblock Plus</i> filters used for <a href=\"https://adblockplus.org/en/filters#elemhide\">element hiding</a> are completely ignored.</p><p>Memory usage requirement is higher when this option is enabled.</p>",
"description": "English: ..."
},
"ubiquitousListsOfBlockedHostsHeader" : {
"message": "Lists of blocked hosts",
"description": "header of ubiquitous lists of blocked hosts section"
"description": "English: Lists of blocked hosts"
},
"userUbiquitousBlacklistHeader" : {
"message": "Your blacklisted hosts",
"description": "English: Your blacklisted hosts"
},
"userUbiquitousWhitelistHeader" : {
"message": "Your whitelisted hosts",
"description": "English: Your whitelisted hosts"
},
"ubiquitousApplyChanges" : {
"message": "Apply changes",
"description": "English: Apply changes"
},
"ubiquitousFormatHint" : {
"message": "One hostname per line. Lines prefixed with &lsquo;#&rsquo; will be ignored.",
"description": "English: One hostname per line. Line prefixed with &lsquo;#&rsquo; will be ignored."
},
"ubiquitousImport" : {
"message": "Import and append",
"description": "English: Import and append"
},
"ubiquitousUserBlockedHostsHeader" : {
"message": "Your list of blocked hosts",
"description": "header of user's list of blocked hosts section"
"ubiquitousExport" : {
"message": "Export",
"description": "English: Export"
},


Expand Down
58 changes: 53 additions & 5 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
"description": ""
},
"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>",
"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-0.0-to-0.5#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": "To help user understand the purpose of strict blocking"
},
"settingsAutoCreateSiteScopePrompt": {
Expand Down Expand Up @@ -382,13 +382,61 @@
},


"ubiquitousWhatIsThisHeader" : {
"message": "What is this?",
"description": "English: What is this?"
},
"ubiquitousWhatIsThisPrompt" : {
"message": "&ldquo;Ubiquitous rules&rdquo; are rules which applies everywhere, i.e. in all scopes.",
"description": "English: &ldquo;Ubiquitous rules&rdquo; are rules which applies everywhere, i.e. in all scopes."
},
"ubiquitousListsOfBlockedHostsPrompt1" : {
"message": "All lists of blocked hosts are loaded as ubiquitous rules, hence these hosts are blacklisted in all scopes.",
"description": "English: All lists of blocked hosts are loaded as ubiquitous rules, hence these hosts are blacklisted in all scopes."
},
"ubiquitousListsOfBlockedHostsPrompt2" : {
"message": "{{ubiquitousBlacklistCount}} distinct blocked hostnames from:",
"description": "English: {{ubiquitousBlacklistCount}} distinct blocked hostnames from:"
},
"ubiquitousParseAllABPFiltersPrompt1" : {
"message": "Parse and enforce Adblock+ complex filters (beta).",
"description": "English: Parse and enforce Adblock+ complex filters (beta)."
},
"ubiquitousParseAllABPFiltersPrompt2" : {
"message": "{{abpFilterCount}} complex filters used.",
"description": "English: Parse and enforce Adblock+ complex filters (beta)."
},
"ubiquitousParseAllABPFiltersInfo" : {
"message": "<p>Normally, <i>HTTP Switchboard</i> will extract from <i>Adblock Plus</i>-compatible filter lists <b>only</b> those filters which are used to block an entire domain (example: &ldquo;<b>||a.ucoz.net^</b>&rdquo;).</p><p>This option enables the parsing and enforcing of finer-grained <i>Adblock Plus</i> filters (example: &ldquo;<b>/adwords-conversion-tracking.</b>&rdquo;). These complex filters are incompatible with the matrix, and thus are only used internally to evaluate whether a net request should be blocked: they have no user interface counterpart.</p><p>Even if this option is enabled, <i>Adblock Plus</i> filters used for <a href=\"https://adblockplus.org/en/filters#elemhide\">element hiding</a> are completely ignored.</p><p>Memory usage requirement is higher when this option is enabled.</p>",
"description": "English: ..."
},
"ubiquitousListsOfBlockedHostsHeader" : {
"message": "Lists of blocked hosts",
"description": "header of ubiquitous lists of blocked hosts section"
"description": "English: Lists of blocked hosts"
},
"userUbiquitousBlacklistHeader" : {
"message": "Your blacklisted hosts",
"description": "English: Your blacklisted hosts"
},
"userUbiquitousWhitelistHeader" : {
"message": "Your whitelisted hosts",
"description": "English: Your whitelisted hosts"
},
"ubiquitousApplyChanges" : {
"message": "Apply changes",
"description": "English: Apply changes"
},
"ubiquitousFormatHint" : {
"message": "One hostname per line. Lines prefixed with &lsquo;#&rsquo; will be ignored.",
"description": "English: One hostname per line. Line prefixed with &lsquo;#&rsquo; will be ignored."
},
"ubiquitousImport" : {
"message": "Import and append",
"description": "English: Import and append"
},
"ubiquitousUserBlockedHostsHeader" : {
"message": "Your list of blocked hosts",
"description": "header of user's list of blocked hosts section"
"ubiquitousExport" : {
"message": "Export",
"description": "English: Export"
},


Expand Down
56 changes: 52 additions & 4 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
"description": ""
},
"settingsStrictBlockingInfo": {
"message": "Introduit dans la <a href=\"https://github.com/gorhill/httpswitchboard/wiki/Change-log#036\">version 0.3.6</a>, le <strong><a href=\"https://github.com/gorhill/httpswitchboard/wiki/%22Strict-blocking%22-illustrated\">Blocage strict</a></strong> 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 en question (plugins, iframes, etc) est lui-même bloqué; en d'autres termes, le blocage du type d'objet prime sur le domaine concerné. Le choix vous est proposé de l'activer ou non, car cela peut se montrer trop restrictif aux yeux de certains utilisateurs. Si l'option est activée, la requête est autorisée à condition que les nom d'hôte ET le type de requête soient autorisés. Si l'option n'est pas cochée, le nom d'hôte alloué suffit à autoriser la requête.",
"message": "Introduit dans la <a href=\"https://github.com/gorhill/httpswitchboard/wiki/Change-log-0.0-to-0.5#036\">version 0.3.6</a>, le <strong><a href=\"https://github.com/gorhill/httpswitchboard/wiki/%22Strict-blocking%22-illustrated\">Blocage strict</a></strong> 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 en question (plugins, iframes, etc) est lui-même bloqué; en d'autres termes, le blocage du type d'objet prime sur le domaine concerné. Le choix vous est proposé de l'activer ou non, car cela peut se montrer trop restrictif aux yeux de certains utilisateurs. Si l'option est activée, la requête est autorisée à condition que les nom d'hôte ET le type de requête soient autorisés. Si l'option n'est pas cochée, le nom d'hôte alloué suffit à autoriser la requête.",
"description": "To help user understand the purpose of strict blocking"
},
"settingsAutoCreateSiteScopePrompt": {
Expand Down Expand Up @@ -382,13 +382,61 @@
},


"ubiquitousWhatIsThisHeader" : {
"message": "De quoi s'agit-il?",
"description": "English: What is this?"
},
"ubiquitousWhatIsThisPrompt" : {
"message": "Les &ldquo;règles universelles&rdquo; sont des règles qui s'appliquent dans tous les contextes.",
"description": "English: &ldquo;Ubiquitous rules&rdquo; are rules which applies everywhere, i.e. in all scopes."
},
"ubiquitousListsOfBlockedHostsPrompt1" : {
"message": "Tous les hôtes des listes prédéfinies sont traités comme étant des règles universelles.",
"description": "English: All lists of blocked hosts are loaded as ubiquitous rules, hence these hosts are blacklisted in all scopes."
},
"ubiquitousListsOfBlockedHostsPrompt2" : {
"message": "{{ubiquitousBlacklistCount}} hôtes à bloquer:",
"description": "English: {{ubiquitousBlacklistCount}} distinct blocked hostnames from:"
},
"ubiquitousParseAllABPFiltersPrompt1" : {
"message": "Lire et appliquer les filtres ABP complexes (beta).",
"description": "English: Parse and enforce Adblock+ complex filters (beta)."
},
"ubiquitousParseAllABPFiltersPrompt2" : {
"message": "{{abpFilterCount}} filtres ABP complexes utilisés.",
"description": "English: Parse and enforce Adblock+ complex filters (beta)."
},
"ubiquitousParseAllABPFiltersInfo" : {
"message": "<p>Normally, <i>HTTP Switchboard</i> will extract from <i>Adblock Plus</i>-compatible filter lists <b>only</b> those filters which are used to block an entire domain (example: &ldquo;<b>||a.ucoz.net^</b>&rdquo;).</p><p>This option enables the parsing and enforcing of finer-grained <i>Adblock Plus</i> filters (example: &ldquo;<b>/adwords-conversion-tracking.</b>&rdquo;). These complex filters are incompatible with the matrix, and thus are only used internally to evaluate whether a net request should be blocked: they have no user interface counterpart.</p><p>Even if this option is enabled, <i>Adblock Plus</i> filters used for <a href=\"https://adblockplus.org/en/filters#elemhide\">element hiding</a> are completely ignored.</p><p>Memory usage requirement is higher when this option is enabled.</p>",
"description": "English: ..."
},
"ubiquitousListsOfBlockedHostsHeader" : {
"message": "Listes d'hôtes à bloquer",
"description": "header of ubiquitous lists of blocked hosts section"
"description": "English: Lists of blocked hosts"
},
"ubiquitousUserBlockedHostsHeader" : {
"userUbiquitousBlacklistHeader" : {
"message": "Votre liste d'hôtes à bloquer",
"description": "header of user's list of blocked hosts section"
"description": "English: Your blacklisted hosts"
},
"userUbiquitousWhitelistHeader" : {
"message": "Votre liste d'hôtes à allouer",
"description": "English: Your whitelisted hosts"
},
"ubiquitousApplyChanges" : {
"message": "Appliquer",
"description": "English: Apply changes"
},
"ubiquitousFormatHint" : {
"message": "Un nom d'hôte par ligne. Les lignes débutant par &lsquo;#&rsquo; seront ignorées.",
"description": "English: One hostname per line. Line prefixed with &lsquo;#&rsquo; will be ignored."
},
"ubiquitousImport" : {
"message": "Importer",
"description": "English: Import and append"
},
"ubiquitousExport" : {
"message": "Exporter",
"description": "English: Export"
},


Expand Down
8 changes: 0 additions & 8 deletions js/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,6 @@ function onMessageHandler(request, sender, callback) {
HTTPSB.onLocalAssetUpdated(request);
break;

case 'localRemoveRemoteBlacklist':
localRemoveRemoteBlacklist(request.location);
break;

case 'mergeBlacklistedHosts':
mergeBlacklistedHosts(request);
break;

case 'reloadPresetBlacklists':
reloadPresetBlacklists(request.switches);
break;
Expand Down
3 changes: 2 additions & 1 deletion js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ var HTTPSB = {
permanentScopes: null,
factoryScope: null,

// Current entries from remote blacklists --
// Current entries from ubiquitous lists --
// just hostnames, '*/' is implied, this saves significantly on memory.
ubiquitousBlacklist: null,
ubiquitousWhitelist: null,

// various stats
requestStats: new WebRequestStats(),
Expand Down
9 changes: 7 additions & 2 deletions js/httpsb.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,13 @@ HTTPSB.getPermanentColor = function(scopeKey, type, hostname) {
return 'xxx';
}
}
if ( type === '*' && this.ubiquitousBlacklist.test(hostname) ) {
return 'rdp';
if ( type === '*' ) {
if ( this.ubiquitousWhitelist.test(hostname) ) {
return 'gdp';
}
if ( this.ubiquitousBlacklist.test(hostname) ) {
return 'rdp';
}
}
return 'xxx';
};
Expand Down
2 changes: 1 addition & 1 deletion js/liquid-dict.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@ HTTPSB.LiquidDict.prototype.reset = function() {
/******************************************************************************/

HTTPSB.ubiquitousBlacklist = new HTTPSB.LiquidDict();
// HTTPSB.ubiquitousWhitelist = new HTTPSB.LiquidDict();
HTTPSB.ubiquitousWhitelist = new HTTPSB.LiquidDict();

Loading

0 comments on commit 1c9eadb

Please sign in to comment.