From 0d332a40843ba092a096dfda634997efa8396965 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 6 Jun 2014 11:07:50 -0400 Subject: [PATCH] this fixes #330 --- _locales/de/messages.json | 4 ++++ _locales/en/messages.json | 4 ++++ _locales/fr/messages.json | 4 ++++ _locales/ru/messages.json | 4 ++++ _locales/zh_CN/messages.json | 8 +++++--- js/storage.js | 24 +++++++++++++++++++----- ubiquitous-rules.html | 2 +- 7 files changed, 41 insertions(+), 9 deletions(-) diff --git a/_locales/de/messages.json b/_locales/de/messages.json index e243727..fb0d1ca 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -485,6 +485,10 @@ "message": "Eine Regel pro Zeile. Eine Regel kann ein einfacher Hostname sein oder ein Adblock Plus-kompatibler Filter. Zeilen mit vorangestelltem ‘#’ werden ignoriert.", "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored." }, + "ubiquitousAllowFormatHint" : { + "message": "Eine Regel pro Zeile. Eine Regel kann ein einfacher Hostname sein oder ein Adblock Plus-kompatibler Filter. Zeilen mit vorangestelltem ‘#’ werden ignoriert.", + "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored." + }, "ubiquitousImport" : { "message": "Importieren und anfügen", "description": "English: Import and append" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 5f98d91..9adf13b 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -485,6 +485,10 @@ "message": "One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored.", "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored." }, + "ubiquitousAllowFormatHint" : { + "message": "One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored.", + "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored." + }, "ubiquitousImport" : { "message": "Import and append", "description": "English: Import and append" diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 79fc38c..4530b22 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -485,6 +485,10 @@ "message": "Une règle par ligne. Une règle peut être un simple nom d'hôte, ou encore un filtre respectant la syntaxe des filtres Adblock Plus. Les lignes débutant par ‘#’ seront ignorées.", "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored." }, + "ubiquitousAllowFormatHint" : { + "message": "Une règle par ligne. Une règle peut être un simple nom d'hôte, ou encore un filtre respectant la syntaxe des filtres d'exception Adblock Plus. Les lignes débutant par ‘#’ seront ignorées.", + "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored." + }, "ubiquitousImport" : { "message": "Importer", "description": "English: Import and append" diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index fccf929..dee4d2f 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -485,6 +485,10 @@ "message": "Одно правило на строку. Правилом может быть обычное имя сайти, или Adblock Plus-совместимый фильтр. Линии начинающиеся с ‘#’ будут пропущены.", "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored." }, + "ubiquitousAllowFormatHint" : { + "message": "Одно правило на строку. Правилом может быть обычное имя сайти, или Adblock Plus-совместимый фильтр. Линии начинающиеся с ‘#’ будут пропущены.", + "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored." + }, "ubiquitousImport" : { "message": "Импортировать и добавить", "description": "English: Import and append" diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index 7a7cc55..2175f7c 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -272,7 +272,6 @@ "description": "To help the user understand the purpose of strict blocking" }, "settingsAutoCreateScopePrompt1": { - "message": "Auto create temporary", "message": "自动添加临时", "description": "English: Auto create temporary" }, @@ -369,9 +368,8 @@ "description": "..." }, "settingsDeleteBlockedLocalStoragePrompt" : { - "message": "Delete local storage content set by blocked hostnames", "message": "删除被屏蔽站点名的本地网页存储内容集。", - "description": "..." + "description": "English: Delete local storage content set by blocked hostnames" }, "settingsDeleteBlockedLocalStorageHelp" : { "message": "TODO", @@ -487,6 +485,10 @@ "message": "每行一条规则。一条规则可以是一个平凡的站点名或者是一条Adblock Plus的兼容过滤规则。以“#”开头的行将被忽略。", "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored." }, + "ubiquitousAllowFormatHint" : { + "message": "每行一条规则。一条规则可以是一个平凡的站点名或者是一条Adblock Plus的兼容过滤规则。以“#”开头的行将被忽略。", + "description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored." + }, "ubiquitousImport" : { "message": "导入并附加规则", "description": "English: Import and append" diff --git a/js/storage.js b/js/storage.js index ff4e458..0e537d6 100644 --- a/js/storage.js +++ b/js/storage.js @@ -167,7 +167,10 @@ HTTPSB.loadUbiquitousWhitelists = function() { HTTPSB.mergeUbiquitousWhitelist = function(details) { var ubiquitousWhitelist = this.ubiquitousWhitelist; - var reAdblockFilter = /^[^a-z0-9:]|[^a-z0-9]$|[^a-z0-9_:.-]/; + var reAdblockHideFilter = /#@#/; + var reAdblockNetFilter = /^@@/; + var abpNetFilters = this.userSettings.parseAllABPFilters ? this.abpFilters : null; + var abpHideFilters = this.userSettings.parseAllABPHideFilters ? this.abpHideFilters : null; var raw = details.content.toLowerCase(); var rawEnd = raw.length; var lineBeg = 0; @@ -183,6 +186,21 @@ HTTPSB.mergeUbiquitousWhitelist = function(details) { } line = raw.slice(lineBeg, lineEnd).trim(); lineBeg = lineEnd + 1; + + if ( reAdblockHideFilter.test(line) ) { + if ( abpHideFilters !== null ) { + abpHideFilters.add(line); + } + continue; + } + + if ( reAdblockNetFilter.test(line) ) { + if ( abpNetFilters !== null ) { + abpNetFilters.add(line); + } + continue; + } + pos = line.indexOf('#'); if ( pos >= 0 ) { line = line.slice(0, pos); @@ -191,10 +209,6 @@ HTTPSB.mergeUbiquitousWhitelist = function(details) { if ( line === '' ) { continue; } - // Ignore whatever appears to be an Adblock filters - if ( reAdblockFilter.test(line) ) { - continue; - } ubiquitousWhitelist.add(line); } }; diff --git a/ubiquitous-rules.html b/ubiquitous-rules.html index 17a8692..435c348 100644 --- a/ubiquitous-rules.html +++ b/ubiquitous-rules.html @@ -69,7 +69,7 @@

-

+